Simplifying symbolic expression to get real of real function in it.

9 ビュー (過去 30 日間)
Smile Guleria
Smile Guleria 2024 年 12 月 28 日
回答済み: Walter Roberson 2024 年 12 月 28 日
I m having a complicated symbolic expression which consists of real function with a complex symbolic expression as an argument to it. I want to simplify this complicated symbolic expression so that i get an expression which does not have real function in it.
How do i do it?
  1 件のコメント
Torsten
Torsten 2024 年 12 月 28 日
Please give an example - or even better: post your code.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2024 年 12 月 28 日
syms x
(x^3 + x)/x^2 + 5
ans = 
real(ans)
ans = 
You can see that if you have a real() call then the Symbolic Toolbox already automatically picks out the portions that are certain to be real and moves them outside the real() call.
If you have a real() call that is not simplifying the expression, then either the expression contains calls to unknown functions
syms F(x)
real(F(x) + 5)
ans = 
or else the expression is in complex variables.
When you syms a variable, by default the variable is assumed to be complex, unless you add the real flag to the syms call
syms x real
or else you use assume or assumeAlso to explicitly mark the variable as real, or to add an assertion that implies the variable is real
syms y
assume(y > 0)
real(y + 5)
ans = 
Here, the assumption of >0 can only be satisfied if y is real, so you get y is real "for free"

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by