フィルターのクリア

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);
Warning: Unable to find explicit solution. For options, see help.

採用された回答

Walter Roberson
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)
partial_1 = 
eqn2 = subs(eqn(2:end), a1, partial_1)
eqn2 = 
partial_2 = solve(eqn2(1), a2)
partial_2 = 
sol_a2 = partial_2
sol_a2 = 
sol_a1 = subs(partial_1, a2, sol_a2)
sol_a1 = 
%cross-check
subs(eqn, {a1, a2}, {sol_a1, sol_a2})
ans = 
isAlways(ans)
ans = 1×2 logical array
1 1
%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])
sol_a1 = 
sol_a2 = 
simplify(sol_a1)
ans = 
simplify(sol_a2)
ans = 
  4 件のコメント
Michael Meyne
Michael Meyne 2023 年 11 月 5 日
I have a quick question, how do you get the solution to be printed with this formatting?
Walter Roberson
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
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)
SOLUTION = struct with fields:
r_1: exp(-((E*alpha)/2 + 8*pi*a2)/(E*alpha))*exp(wrightOmega(log(-(8*pi*a1)/(E*alpha)) + (E*alpha + 16*pi*a2)/(E*alpha))/2) r_2: exp(-((E*alpha)/2 + 8*pi*a2)/(E*alpha))*exp(wrightOmega(log(-(8*pi*a1)/(E*alpha)) + (E*alpha + 16*pi*a2)/(E*alpha))/2)
r_1 = SOLUTION.r_1
r_1 = 
r_2 = SOLUTION.r_2
r_2 = 
a3 = (alpha*E)/(8*pi)
a3 = 

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by