0

I am experiencing a weird error in Matlab that is not prone to being solved with internet research, and it comes up when trying to solve the following equation for the variable, S:

-(W-S)^(y-1) + d*p*(1+f+w1*(r1-f))^y + d*(1-p)*(1+f+w1*(r2-f))^y == 0

The code I use is

syms W S y d p r1 r2 f positive
eqn = -(W-S)^(y-1) + d*p*(1+f+w1*(r1-f))^y + d*(1-p)*(1+f+w1*(r2-f))^y == 0
solve(eqn, S)

and the error, along with incorrect answer, that I get is

Warning: The solutions are parameterized by the symbols: k.
 To include parameters and conditions in the solution,
 specify the 'ReturnConditions' option. 
> In solve>warnIfParams (line 500)
  In solve (line 356) 
Warning: The solutions are valid under the following
conditions: 1 < y & in(k, 'integer') & k*pi < (pi/2 +
angle(d*p*(f - w1*(f - r1) + 1)^y - d*(p - 1)*(f - w1*(f -
r2) + 1)^y)/(2*(y - 1)))*(y - 1) & 0 < W - exp(-(k*pi*2i)/(y
- 1))*(-d*((p - 1)*(f - w1*(f - r2) + 1)^y - p*(f - w1*(f -
r1) + 1)^y))^(1/(y - 1)) & angle(d*p*(f - w1*(f - r1) + 1)^y
- d*(p - 1)*(f - w1*(f - r2) + 1)^y) <= 2*k*pi + pi*(y - 1) |
y < 1 & in(k, 'integer') & (pi/2 + angle(d*p*(f - w1*(f - r1)
+ 1)^y - d*(p - 1)*(f - w1*(f - r2) + 1)^y)/(2*(y - 1)))*(y -
1) < k*pi & 0 < W - exp(-(k*pi*2i)/(y - 1))*(-d*((p - 1)*(f -
w1*(f - r2) + 1)^y - p*(f - w1*(f - r1) + 1)^y))^(1/(y - 1))
& 2*k*pi + pi*(y - 1) <= angle(d*p*(f - w1*(f - r1) + 1)^y -
d*(p - 1)*(f - w1*(f - r2) + 1)^y).
 To include parameters and conditions in the solution,
 specify the 'ReturnConditions' option. 
> In solve>warnIfParams (line 507)
  In solve (line 356) 

ans =

W - exp(-(pi*k*2i)/(y - 1))*(d*p*(f - w1*(f - r1) + 1)^y - d*(p - 1)*(f - w1*(f - r2) + 1)^y)^(1/(y - 1))

Thing is, I can solve this by hand with no problem and get the answer, which even Wolfram Alpha agrees with, so I know Matlab or I are experiencing a hiccup somewhere:

Wolfram Can but Matlab can't?

Where am I going wrong in my code?

halfer
  • 19,824
  • 17
  • 99
  • 186
Coolio2654
  • 1,589
  • 3
  • 21
  • 46
  • So I tried to solve this using matlab 2016a and I ran into a forever loop with solve. For some reason it just wouldn't solve it. I never received the error, I had to crash the app after 1 hour of computations. – Hojo.Timberwolf Sep 20 '17 at 08:07
  • @Hojo.Timberwolf Any idea what could possibly be causing this? I wouldn't imagine Matlab is encountering the limit of its capabilities with just some complicated algebra, or is it? If it is, is Matlab known for not being able to answer such questions in general? – Coolio2654 Sep 20 '17 at 17:15

0 Answers0