error: fzero: zero point is not bracketed
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!
Answers (1)
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
Andreea Oana
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)
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)
.
Categories
Find more on Symbolic Math Toolbox 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!