Solve Three non-linear equations for 3 variables system
7 次查看(过去 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 中查找有关 Numbers and Precision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!