Solve Three non-linear equations for 3 variables system

9 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 27 Lug 2022
Modificato: Walter Roberson il 27 Lug 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)))))
eq1 = 
eq2=65000==((B*3500)/(log(A*3500)-log(log(1+(1/Yse)))))
eq2 = 
eq3=55000==((B*3000)/(log(A*3000)-log(log(1+(1/Yse)))))
eq3 = 
part_B = solve(eq1, B)
part_B = 
eqn4 = subs([eq2, eq3], B, part_B)
eqn4 = 
part_A = solve(eqn4(1), A)
Warning: Possibly spurious solutions.
part_A = 
eqn5 = subs(eqn4(2:end), A, part_A)
eqn5 = 
Ysea = vpasolve(eqn5(1))
Ysea = Empty sym: 0-by-1
Yseb = vpasolve(eqn5(2))
Yseb = Empty sym: 0-by-1
Z1 = simplify(lhs(eqn5(1)) - rhs(eqn5(1)))
Z1 = 
L1 = simplify(cellfun(@(X) X, children(findSymType(Z1, 'log'),1)))
L1 = 
Z2 = simplify(lhs(eqn5(2)) - rhs(eqn5(2)))
Z2 = 
L2 = simplify(cellfun(@(X) X, children(findSymType(Z2, 'log'),1)))
L2 = 
sol1 = arrayfun(@solve, L1, 'uniform', 0)
sol1 = 1×3 cell array
{0×1 sym} {0×1 sym} {0×1 sym}
sol2 = arrayfun(@solve, L2, 'uniform', 0)
sol2 = 1×3 cell array
{0×1 sym} {0×1 sym} {0×1 sym}

Più risposte (2)

Harshit Gupta
Harshit Gupta il 27 Lug 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)))))
eq1 = 
eq2=65000==((B*3500)/(log(A*3500)-log(log(1+(1/Yse)))))
eq2 = 
eq3=55000==((B*3000)/(log(A*3000)-log(log(1+(1/Yse)))))
eq3 = 
Now you can store these equations in a structure array
eqns = [eq1, eq2, eq3]
eqns = 
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!

Torsten
Torsten il 27 Lug 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)]
fun = function_handle with value:
@(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)
Solver stopped prematurely. fsolve stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 1.000000e+06.
sol = 1×3
0.0007 27.3825 -0.5611
%sol = lsqnonlin(@(x)fun(x(1),x(2),x(3)),[18 0 -1],[],[],options)
fun(sol(1),sol(2),sol(3))
ans = 3×1
1.0e+03 * 5.1207 1.2857 -5.8480
  1 Commento
Torsten
Torsten il 27 Lug 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.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by