[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fminbnd doesn't give correction solution?
From: |
paul6 |
Subject: |
fminbnd doesn't give correction solution? |
Date: |
Fri, 7 Sep 2018 09:21:05 -0500 (CDT) |
I am testing to solve an equation y = x.^3 - 2*x.^2 - 58 using different
functions, only "fzero" gives correct solution. The test code is as follows.
I'm using 4.2.1 version. Thanks for any help!function
test_eqn%[z1,fv1,info1,out1] = fminbnd(@f2,1.5,6) %[z2,fv2,info2,out2] =
fminbnd(@f2,1.5,6) [z1,fv1] = fminbnd(@f2,1.5,6);[z1,fv1] =
fminbnd(@f2,1.5,6); [z2,fv2] = fminbnd(@f2, 1.5, 6);[z3,fv3] =
fzero(@f2,[1.5 6]);[z4,fv4] = fminsearch(@f2,2);[z5,fv5] =
fminunc(@f2,5);fprintf('z1=%f, fv1=%f\n',z1,fv1);fprintf('z2=%f,
fv2=%f\n',z2,fv2);fprintf('z3=%f, fv3=%f\n',z3,fv3);fprintf('z4=%f,
fv4=%f\n',z4,fv4);fprintf('z5=%f, fv5=%f\n',z5,fv5);%% output from the above
solutions in Octave 4.2.1.% Only "z3" obtained from "fzero" is right.%
z1=1.500000, fv1=-59.125000% z2=1.500000, fv2=-59.125000% z3=4.665079,
fv3=0.000000% z4=1.333374, fv4=-59.185185% z5=1.333342,
fv5=-59.185185%=========================function y = f2(x)y = x.^3 - 2*x.^2
- 58;
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- fminbnd doesn't give correction solution?,
paul6 <=