How can I use fzero on these two functions?
8 views (last 30 days)
Show older comments

I can't seem to get fzero to work on these two functions. I tried rearanging them to bring it to one side but it would not work. Please help me with this.
This is the code I have been trying to use for the second problem
f=@(x) (log(4*x-3))/-0.1
fzero(f,[0 4])
It then gives me this error
Error using fzero
Function values at interval endpoints must be finite and real.
Error in A3_SECTION_07_501178997_501160077 (line 6)
fzero(f,[0 4])
0 Comments
Accepted Answer
John D'Errico
on 8 Oct 2022
Edited: John D'Errico
on 8 Oct 2022
Why in the name of god and little green apples do you want to transform the function, by taking the log? Just move the exponential to the right hand side, so fzero will be looking for a zero result.
First, verify a solution exists.
F2 = @(x) -exp(-0.1*x) + 4*x - 3;
fplot(F2,[0,4])
grid on
Clearly, one does, and it is near x==1.
fzero(F2,[0,4])
2 Comments
John D'Errico
on 8 Oct 2022
Just a phrase I always liked. :-) It does seem to fit on Answers often enough.
More Answers (2)
Torsten
on 8 Oct 2022
Use the original equation. Why do you take log on both sides - it only implies problems for x <= 3/4.
f = @(x)4*x-3-exp(-0.1*x);
x0 = fzero(f,[0 4])
f(x0)
0 Comments
See Also
Categories
Find more on Optimization 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!