Solve Three non-linear equations for 3 variables system
조회 수: 5 (최근 30일)
이전 댓글 표시
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
채택된 답변
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)))))
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
추가 답변 (2개)
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)))))
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
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)]
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
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 Center 및 File 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!