Solve function has no numerical answer
Show older comments
i'm trying to solve a simple eqation which has a large answer, but i can't get numerical answer, which keep having an answer of z2^5.
How can I get the numerical answer? vpasovle() has used.
The answer should be 1.24209e17.
Here is my code
lambda0=1.3e-6;
L=1.8e-3;
syms x
A=-6.2*10^(-22);
B=-6*10^(-18);
C=lambda0/(2*L);
eq=A*x+B*x^0.8==C;
anss=solve(eq,x,'ReturnConditions',true);
if not adding 'ReturnCondition', there will have warning
Warning: Solutions are parameterized by the symbols: z2. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
4 Comments
When in doubt, plot it to see what ti does.
The function does not appear to have a solution, however it has some interesting behaviour.
lambda0=1.3e-6;
L=1.8e-3;
syms x
A=-6.2*10^(-22);
B=-6*10^(-18);
C=lambda0/(2*L);
eq=A*x+B*x^0.8==C;
eq0 = vpa(lhs(eq) - rhs(eq), 6)
Sx = solve(eq0)
Sxr = solve(real(eq0))
Sxi = solve(imag(eq0))
figure
hfp = fplot(imag(eq0), [-1 1]*1E+18);
hold on
grid
ylim([-1 1]*1E-3)
plot(Sxi,0, '+r', 'MarkerSize',15)
hold off
title('Imaginary')
figure
hfp = fplot(real(eq0), [-1 1]*3E+17);
hold on
grid
ylim([-1 1]*1E-3)
plot(Sxr,0, '+r', 'MarkerSize',15)
hold off
title('Real')
.
David Goodmanson
on 12 Jan 2022
Hi ccl,
I believe the intent is that A and B be positive and not negative. That change gives the result you are looking for.
If A is negative, the fact that C is positive forces x to be negative. Then taking x to the 0.8 power leads to an imaginary part and a complex result which is not what you want.
chia ching lin
on 13 Jan 2022
Accepted Answer
More Answers (0)
Categories
Find more on Numeric Solvers 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!



