Is there a way to limit the "solve" function to converge only to a real solution (no imaginary or complex numbers)?

조회 수: 49 (최근 30일)
I am trying to solve a system of algebraic equations using the "solve" function in the symbolic toolbox. Since the equations describe a physical system only a real solution can be realistic (taking the real parts of the resulting complex numbers is not a solution). Is there a way to make the "solve" function converge to real numbers only?
Thank you in advance.

채택된 답변

Walter Roberson
Walter Roberson 2019년 4월 23일
No, there is not.
  • vpasolve() permits ranges to be specified for each value. vpasolve() will typically only find one solution
  • You can add additional equations that are inequalities, but it is common for solve() to give up almost immediately when the number of equations does not match the number of variables to be solved for. Also, when solve() does respect an inequality, it does not return a description of the ranges that are valid: instead it returns a representative value. For example if it figures out that 1/2 < x < 14 then it will return 1, and if it figures out that 2 < x < 14 then it returns pi
  • When you "syms" the variable or sym() it into existence, you can specify the real flag, such as syms x y real . These can help the computation a fair bit, but they can also lead to solve() missing valid answers . solve() is also permitted to ignore these kinds of assumptions
  • You can assume() and assumeAlso() to add assumptions that specify restrict ranges, such as assume(2 < x & x < 14) . These have the same disadvantages as the real flag, and as well it can lead to solve() spending a lot of time working on the value of the variable at the boundary conditions when the boundary conditions might be of lower priority than some other calculations.

추가 답변 (0개)

카테고리

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