Trying to Solve system of 2 Equations "Unable to find explicit solution" Code In Description
1 次查看(过去 30 天)
显示 更早的评论
Code pasted below, thanks in advance:
clear all;
close all;
clc;
% Solve System of Equations
syms a1 a2 a3 r_1 r_2 alpha E
a3 = (alpha*E)/(8*pi);
[sol_a1, sol_a2] = solve(2*a3*log(r_1) + (a1/(r_1)^2) + a3 + 2*a2 == 0,...
2*a3*log(r_2) + (a1/(r_2)^2) + a3 + 2*a2 == 0);
0 个评论
采纳的回答
Walter Roberson
2023-11-4
syms a1 a2 a3 r_1 r_2 alpha E
a3 = (alpha*E)/(8*pi);
eqn = [2*a3*log(r_1) + (a1/(r_1)^2) + a3 + 2*a2 == 0,...
2*a3*log(r_2) + (a1/(r_2)^2) + a3 + 2*a2 == 0];
partial_1 = solve(eqn(1), a1)
eqn2 = subs(eqn(2:end), a1, partial_1)
partial_2 = solve(eqn2(1), a2)
sol_a2 = partial_2
sol_a1 = subs(partial_1, a2, sol_a2)
%cross-check
subs(eqn, {a1, a2}, {sol_a1, sol_a2})
isAlways(ans)
%or... more directly...
syms a1 a2 a3 r_1 r_2 alpha E
a3 = (alpha*E)/(8*pi);
[sol_a1, sol_a2] = solve(2*a3*log(r_1) + (a1/(r_1)^2) + a3 + 2*a2 == 0,...
2*a3*log(r_2) + (a1/(r_2)^2) + a3 + 2*a2 == 0, [a1, a2])
simplify(sol_a1)
simplify(sol_a2)
4 个评论
Walter Roberson
2023-11-6
When you have a sym() or symfun() or symmatrix() expression, then that sort of formatting happens automatically if you are using LiveScript or MATLAB Online or MATLAB Answers. It does not happen if you are using the traditional command window (and there is no way to turn it on for the command window)
更多回答(1 个)
Sulaymon Eshkabilov
2023-11-4
编辑:Sulaymon Eshkabilov
2023-11-4
Note that you have six unknowns (a1, a2, r_1, r_2, alpha, E) an two equations. It is possible to get two solution type expressions using IgnoreAnalyticalConstraints option, e.g.:
syms a1 a2 r_1 r_2 alpha E
a3 = (alpha*E)/(8*pi);
SOLUTION = solve(2*a3*log(r_1) + (a1/(r_1)^2) + a3 + 2*a2 == 0,...
2*a3*log(r_2) + (a1/(r_2)^2) + a3 + 2*a2 == 0, "IgnoreAnalyticConstraints",true)
r_1 = SOLUTION.r_1
r_2 = SOLUTION.r_2
a3 = (alpha*E)/(8*pi)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!