No solution found using fsolve, what should I do?
5 views (last 30 days)
Show older comments
I'm trying to solve a nonlinear system with six equations and six unknowns (Basically it is trying to find the fixed point of a mapping from to ).
I wrote the following small experiment:
tempx=1;
p0=0.5*ones(1,6);
fsub=@(p)ComputeCCP(tempx,p);
[trueccp,fv,ext]=fsolve(fsub,p0);
It takes a long time to run this code, and in the end, it returns "No solution found". The function I feed into fsolve is called fsub, and it is a function of p. It is constructed using a function called ComputeCCP when its first parameter tempx is fixed at 1. I attached ComputeCCP in this question. It is slow to evaluate because I used 1 million simulations inside this function to compute double integrals (which gives probabilities) with high precision.
Why fsolve is not working here? What shall I do to find a solution to this system? Thanks in advance!
0 Comments
Accepted Answer
John D'Errico
on 3 Nov 2022
Edited: John D'Errico
on 3 Nov 2022
A simple rule is fsolve assumes the function you feed it is well behaved. That means things like continuity. Differentiable. At the very least, it means that if you were to evaluate the function at the same set of values twice in a row, it would generate exactly the same result.
format long g
fsub(.5*ones(1,6))
ans =
Columns 1 through 3
0.096333 0.302968 0.30198
Columns 4 through 6
0.10278 0.319573 0.318503
fsub(.5*ones(1,6))
ans =
Columns 1 through 3
0.096683 0.30191 0.301975
Columns 4 through 6
0.102587 0.319008 0.318855
Do you see anything interesting there? That when evaluated at exactly the same point twice in a row, your function is not even consistent, returning the same result. That means continuity and especially differentiability are completely out of the question.
If I look at your code:
z11=normrnd(0,3);
z12=normrnd(0,3);
z21=normrnd(0,3);
z22=normrnd(0,3);
e11=normrnd(0,3);
e12=normrnd(0,3);
e21=normrnd(0,3);
e22=normrnd(0,3);
it appears to be a simulation of some sort. Is that going to produce the well-defined function I said fsolve REQUIRES? No.
I'm sorry. It does not matter how badly you want to use fsolve, you cannot do so.
11 Comments
More Answers (0)
See Also
Categories
Find more on Systems of Nonlinear Equations 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!