Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- How to solve an ode like this in Mathcad?

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
05:39 AM

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
04:15 PM

08-10-2014
04:15 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
10:04 AM

08-10-2014
10:04 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
10:46 AM

08-10-2014
10:46 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
10:54 AM

08-10-2014
10:54 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
11:13 AM

08-10-2014
11:13 AM

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?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
11:23 AM

08-10-2014
11:23 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
11:40 AM

08-10-2014
11:40 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
11:54 AM

08-10-2014
11:54 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-10-2014
04:15 PM

08-10-2014
04:15 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-11-2014
10:44 AM

08-11-2014
10:44 AM

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.