How to solve ODE y'' - 4y' + y - x = 0 using rk4?

44 views
Skip to first unread message

jmarcell...@ufpi.edu.br

unread,
Sep 5, 2016, 9:33:17 PM9/5/16
to sage-support
How to solve ODE y'' - 4y' + y - x = 0 using rk4? :(

David Joyner

unread,
Sep 6, 2016, 5:37:18 AM9/6/16
to SAGE support
On Mon, Sep 5, 2016 at 9:33 PM, <jmarcell...@ufpi.edu.br> wrote:
> How to solve ODE y'' - 4y' + y - x = 0 using rk4? :(
>

http://doc.sagemath.org/html/en/reference/calculus/sage/calculus/desolvers.html
lists dsolve_rk4.
Was there a specific problem you encountered?

> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

jmarcell...@ufpi.edu.br

unread,
Sep 6, 2016, 8:43:43 AM9/6/16
to sage-support
I could not define a way to insert the arguments in RK4 command :(

jmarcell...@ufpi.edu.br

unread,
Sep 6, 2016, 11:38:22 AM9/6/16
to sage-support
I tryed

# w = y''
# z = y'

var('x, w, z')

desolve_system_rk4( [w , 4*z + x] , [w,z] , ics = [0,1,0], ivar = x, end_points = 10, step = 0.1)

But does no work correty :(

jmarcell...@ufpi.edu.br

unread,
Sep 6, 2016, 5:16:58 PM9/6/16
to sage-support
I got a way to solve the differential equation. If wrong please correct;)

To solve this differential equation we must first make a variable substitution to reduce the differential equation for a first order and thus create a system of ODEs. variable change:

w1 = y
w2 = y
w3 = y '

Thus, deriving the above variables, we have a system of equations of the form:

w1 '= w2
w2 '= f (x, w1, w2) = 4 * w2 + x

desolve_system_rk4([w2, 4*w2 + x ],[w1 , w2], ics = [0,1,0],ivar = x, step = 0.1, end_points = 2)
Reply all
Reply to author
Forward
0 new messages