Trying to Solve system of 2 Equations "Unable to find explicit solution" Code In Description
1 view (last 30 days)
Show older comments
Michael Meyne
on 4 Nov 2023
Commented: Walter Roberson
on 6 Nov 2023
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 Comments
Accepted Answer
Walter Roberson
on 4 Nov 2023
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 Comments
Walter Roberson
on 6 Nov 2023
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)
More Answers (1)
Sulaymon Eshkabilov
on 4 Nov 2023
Edited: Sulaymon Eshkabilov
on 4 Nov 2023
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 Comments
See Also
Categories
Find more on Number Theory in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!