MATLAB Answers

How to expand the solve answer?

2 views (last 30 days)
I CHUN LIN
I CHUN LIN on 21 May 2021
Commented: I CHUN LIN on 21 May 2021
Hi,
when I run the code
clear; clc;
syms x
y = 3*x.^2 - 10*x + 1.01;
solve(y == 1, x)
this give me the answer
5/3 - 2497^(1/2)/30
2497^(1/2)/30 + 5/3
How can I expand these to
0.0010
3.3323
Thank you very much!

Answers (2)

John D'Errico
John D'Errico on 21 May 2021
You want to convert them to floating point numbers.
syms x
y = 3*x.^2 - 10*x + 1.01;
xsol = solve(y == 1, x);
vpa(xsol) % produces a floating point symbolic number, so many digits
ans = 
double(xsol) % produces a double precision version
ans = 2×1
0.0010 3.3323
  1 Comment
I CHUN LIN
I CHUN LIN on 21 May 2021
I got it!
Thank you very much!

Sign in to comment.


EmirBeg
EmirBeg on 21 May 2021
Try vpasolve();
clear; clc;
syms x
y = 3*x.^2 - 10*x + 1.01;
vpasolve(y == 1, x)
  1 Comment
I CHUN LIN
I CHUN LIN on 21 May 2021
That is!
Thank you very much!

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!