MATLAB Answers

How should I store the value of f(x) in the output of fsolve?

4 views (last 30 days)
Dan Zhu
Dan Zhu on 28 Jun 2020
Answered: Matt J on 28 Jun 2020
I saw the example in the fsolve page:
F = @(x) [2*x(1) - x(2) - exp(-x(1));
-x(1) + 2*x(2) - exp(-x(2))];
x0 = [-5;-5];
options = optimoptions('fsolve','Display','iter');
[x,fval] = fsolve(F,x0,options)
which gives the result:
Norm of First-order Trust-region
Iteration Func-count f(x) step optimality radius
0 3 47071.2 2.29e+04 1
1 6 12003.4 1 5.75e+03 1
2 9 3147.02 1 1.47e+03 1
3 12 854.452 1 388 1
4 15 239.527 1 107 1
5 18 67.0412 1 30.8 1
6 21 16.7042 1 9.05 1
7 24 2.42788 1 2.26 1
8 27 0.032658 0.759511 0.206 2.5
9 30 7.03149e-06 0.111927 0.00294 2.5
10 33 3.29525e-13 0.00169132 6.36e-07 2.5
Now, I want to store the last value of f(x), 3.29525e-13, in a file, what should I do?

  0 Comments

Sign in to comment.

Answers (1)

Tags