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
- :
- ODE Solve issue

Options

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

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

Showing results for

12-02-2021
09:05 AM

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

12-02-2021
09:05 AM

ODE Solve issue

Hi all,

I am trying to figure out if it is (mathematically) possible to obtain a x(y) function via the following system with odesolve:

dx/dy=F(x)

Do you guys have a idea if it is possible in mathcad, and if so, how?

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

12-02-2021
09:47 AM

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

12-02-2021
09:47 AM

As x is your function and dependent on y, you have to always write x(y) and not just x!

And the initial condition can't be that of F but that of the function to solve for -> x(0)=...

After all, in your example F(0)=5 and not 4 🙂

The plots also show the exact symbolic solution of your ODE.

13 REPLIES 13

12-02-2021
09:10 AM

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

12-02-2021
09:10 AM

Give an example and post the initial worksheet please.

Here is an example done in MC15

If you use Prime keep in mind that solve blocks and the syntax for odesolve is different there.

12-02-2021
09:15 AM

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

12-02-2021
09:15 AM

So something like this. I want to plot x versus y, given the equations in the screenshot. (this is a simplified version of what i want to actually solve).

12-02-2021
09:47 AM

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

12-02-2021
09:47 AM

As x is your function and dependent on y, you have to always write x(y) and not just x!

And the initial condition can't be that of F but that of the function to solve for -> x(0)=...

After all, in your example F(0)=5 and not 4 🙂

The plots also show the exact symbolic solution of your ODE.

12-02-2021
10:17 AM

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

12-02-2021
10:17 AM

Allright, thank you for your response!

It is a relieving thought that such a system can be solved.

However, when I try to do it myself this error occurs:

Also I can't define F(x(y)) above the solve block, since prime doesn't allow me to add another bracket ((y)) between the F() bracket, is that the source of the error?

I see that you answer to allot of posts here, and I want to say thank you for that! I am sure that you helped so many people out (:

12-02-2021
12:56 PM

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

12-02-2021
12:56 PM

That you can't __define__ a function with another function as argument is OK an normal. Its absolutely OK to define F(x):=3x+5 in front of the solve block. The x there is just a formal arguement anyway and so you can later call the function with any actual argument you like, also a function like x(y). You may as well define F(oops):=3*oops+5, it doesn't make any difference 😉

The problem with your solve block seems to be that your function is named x and you state the derivative with respect to x. As your function x is dependent on y you should use the derivative wrt y -> d/dy...

Look at my screenshot in my previous answer to see the difference.

You had not told us which version of Prime you are using. Hope you can read the attached Prime 6 file.

P.S.: I am not sure why you assigned the odesolve result to variable z. If you like you sure can also use x instead.

12-03-2021
05:11 AM

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

12-03-2021
05:11 AM

I was just wondering what happens when in the F function, y is also a variable. So like in the example in the screenshot below:

Is mathcad able to solve that aswell?

12-03-2021
06:32 AM

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

12-03-2021
06:32 AM

Then your differential equation becomes:

(This is what you should set in the Constraints section, or you define:

and your Constraint becomes:

).

The solution to that equation, with:

is:

Proof:

You can (also) check this result with your result of odesolve..

Success!

Luc

12-03-2021
10:21 AM

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

12-03-2021
10:21 AM

Hi,

Thanks for your response and indeed it works for the example system I proposed.

However, when I try it on my own system, it doesn't work and it gives the following error:

I cannot figure I what goes wrong...

The Worksheet is attached.

Thanks for your help in advance!

12-03-2021
10:36 AM

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

12-03-2021
10:36 AM

I already solved it, sorry!

12-03-2021
11:13 AM

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

12-03-2021
11:13 AM

@TW_9638511 wrote:

I already solved it, sorry!

So you found out yourself despite of the misleading error message that you forgot the function arguments here

But even with that correction the system won't solve up to 400 because there seems to be a vertical asymptote around 61

Maybe some error in your model/equations?

BTW, why don't you take advantage of Primes capability to work with units?

12-03-2021
01:36 PM

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

12-03-2021
01:36 PM

Becomes very unstable for H.L values above 60:

Success!

Luc

12-03-2021
06:34 PM

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

12-03-2021
06:34 PM

Interesting! I can't go much further than 60.9568 without getting an unknown exception error.

The values you show at the end are much larger and in Prime we get no negative values.

The ripple in the left picture is because of the larger step width:

EDIT: Long time no see - now after a long while I once again experience the forum error

I have no idea why I could upload this pic of the error message but the picture from the Prime sheet still fails - both were made with the very same screenshot software using the same procedure ...

I'll post a follow up with the pic.

12-03-2021
06:40 PM

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

12-03-2021
06:40 PM

So here is the pic which I wasn't able to include in my last post: