Solve Three non-linear equations for 3 variables system

조회 수: 5 (최근 30일)
Deema Khunda
Deema Khunda 2022년 7월 27일
댓글: Torsten 2022년 7월 27일
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

채택된 답변

Walter Roberson
Walter Roberson 2022년 7월 27일
편집: Walter Roberson 2022년 7월 27일
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}

추가 답변 (2개)

Harshit Gupta
Harshit Gupta 2022년 7월 27일
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 2022년 7월 27일
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
Torsten
Torsten 2022년 7월 27일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Quadratic Programming and Cone Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by