0

Here is the equation in WolframAlpha returning me the correct answer.

In MATLAB, I've written the following:

mu = 305; %as a temporary example since it's greater than c, which is 300

syms x
eqn = ((1 + (x/(mu + 300)))^((1/2) + (150/mu)))*((1 - (x/(mu - 300)))^((1/2) - (150/mu))) - 0.2 == 0 %matlab shows the answer is -605
solve(eqn,x)

It's the same equation, except MATLAB substitutes for mu for me. MATLAB is returning the following:

eqn = logical 0
ans = x

Am I typing the equation in wrong somehow? Is that why it's showing me a logical zero when I'm not suppressing the equation? How do I get it to result in the same values as WolframAlpha?

I also want to note that Maple seems to hang on this same equation as well.

TheTreeMan
  • 913
  • 8
  • 23
  • 38

1 Answers1

0

Unless you have a specific reason for using symbolic expressions, you can solve the equation that you have using fsolve as follows:

%Define your value of mu
mu = 305;
% Define the equation as an anonymous function
fn = @(x) ((1 + (x/(mu + 300)))^((1/2) + (150/mu)))*((1 - (x/(mu - 300)))^((1/2) - (150/mu))) - 0.2;
% Define the initial value for x so that fsolve can find the root nearest to that
x0 = 1;
root_x = fsolve(fn, x0);

This leads to the output root_x = 5.0000 + 0.0000i You can also change the initial value of x0

x0 = 400;
root_x = fsolve(fn, x0);

This will return the output root_x = -4.9005e+02 - 2.6326e-05i

This method can be used to solve any of the equations that you might have.

Community
  • 1
  • 1
ammportal
  • 991
  • 1
  • 11
  • 27