352 - Topic 00 - Beginnings

35 days ago by Professor352

John Travis

Mississippi College

# Using Sage to check a nice example by starting with the answer and differentiating # Let's use the original de: y' = x*y var('x,y') f = x*y # r =2.5 # f = 0.5*r-5*y-y*r/2 pretty_print("This is the DE: y' = %s"%str(f)) Y = function('Y')(x) DE = diff(Y, x) - x*Y # Notice that we have put this in the form y' - f = 0 # DE = diff(Y, x) - (0.5*r-5*Y-Y*r/2) # Notice that we have put this in the form y' - f = 0 soln = desolve( DE, Y) # So this is the answer we are looking for pretty_print("and this is the solution y(x) = ",soln) # So, we take the derivative of this answer and plug back into the DE and simplify solnp = diff(soln,x) yprime_minus_f = solnp - x*soln show("So, y' - f = ",solnp," - x",soln,"=",yprime_minus_f) 
       

                                
                            

                                
S = solve(soln==0.04,x,soln_dict=true) S[1] 
       
x == 4*log(1/4*5^(1/25)*4^(24/25)*e^(4/25*I*pi))
x == 4*log(1/4*5^(1/25)*4^(24/25)*e^(4/25*I*pi))
# Using Sage to check another nice example by starting with the answer and differentiating # Let's use the original de: x y' + 2 y = sin(x) pretty_print("This is the DE: x y' + 2 y = sin(x)") y = function('y')(x) DE = diff(y, x) - (sin(x)/x - 2*y/x) # Notice that we have put this in the form y' - f = 0 soln = desolve( DE, y ) # So this is the answer we are looking for pretty_print("and this is the solution y(x) = ",soln) # So, we take the derivative of this answer and plug back into the DE and simplify solnp = diff(soln,x) yprime_minus_f = x*solnp + 2*soln - sin(x) show("So, y' - f = ",yprime_minus_f,"=",yprime_minus_f.simplify_full()) 
       

                                
                            

                                
# How about using a second order DE # Let's use the original de: y" + 3 y' + 2y = f f = x pretty_print("This is the DE: y'' + 3 y' + 2y = %s"%str(f)) y = function('y')(x) DE = diff(y,x,2) + 3*diff(y,x,1) + 2*y - f # Notice that we have put this in the form y' - f = 0 soln = desolve( DE, y ) # So this is the answer we are looking for pretty_print("and this is the solution y(x) = ",soln) # So, we take the derivative of this answer and plug back into the DE and simplify solnp = diff(soln,x,1) solnpp = diff(soln,x,2) yprime_minus_f = solnpp+3*solnp+2*soln - f show("So, y' - f = ",yprime_minus_f,"=",yprime_minus_f.simplify_full()) 
       

                                
                            

                                
# Just in case you need to do partial fractions for some reason. var('x') f = (3*x-17)/((97*x-x^3)*(1+x^2)) f.show() f.partial_fraction().show()