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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

How to solve an ode like this in Mathcad?

zhulaojianke
2-Guest

How to solve an ode like this in Mathcad?

2014-08-10_173638.jpg

2014-08-10_173655.jpg

1 ACCEPTED SOLUTION

Accepted Solutions

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.

1.png

View solution in original post

9 REPLIES 9

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).

1.png

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...

2014-08-10_223802.jpg

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

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

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.

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).

1.png

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?

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.

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

2014-08-10_235150.jpg

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.

1.png

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

Top Tags