How to use equation solver with conditions

1 次查看(过去 30 天)
syms x a r
x = isolate(-((2*(90 - x)^r - (2*x + 90)^r)*(a + 4)*(r - 1)==0,a)
Is it possible to ask matlab to solve the above equation setting as a condition that "a" is a positive number?
Ideally, I want matlab to return an equation rather than -4 as the solution.

采纳的回答

Star Strider
Star Strider 2019-1-16
Theoretically, yes:
syms x a r
assume(a > 0)
x = isolate(-((2*(90 - x)^r - (2*x + 90)^r)*(a + 4)*(r - 1))==0,a)
However,
Error using sym/isolate (line 108)
Unable to isolate 'a' because the equation has no solution.
Note that the equation you posted has an unmatched parenthesis. I added one to get this to work, so be sure all of them are in the correct places, and that you are not using more of them than you need to.

更多回答(1 个)

Walter Roberson
Walter Roberson 2019-1-16
No. Your equation has three terms multiplied together
-2*(90 - x)^r + (2*x + 90)^r
a + 4
r - 1
in order for the result to equal zero, one of the terms must equal 0. The only term that involves a is a+4 . In order for that to equal 0, a must be -4.
There are two solutions in r: r = 1 or r = -ln(2)/(ln(90 - x) - ln(2*x + 90)) neither of which involve a and so under the positivity constraint would be valid for all positive a other than x = 0 (as 0 gives a division by 0)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by