How can I find X for given Y value in a fitted curve. I have a non- linear equation of 6th order.
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
X = [1:0.05:6.5];
Y = 0.0178*(X.^6) -0.3463*(X.^5) + 2.6845*(X.^4) -10.426*(X.^3) + 21.192*(X.^2) -20.642*X + 7.5426;
I have to find X for Y= 2.75e-06.
I really appreciate any help you can provide.
Shivam
1 Kommentar
Dyuman Joshi
am 20 Okt. 2022
You have an equation and a value, why not directly solve for it?
0.0178*x^6 -0.3463*x^5 + 2.6845*x^4 -10.426*x^3 + 21.192*x^2 -20.642*x + 7.5426 - 2.75e-6 = 0
Antworten (2)
John D'Errico
am 20 Okt. 2022
There are more digits in those numbers as estimated. Just using numbers accurate to 4 digits is far too low for a 6th degree polynomial. The results may be suspect.
Effectively, when you say the firt coefficient is 0.0178, there are still more digits there, but just rounded off. So in realiity, that number is anything from the interval 0.01775 to 0.01785. The problem is, that tiny change in the value of this coefficient can sometimes significantly influence the result.
Here are the coefficients you have reported. as a vector:
C0 = [0.0178, -0.3463, 2.6845, -10.426, 21.192, -20.642, 7.5426];
% next, the uncertyainties in C. The true value of the coefficients in C is something in the
% interval C0 plus or minus U, for each coefficient.
U = [0.00005,0.00005 0.00005, 0.0005, 0.0005, 0.0005, 0.00005];
Ytarget = 2.75e-6;
C = C0;
C(end) = C(end) - Ytarget;
roots(C)
Do you see there are no solutions to this problem in real numbers? All of the roots are complex. Another way of looking at this is to look at the plot of your function. Look where this curve crosses y == 0
fplot(@(x) polyval(C,x),[0,5])
Yet that curve never actually crosses zero. It comes pretty close. I'lll zoom into the point near the closest point of approach.
fplot(@(x) polyval(C,x),[1.05,1.1])
But as you can see in this second plot, it never really crosses the axis.
Anyway, as I showed above, you can use roots to solve the problem, but your coefficients are inadequate to actually solve the problem for a real root.
A best guess for the solution is the approximate value around 1.08. We might get that as the minimum value of this polynomial
fminbnd(@(x) polyval(C,x).^2,0,10)
0 Kommentare
dpb
am 20 Okt. 2022
Bearbeitet: dpb
am 20 Okt. 2022
"ALWAYS" plot your equation first --
fnY=@(X)0.0178*(X.^6) -0.3463*(X.^5) + 2.6845*(X.^4) -10.426*(X.^3) + 21.192*(X.^2) -20.642*X + 7.5426;
Y0=2.75E-6;
ezplot(fnY)
hAx=gca;
hL=hAx.Children;
[Ymin,Xmin]=min(fnY(hL.XData));
hAx.YScale='log';
ylim([1E-6 1E4])
yline(Y0,'-',"YZero")
yline(Ymin,'-',"Ymin "+num2str(Ymin,'%0.5f'))
There is no solution for that value...
But, we only looked at the values calculated by ezplot, maybe there is a very narrow minimum???
Xmin=fminsearch(fnY,1)
Ymin=fnY(Xmin)
2 Kommentare
Dyuman Joshi
am 20 Okt. 2022
Evidently, interp1 returns NaN as well.
X = [1:0.05:6.5];
Y = 0.0178*(X.^6) -0.3463*(X.^5) + 2.6845*(X.^4) -10.426*(X.^3) + 21.192*(X.^2) -20.642*X + 7.5426;
interp1(Y,X,2.75e-6)
Since we are reverse interpolating, it should suggest that there exists no value corresponding to it.
John D'Errico
am 22 Okt. 2022
Yes. I showed in my answer there is no solution possible for that y. Though the function comes close near one point, it lies everywhere above that value.
format long g
fnY=@(X)0.0178*(X.^6) -0.3463*(X.^5) + 2.6845*(X.^4) -10.426*(X.^3) + 21.192*(X.^2) -20.642*X + 7.5426;
[xmin,ymin] = fminbnd(fnY,-10,10)
That is the global min in fact, since the target value of 2.75e-06 is closer to -inf than the global minimum, no real valued solution could ever be found. There are of course 6 complex solutions, two of which will be close to that point, with small imaginary parts.
Siehe auch
Kategorien
Mehr zu Polynomials finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!