cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

SOLVED
Guest

How to solve an ode like this in Mathcad?

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to solve an ode like this in Mathcad?

 zhu laojianke wrote:I use the nth_root(), but the graph what I have got is not like you've pasted there...

This is possibly because you used a different numeric algorithm. Right click on the word odesolve and look what you have chosen. Usually "Adams/BDF" or Adaptive are a good choice. I guess you have chosen "Fixed".

BTW, here is another way to force real values for any root. It depends on the underlying problem if any of these workarounds make sense!

You can also try to increase accuracy by setting TOL to a value lower than the default 10^-3.

9 REPLIES 9

Re: How to solve an ode like this in Mathcad?

The problem is the definition of a^(1/3) of being the complex solution of the equation x=a^3 which has the smallest argument.

While 8^(1/3) is 2 (agrument = 0) we do NOT get (-8)^(1/3)=-2 (argument = pi) but a complex value with magnitude 2 and argument pi/3.

So whenever y(x) gets neagtive your calculations returns a non-real value and odesolve fails.

Resist from writing |y(x)|^(1/3) as this will work (its even faster), but give you a wrong result (see attachment).

Fortunately there is a compromise built into Mathcad. The root symbol defaults to the real value and that solves your problem (calculation time is significantly higher - not sure why).

Re: How to solve an ode like this in Mathcad?

Thank you werner, your method really work well.

But when I change the power from 1/3 to 1/2, even use sqrt(), it still won't work...

It seems when the root number of y(x) is even, the solve block will say "This value must be a real number".

Re: How to solve an ode like this in Mathcad?

The square root of a negative y(x) is of course non-real - regardless of how you write it.

Re: How to solve an ode like this in Mathcad?

 zhu laojianke wrote:Thank you werner, your method really work well. But when I change the power from 1/3 to 1/2, even use sqrt(), it still won't work...

Odesolve won' work in domain complex so you will either have to reformualte your equation or you have to decide what REAL value you want to be returned for the square root if y(x) is negative and then define your own nth-root function. The result may not be a valid solution of your underlying problem, though.

If you use the following approach for a third root, odesolve will not find a solution at all (while using the built-in third root, which returns negative reals for negative arguments, does).

y(10) obviously is not 0, as demanded and y'(10) sure is not zero either.

So a main question is: Are you sure that a valid solution exist to the problem?

Re: How to solve an ode like this in Mathcad?

OK! I got it. The root of y(x) (whether positive or negative) must could be real, then the ode solve block can do his job.

Re: How to solve an ode like this in Mathcad?

I am not sure. This question is what my friend asked me. I can't solve it too, then show it here.

I will discuss this solution with him. Your method has given me great inspiration.

Re: How to solve an ode like this in Mathcad?

I use the nth_root(), but the graph what I have got is not like you've pasted there...

Re: How to solve an ode like this in Mathcad?

 zhu laojianke wrote:I use the nth_root(), but the graph what I have got is not like you've pasted there...

This is possibly because you used a different numeric algorithm. Right click on the word odesolve and look what you have chosen. Usually "Adams/BDF" or Adaptive are a good choice. I guess you have chosen "Fixed".

BTW, here is another way to force real values for any root. It depends on the underlying problem if any of these workarounds make sense!

You can also try to increase accuracy by setting TOL to a value lower than the default 10^-3.

Re: How to solve an ode like this in Mathcad?

It seems there are many methods to solve an ode, and how to choose the appropriate one is really a matter.

Announcements