Solve Three non-linear equations for 3 variables system
9 views (last 30 days)
Show older comments
I have the followig three equations
eq1=72000==((B*4000)/(log(A*4000)-log(log(1+(1/Yse)))))
eq2=65000==((B*3500)/(log(A*3500)-log(log(1+(1/Yse)))))
eq3=55000==((B*3000)/(log(A*3000)-log(log(1+(1/Yse)))))
I would like to solve them for A,B, and Yse.
Every time I used Syms it comes back with empty cell and no symolic solutions found, What other functions do you recommened for solving them numerically ?
Thank you
0 Comments
Accepted Answer
Walter Roberson
on 27 Jul 2022
Edited: Walter Roberson
on 27 Jul 2022
There are no real solutions. In order for there to be real solutions, some of the log() terms would have to cross zero, but when you study them (variables L1 and L2) they cannot do that. Instead the log terms are either always complex or else always positive in a way that does not permit balancing the equations.
syms A B Yse
eq1=72000==((B*4000)/(log(A*4000)-log(log(1+(1/Yse)))))
eq2=65000==((B*3500)/(log(A*3500)-log(log(1+(1/Yse)))))
eq3=55000==((B*3000)/(log(A*3000)-log(log(1+(1/Yse)))))
part_B = solve(eq1, B)
eqn4 = subs([eq2, eq3], B, part_B)
part_A = solve(eqn4(1), A)
eqn5 = subs(eqn4(2:end), A, part_A)
Ysea = vpasolve(eqn5(1))
Yseb = vpasolve(eqn5(2))
Z1 = simplify(lhs(eqn5(1)) - rhs(eqn5(1)))
L1 = simplify(cellfun(@(X) X, children(findSymType(Z1, 'log'),1)))
Z2 = simplify(lhs(eqn5(2)) - rhs(eqn5(2)))
L2 = simplify(cellfun(@(X) X, children(findSymType(Z2, 'log'),1)))
sol1 = arrayfun(@solve, L1, 'uniform', 0)
sol2 = arrayfun(@solve, L2, 'uniform', 0)
0 Comments
More Answers (2)
Harshit Gupta
on 27 Jul 2022
Hi, you need to specify the veriables to solve for and then this works just fine
syms A B Yse;
eq1=72000==((B*4000)/(log(A*4000)-log(log(1+(1/Yse)))))
eq2=65000==((B*3500)/(log(A*3500)-log(log(1+(1/Yse)))))
eq3=55000==((B*3000)/(log(A*3000)-log(log(1+(1/Yse)))))
Now you can store these equations in a structure array
eqns = [eq1, eq2, eq3]
Now the input is complicated for solve() function but this can be further solved.
I recommend reading this part of the documentation: Troubleshoot Equation Solutions from solve Function
Hope that helps!
0 Comments
Torsten
on 27 Jul 2022
You might want to try a numerical solver, but the two I tested also didn't succeed.
fun = @(A,B,C)[72000-(B*4000)/(log(A*4000)-C);65000-(B*3500)/(log(A*3500)-C);55000-(B*3000)/(log(A*3000)-C)]
options = optimset('MaxFunEvals',1000000,'MaxIter',1000000);
sol = fsolve(@(x)fun(x(1),x(2),x(3)),[18 0 -1],options)
%sol = lsqnonlin(@(x)fun(x(1),x(2),x(3)),[18 0 -1],[],[],options)
fun(sol(1),sol(2),sol(3))
1 Comment
Torsten
on 27 Jul 2022
The problem with your set of equations is that you have 3 equations, but in reality only 2 and not 3 free parameters.
If you write your equation as
data1 = data2 * B / (A1 + A2 + log(data2))
with
A1 = log(A), A2 = -log(log(1+(1/Yse)))
you can see that the sum A1 + A2 only gives one degree of freedom, not two.
So you can fit two data points to the function above, but not three.
See Also
Categories
Find more on Quadratic Programming and Cone Programming 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!