error: fzero: zero point is not bracketed
9 views (last 30 days)
Show older comments
Hi. So this is what I wrote so far in octave:
syms x
f=4*x.^2+20*x+4
x=fzero(@(x) f, -5)
but I keep getting the error in the title. What is wrong with what I wrote? Thanks in advance!
0 Comments
Answers (1)
Star Strider
on 5 Jan 2022
Use fzero for numeric functions and solve for symbollic functions —
syms x
f=4*x.^2+20*x+4
x=vpa(solve(f==0))
format long
xd = double(x)
whos x xd
.
3 Comments
Walter Roberson
on 5 Jan 2022
syms x
f=4*x.^2+20*x+4
F = matlabFunction(f)
x = fzero(F, -5)
or
f = @(x) 4*x.^2 + 20*x + 4
x = fzero(f, -5)
Star Strider
on 5 Jan 2022
One approach —
syms x
f=4*x.^2+20*x+4
f_fcn = matlabFunction(f)
format long
x=fzero(f_fcn,-5)
To get the other root, use a different initial parameter estimate —
x=fzero(f_fcn,-1)
.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!