Getting Empty sym: 0-by-1 when using solve function
Show older comments
I am trying to find the value of x when the equation is equal to zero. I keep getting an empty sym 0-by-1. Any suggestions? Thanks!
I = (pi*.015^4)/64;
E = 200*10^9;
syms x
[x] = solve(0 == (1/(E*I))*((-199.46/2)*x^2 + (290/2)*(x-.25)^2 - (90.66/2)*(x-.8)^2 + 11.22),x)
x = double(x)
3 Comments
Walter Roberson
on 24 Nov 2018
solve requests that an infinitely precise solution be found if possible . It makes little sense to use solve with floating point numbers as floating point numbers represent a semirandom point within an interval . It is a category error to use the two together . You should only use solve with infinitely precise inputs
For example is the 11.22 standing in for 101/9 ?
Mason Osborn
on 24 Nov 2018
Walter Roberson
on 24 Nov 2018
vpasolve potentially
Answers (1)
Star Strider
on 23 Nov 2018
Edited: Star Strider
on 23 Nov 2018
Your code works for me:
I = (pi*.015^4)/64;
E = 200*10^9;
syms x
[x] = solve(0 == (1/(E*I))*((-199.46/2)*x^2 + (290/2)*(x-.25)^2 - (90.66/2)*(x-.8)^2 + 11.22),x)
x = double(x)
producing:
x =
7/30 - (2^(1/2)*261763^(1/2)*1i)/60
(2^(1/2)*261763^(1/2)*1i)/60 + 7/30
x =
0.233333333333333 - 12.0591827620651i
0.233333333333333 + 12.0591827620651i
4 Comments
Mason Osborn
on 24 Nov 2018
Walter Roberson
on 24 Nov 2018
you appear to have a quadratic . Expand it out and group terms and use the quadratic formula . II would be surprised if matlab is not calculating it correctly .
In other words either your equation is wrong or your expectations of aa real solution are wrong .
Star Strider
on 24 Nov 2018
Your function has no real roots. If you plot it, this quickly becomes evident:
syms x real
I = sym((pi*.015^4)/64);
E = sym(200E9);
Eqn = (1/(E*I))*((-199.46/2)*x^2 + (290/2)*(x-.25)^2 - (90.66/2)*(x-.8)^2 + 11.22);
figure
fplot(Eqn, [-10 10])
ylim([-0.03 0.001])
grid
You can expand the fplot limits as far as you like. It does not change the result.
I got the empty result with real, and without it (using vpasolve):
x =
7/30 - (523526^(1/2)*1i)/60
(523526^(1/2)*1i)/60 + 7/30
x =
0.23333333333333333333333333333333 - 12.059182762065134606377924566193i
0.23333333333333333333333333333333 + 12.059182762065134606377924566193i
I am using R2018b.
Walter Roberson
on 24 Nov 2018
Your equation has an expression in x in the numerator, and has E*I in the denominator. For any E*I that is non-zero and independent of x, then the roots of the equation are the same as the roots of the numerator. Therefore the values of E and I do not matter for the purpose of finding roots.
Your equation simplifies to
-600*x^2+280*x-87287 / (10000*E*I)
"a" and "c" are both negative, so b^2-4*a*c is subtracting a positive value from b^2, and -4*a*c is larger than b^2, so you would be taking sqrt() of a negative number. It isn't borderline either: it is solidly negative, around -209410400
Therefore no real roots.
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!