# How is f(x) evaluated for each iteration using fsolve?

5 visualizzazioni (ultimi 30 giorni)
TS il 14 Gen 2019
Commentato: Torsten il 15 Gen 2019
I'm using fsolve for an unconstrained non-linear function. And I notice that fval is much different than f(x) for the last iteration. How exactly is f(x) calculated?
##### 13 CommentiMostra 11 commenti meno recentiNascondi 11 commenti meno recenti
TS il 14 Gen 2019
So it's the squared error? I got confused because it says f(x) even though it's the sum of squared function values.
Thanks so much!
Stephen23 il 14 Gen 2019
Modificato: Stephen23 il 14 Gen 2019
"I got confused because it says f(x) even though it's the sum of squared function values."
I agree that the inconsistent labeling is confusing at best, and at worst incorrect. You should make a bug report (and include a link to this thread).

Accedi per commentare.

### Risposta accettata

Martijn il 15 Gen 2019
The values shown under f(x) in the iteration table are indeed not literally the function values at that given iteration, you are seeing the square of the norm of the function value vector here; as documented, see:
The reason for this is that "fsolve" can actually solve whole systems of equations where f(x) would then be a whole vector of values. Displaying this whole vector in the table is not really feasible, there is not enough space for that. Hence, instead, a measure is shown which basically summarizes the whole f(x) vector in a single measure which also actually is representative for how good the current solution is.
We could look into whether we can perhaps change the header to ||f(x)||^2 in future releases to better illustrate this.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Torsten il 15 Gen 2019
Or use norm(f) instead of norm(f)^2.

Accedi per commentare.

### Più risposte (1)

RANJEET YADAV il 14 Gen 2019
f(x)=fsolve(@(x) funname(x),x=1);
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Solver Outputs and Iterative Display in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by