Solving a third a cubic polynom for a certain for a fixed Y value
显示 更早的评论
Hi there,
i really would like to solve (multiple x solutions) from my cubic polynom for a given y=0,7 value.
Polynom:
y = 9e-11x3-2e-07x2-5e-05x+1,0009
I´m having trouble to sovle this equation bc i´m not interested in their complex roots. SHould have a at least one real solution.
Thanks in advance
回答(1 个)
Star Strider
2020-7-22
Solve for the roots, regardless:
syms x
y = 9e-11*x.^3 - 2e-07*x.^2 - 5e-05*x + 1.0009;
ys = solve(y == 0.7)
ys = vpa(ys)
or:
y = 0.7;
ys = roots([9e-11 -2e-07 -5e-05 (1.0009-y)])
Both (not surprisingly) give the same results.
.
5 个评论
Nicolás Casal Diaz
2020-7-22
John D'Errico
2020-7-22
This is a cubic polynomial.
syms x
y = 9e-11*x^3-2e-07*x^2-5e-05*x+1.0009;
fplot(y,[-2000,2500])
yline(0.7);

It has ONE location where it crosses y = 0.7. That happens around x = -1000.
You are asking for an absolute minimum? But that never exists for any cubic polynomial. Are you asking for the point where it comes closest to y = 0.7? That happens near x=-1000.
Are you asking for the location where it comes closest to 0.7, for positive x? fminbnd will sufficie for that.
Star Strider
2020-7-22
Try this:
yfcn = @(y) roots([9e-11 -2e-07 -5e-05 (1.0009-y)]);
ys = fminunc(@(y)norm(yfcn(y)), 0.5)
Check = yfcn(ys)
producing:
Check =
2057.35299998955
-867.062734657622
1031.93195689029
That produces three real roots, two of them positive.
.
Nicolás Casal Diaz
2020-7-23
Star Strider
2020-7-23
John — Again, thank you! (I didn’t see your Comment before.)
Nicolás Casal Diaz —
Try this:
syms x
y(x) = 9e-11*x.^3 - 2e-07*x.^2 - 5e-05*x + 1.0009;
dy = diff(y);
d2y = diff(dy);
xval = solve(dy == 0, d2y > 0); % Solve For Minimum Inflection Point
xval = vpa(xval)
yval = y(xval)
producing:
xval =
1597.4098893496575451843309791331
yval =
0.77753844671553907872492123183542
It might be possible to do that without the Symbolic Math Toolbox, however it is easier this way.
.
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!