필터 지우기
필터 지우기

Find conditions such that symbolic expression is real-valued

조회 수: 3 (최근 30일)
I have a set of symbolic expressions of several variables, and I want Matlab to find the conditions on the variables such that the expressions meet certain criteria, such as being real-valued or one expression being less than another. For example,
syms a b c x;
x = solve(a*x^2 + b*x + c == 0,x)
returns the familiar quadratic formula as a vector:
x =
-(b + (b^2 - 4*a*c)^(1/2))/(2*a)
-(b - (b^2 - 4*a*c)^(1/2))/(2*a)
For these two solutions for x, I'd like to know: (a) the conditions on a, b, and c such that x is real-valued (obviously b^2 > 4*a*c for this example); (b) the conditions on a, b, and c such that x(1) > x(2).
If it helps, I know that all my symbolic variables (a, b, and c in the example) are positive-valued. Also, I'm only interested in positive values of x.
Thanks, Rich
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 6월 12일
For the quadratic, x(2) >= x(1) provided that both are real-valued. (If they have imaginary components then comparing them is not well defined.)

댓글을 달려면 로그인하십시오.

채택된 답변

Stefan Wehmeier
Stefan Wehmeier 2012년 6월 26일
a)
feval(symengine, 'solve', a*x^2 + b*x + c, x, 'Real', 'IgnoreSpecialCases')
You may omit the IgnoreSpecialCases, which shows you that a<>0 must also be satisfied (obviously).
b) It is better to solve for only one variable:
feval(symengine, 'solve', x(1) > x(2), a, 'Real')
You haven't declared your syms to be real, but the real mode in the solver treats them as reals which I think is what you want.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Properties and Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by