cancel
Showing results for 
Search instead for 
Did you mean: 
Security Alert Log4j Security Vulnerability. Click here to know more.
cancel
Showing results for 
Search instead for 
Did you mean: 

ODE Solve issue

TW_9638511
4-Participant

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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 🙂

Werner_E_0-1638457199703.png

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

 

View solution in original post

13 REPLIES 13

Give an example and post the initial worksheet please.

 

Here is an example done in MC15

Werner_E_0-1638455031591.png

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

 

TW_9638511
4-Participant
(To:Werner_E)

TW_9638511_0-1638454493247.png

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

 

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 🙂

Werner_E_0-1638457199703.png

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

 

View solution in original post

TW_9638511
4-Participant
(To:Werner_E)

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:

TW_9638511_0-1638458112441.png

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 (: 

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.

 

TW_9638511
4-Participant
(To:Werner_E)

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:

TW_9638511_0-1638526283041.png

Is mathcad able to solve that aswell?

 

LucMeekes
23-Emerald I
(To:TW_9638511)

Then your differential equation becomes:

LucMeekes_0-1638530918974.png

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

LucMeekes_0-1638531975400.png

 

and your Constraint becomes:

LucMeekes_5-1638531503842.png

).

The solution to that equation, with:

LucMeekes_1-1638530963671.png

is:

LucMeekes_2-1638531060862.png

Proof:

LucMeekes_3-1638531331356.png

 

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

 

Success!

Luc

 

TW_9638511
4-Participant
(To:LucMeekes)

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:

 

TW_9638511_0-1638544788932.png

I cannot figure I what goes wrong...

The Worksheet is attached. 

 

Thanks for your help in advance!

 

TW_9638511
4-Participant
(To:TW_9638511)

I already solved it, sorry!


@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

Werner_E_0-1638547860721.png

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

Werner_E_3-1638548130345.png

Maybe some error in your model/equations?

 

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

LucMeekes
23-Emerald I
(To:TW_9638511)

Becomes very unstable for H.L values above 60:

LucMeekes_0-1638556569292.png

Success!
Luc

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

Werner_E_4-1638574583095.png

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.

 

 

Werner_E
24-Ruby IV
(To:Werner_E)

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

Werner_E_8-1638574809116.png

 

Announcements
Check out the latest
Mathcad Tip
"PTC Mathcad 15 / Prime 1-6 Update."