Solving 4 non-linear equations for 4 unknowns using fsolve
Show older comments
Hello,
I am trying to fit 2 non-linear equations (dashed, blue lines) to 2 sets of experimental data (solid, red or black lines). Within these 2 equations are 4 unknowns (u1, n1, u2, and n2). I have therefore developed 4 equations such that the endpoints of my new equations should be equal those of the experimental data. Now I have 4 equations and 4 unknowns. Here are the issues that I am experiencing using fsolve:
- When plugging in the 4 solutions back into my 2 non-linear equations, the endpoints do not match the experimental data. I expect that the endpoint values should be the same because I set these in fsolve_function.
- When making the initial guesses for the solutions, 2 of the solutions (e.g. n1 and n2) are always the same as my initial guess, and the other 2 solutions (e.g. u1 and u2) change. I expect all 4 values to change to values that are different from my initial guesses.
What could be the causes?
Here is my function:
function F = fsolve_function (Y)
%Unpack variables
u1 = Y(1);
n1 = Y(2);
u2 = Y(3);
n2 = Y(4);
%Constants
e = 1.602 *10^-19; %Coulomb, electron charge
%Constraints from experimental data
A = 0.000438; %value at B=0 for Gxx
B = 0.0003; %value at B=14 for Gxx
C = 0.0000061841; %slope at B=0 for Gxy
D = 0.0000381; %value at B=14 for Gxy
%Input equations
%Gxx, inserting value at B=0T
equation1 = n1*e*u1 + n2*e*u2 - A;
%Gxx, inserting value at B=14T
equation2 = ( (n1*e*u1) / (1+u1^2*(14^2)) ) + ( (n2*e*u2) / (1+u2^2*(14^2)) ) - B;
%Gxy, inserting slope at B=0T
equation3 = n1*e*u1^2 + n2*e*u2^2 - C;
%Gxy, inserting value at B=14T
equation4 = ( (n1*e*u1^2*14) / (1+u1^2*14) ) + ( (n2*e*u2^2*14) / (1+u2^2*14) ) - D;
%Pack up our function
F = [equation1; equation2; equation3; equation4; ];
Here is my script:
%Initial guesses
u1o = 0.009;
n1o = 5 * 10^17;
u2o = 0.5;
n2o = 2 * 10^19;
Y0 = [u1o; n1o; u2o; n2o];
%Call fsolve function
fhandle = @fsolve_function;
Y = fsolve (fhandle, Y0);
%Display solutions for our 4 variables
disp ('u1, n1, u2, n2');
disp (Y(1:4));
Here are my results: As one can see. The endpoints of the simulated data (dashed, blue lines) do not match those of the experimental data (solid red or black lines) even though I set these values in my fsolve_function. Secondly the values for n1 and n2 are the same as my initial gueses while the others (u1 and u2) changes. If someone could help me understand perhaps what the issue may be that would be very helpful!
Thanks,
Chris

1 Comment
Walter Roberson
on 27 Aug 2020
There are two real-valued solutions to the equations:
Y1 = 0.1437438700474650, Y2 = 4.82587963631918*10^15, Y3 = -0.0299508173739704, Y4 = -6.812474451761340*10^16
Y1 = -0.02995081737398195, Y2 = -6.812474451761304*10^16, Y3 = 0.1437438700474649, Y4 = 4.825879636317568*10^15
The other 6 solutions all involve complex values.
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential 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!