Trying to Solve system of 2 Equations "Unable to find explicit solution" Code In Description
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Michael Meyne
il 4 Nov 2023
Commentato: Walter Roberson
il 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 Commenti
Risposta accettata
Walter Roberson
il 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 Commenti
Walter Roberson
il 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)
Più risposte (1)
Sulaymon Eshkabilov
il 4 Nov 2023
Modificato: Sulaymon Eshkabilov
il 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 Commenti
Vedere anche
Categorie
Scopri di più su Number Theory in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!