How can I simplify the symbolic expressions?

2 ビュー (過去 30 日間)
Ali Almakhmari
Ali Almakhmari 2023 年 9 月 11 日
編集済み: Ali Almakhmari 2023 年 9 月 11 日
I hate the fact that solve keeps outputting symbolic expressions with extremely large numbers, when clearly it can simplify further and get rid of those numbers. How can I force it to do that? Its okay with me if I can get an approximation up 6 decimal places.
clear
clc
syms q_bar delta_o theta1 theta2 q S CL_alpha CL_delta b e KT
eqn1 = (2*theta1 - theta2 - q_bar.*theta1 + q_bar.*theta2) == (-0.4805020381.*q_bar.*delta_o);
eqn2 = (-theta1 + theta2 - 2.*q_bar.*theta2) == (-0.0051005137.*q_bar.*delta_o);
sol = solve(eqn1,eqn2,theta1,theta2);
L1 = q.*S.*CL_alpha.*sol.theta1;
L2 = q.*S.*CL_alpha.*sol.theta2 + q.*S.*CL_delta.*delta_o;
eqn1 = (0.25.*L1.*b + 0.75.*L2.*b) == 0;
a=solve(eqn1,q_bar)
a = 
  1 件のコメント
Torsten
Torsten 2023 年 9 月 11 日
If you need 6 decimal places, why do you supply model parameters with 10 decimal places ?
-0.4805020381*q_bar
-0.0051005137*q_bar

サインインしてコメントする。

採用された回答

John D'Errico
John D'Errico 2023 年 9 月 11 日
編集済み: John D'Errico 2023 年 9 月 11 日
clear
clc
syms q_bar delta_o theta1 theta2 q S CL_alpha CL_delta b e KT
eqn1 = (2*theta1 - theta2 - q_bar.*theta1 + q_bar.*theta2) == (-0.4805020381.*q_bar.*delta_o);
eqn2 = (-theta1 + theta2 - 2.*q_bar.*theta2) == (-0.0051005137.*q_bar.*delta_o);
sol = solve(eqn1,eqn2,theta1,theta2);
L1 = q.*S.*CL_alpha.*sol.theta1;
L2 = q.*S.*CL_alpha.*sol.theta2 + q.*S.*CL_delta.*delta_o;
eqn1 = (0.25.*L1.*b + 0.75.*L2.*b) == 0;
a=solve(eqn1,q_bar)
a = 
They are simple already. At least, as simple as they can be. You have unknowns in there, inside and outside of the square roots. I suppose you could play around, and make it different, but simpify will not find anything glaring to reduce there.
Can you make the numbers smaller? Well, yes, you can force VPA to round them.
vpa(a,10)
ans = 
Is that simpler? I guess.
  1 件のコメント
Ali Almakhmari
Ali Almakhmari 2023 年 9 月 11 日
編集済み: Ali Almakhmari 2023 年 9 月 11 日
Not really. I mean, you can take 5.642719936e17 in common from numerator and denominator and have everything simplify to have all numbers between 0.1 to 10 instead of so complicated like that with high numbers.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by