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

조회 수: 1 (최근 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개)

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 CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by