#Short script to illustrate using the "ode_solve" command in Sage to solve
#an ODE numerically.

#First define the function f(t,u) in the ODE u' = f(t,u). Here u is treated
#as a vector (u[0],u[1],...) so for a scalar ODE use u[0].
def f(t,u):
    return [t+u[0]] #This is for u' = u + t

T = ode_solver() #Set up data structure "T" for handling solution process

T.function = f #Define the right side of the ODE

T.ode_solve(y_0=[1],t_span=[0,1],num_points=10) #Call the solver. Initial condition u(0)=1 (must label "y0").

usol = T.interpolate_solution() #Set up a function "usol" to interpolate the solution

plot(usol,0,1).show() #Plot the solution

usol(0.5) #Evaluate the solution at a certain time