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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to solve numerically the following two, second order, ordinary differential equations?

-MFra-
21-Topaz II

How to solve numerically the following two, second order, ordinary differential equations?

Hello to all the most expert of Mathcad community,

I have this little problem:

determine the two functions y1 and y2, solutions of the following two differential equations, being known the initial conditions and  of continuity (the two functions, in reality, constitute the two arms of the same function but defined in two different and adjacent intervals. In the point common to the two intervals, it is required the continuity of the function (equality of the derivatives in b).

Thank you very much

F. M.

syseqdiff.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
Werner_E
24-Ruby V
(To:-MFra-)

While I still don't see why it should be necessary, here is a solution similar to what you had in mind.

I see no practical way to calculate both functions in a single solve block because Mathcad would choke on the different initial values. Maybe one could use "sbval" to find consistent initial value - I haven't tried as as long as y1 and y2 are independent (apart from forcing them to have the same function value and derivative at b) its easier to do with separate solve blocks.

As you can see I solved the problem with the numerical derivative by simply providing the derivative as parameter of the odesolve blocks and later ensures with a regular solve block that the function values match at b. As an alternative we could write our own derivative functions similar to how I checked that the derivates are equal at the end of the screen shot. Then we could do like I outlined above, making the function value at b the argument of the solve blocks.

Hope that the parametrization of the odesolve block works the same in Prime. Was too lazy to try.

Works quite well at least in MC15, but I see no reason why we should not use the first solution I posted.

View solution in original post

7 REPLIES 7
Werner_E
24-Ruby V
(To:-MFra-)

Mathcads abilities to solve ODEs (even just numerically) are very limited, but how about this?

Should work in Prime, too (the syntax for odesolve is a little different, though).

-MFra-
21-Topaz II
(To:Werner_E)

Very nice and simple solution (made with Mathcad 15, I suppose, what about Prime 3.1?). But the continuity in b, should be an explicit condition. In the way you indicated, it may happen that it is not verified for particular initial conditions.

(Applies to both responses).

Thank you

F.M.

Werner_E
24-Ruby V
(To:-MFra-)

F.M. wrote:

Very nice and simple solution (made with Mathcad 15, I suppose, what about Prime 3.1?).

Yes MC 15. As I had no urge to "upgrade" from P3 to P31, I can't read P31 files and had to retype what you did. And I see no reason why I should use Prime voluntarily. Maybe in 10 years Prime can compete with MC but sure not yet.

Any reason you are using Prime? Out of curiosity or maybe you intend to later use units with odesolve  - one of the few benefits of Prime.

But as I already wrote above, you should experience no difficulties to reproduce the very same in Prime as long as you consider the different odesolve syntax.

But the continuity in b, should be an explicit condition.

Given the way the numerical algorithms involved work I can't see a way to use the "end" value of one function as a starting point for the other using a single solve block.

Maybe you have luck using a parametrized solve block for y1 and  y2 where the parameter is the function value of both functions at b. Then you could use another ordinary solve block to fiund the function value at b which gives the dame derivative for both functions. But I see a problem as b is an endvalue either for both y1 and y2 or at least its the starting value for y2 and so you could run into problems calculating the numeric derivative at b for that function. But maybe you should give it a try if you think thats necessary.

In the way you indicated, it may happen that it is not verified for particular initial conditions.

Can you provide an example? Maybe I am missing the point, but a long as the given function y'' (f''(x) in my screenshot above) does not show a Dirac impulse at b, the integral functions would be continuous automatically the way I added them.

WE

Werner_E
24-Ruby V
(To:-MFra-)

While I still don't see why it should be necessary, here is a solution similar to what you had in mind.

I see no practical way to calculate both functions in a single solve block because Mathcad would choke on the different initial values. Maybe one could use "sbval" to find consistent initial value - I haven't tried as as long as y1 and y2 are independent (apart from forcing them to have the same function value and derivative at b) its easier to do with separate solve blocks.

As you can see I solved the problem with the numerical derivative by simply providing the derivative as parameter of the odesolve blocks and later ensures with a regular solve block that the function values match at b. As an alternative we could write our own derivative functions similar to how I checked that the derivates are equal at the end of the screen shot. Then we could do like I outlined above, making the function value at b the argument of the solve blocks.

Hope that the parametrization of the odesolve block works the same in Prime. Was too lazy to try.

Works quite well at least in MC15, but I see no reason why we should not use the first solution I posted.

-MFra-
21-Topaz II
(To:Werner_E)

Many Thanks for taking the time to my little problem. Everything is solved analytically. I wanted find a comparison by solving the problem with mathcad. Thanks again.

F.M.

Werner_E
24-Ruby V
(To:-MFra-)

Here's another approach using simple integration

Hi.

Following the integrals from Werner post, you can get the full symbolic solution for this problem.

Best regards.

Alvaro.

fig.gif

Top Tags