\documentclass{article}
\usepackage{ifxetex,ifluatex}
\newif\ifxetexorluatex
\ifxetex
\xetexorluatextrue
\else
\ifluatex
\xetexorluatextrue
\else
\xetexorluatexfalse
\fi
\fi
\ifxetexorluatex
\usepackage{fontspec}
\else
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\fi
\usepackage{csquotes}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lhead{Saraí Pérez}
\rhead{MAT4109/EDG1109}
\rfoot{Page \thepage/14}
\usepackage{hyperref}
\title{UNIVERSIDAD DE EL SALVADOR\\
Facultad de Ciencias Naturales y Matemática\\
$\ $\\
Escuela de Física\\
$\ $\\
Course Project MAT4109/EDG1109 $-$ 2018\\
$\ $}
\author{Instructor: M.Sc. Carlos Gámez\\
$\ $\\
Br. Jennifer Saraí Castellón Pérez \ \ \ CP12071}
\date{November 22, 2018}
\begin{document}
\maketitle
\newpage
\tableofcontents
\section{PROBLEM 01}
\label{Solucion de problema 1}
\%md\\
{\color{blue} \#\# Problem 1\\
\#\#\# Solve the following diferential equation:}\\
$(D-2)^3 (D^2 +9)y=x^2 e^x + x\sin{(3x)}$\\
{\color{blue} \#\#\# subject to the initial conditions given:}\\
$y(0)=y'(0)=y"(0)=y^(3)*(0)=y^(4)*(0)=1$
\begin{figure}[!ht]
\includegraphics[width=1.12\textwidth]{p110}
\end{figure}
{\color{blue} \# Let us first find the characteristic equation and solve it:}
\begin{verbatim}
var('r')
solve([(r-2)^3*(r^2 + 9)== 0],r)
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.8\textwidth]{p12}
\end{figure}
{\color{blue} \#Among the roots from the characteristic equations that were found, there is one with multiplicity 3 and this one will be used to find the complementary solution. Let's start with the particular one:}\\
$\ $\\
{\color{blue} \#We have multiplied everything times x to take out the duplicity}
\begin{verbatim}
var ('x,A,B,C,D,E,F,G')
yp=(A+B*x+C*x^2)*exp(x)+(D*x+E*x^2)*cos(3*x)+(F*x+G*x^2)*sin(3*x)
show(yp)
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=1.0\textwidth]{p131}
\end{figure}
{\color{blue}\#Now, we will substitute the previous equation into the original differential equation:}
\begin{verbatim}
rem0= diff(yp,x,2)+9*yp
rem1= diff(rem0,x)-2*rem0
rem2= diff(rem1,x)-2*rem1
rem3= diff(rem2,x)-2*rem2
remfinal= rem3-x^2*exp(x)-x*sin(3*x)
show(remfinal)
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=1.0\textwidth]{p141}
\end{figure}
{\color{blue}\#Now, we will find the coefficients of the previous equation}
\begin{verbatim}
coeffEx=remfinal.coefficient(exp(x))
coeffCos=remfinal.coefficient(cos(3*x))
coeffSin=remfinal.coefficient(sin(3*x))
\end{verbatim}
{\color{blue}\#We will use the command Solve to find the coefficients A, B, C}
\begin{verbatim}
solve([coeffEx.coefficient(x,0)==0,coeffEx.coefficient(x,1)==0,
coeffEx.coefficient(x,2)==0],A,B,C)
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.8\textwidth]{p15}
\end{figure}
{\color{blue}\#And now, we will find the remaining coefficients of the problem, which are the coefficients D, E, F, G}
\begin{verbatim}
solve ([coeffCos.coefficient(x,0)==0,coeffCos.coefficient(x,1)==0,
coeffSin.coefficient(x,0)==0,coeffSin.coefficient(x,1)==0],D,E,F,G)
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=1.0\textwidth]{p16}
\end{figure}
{\color{blue}\#In short, the values of the coefficients found are the following ones:}
\begin{verbatim}
A=-267/250; B=-14/25; C=-1/10; D=-251/114244; E=-23/13182;
F=1379/514098; G=-3/8788;
\end{verbatim}
{\color{blue}\#We are now finally able to find the complementary solution as follows:}
\begin{verbatim}
var ('c1,c2,c3,c4,c5')
yc=c1*exp(2*x)+c2 *x*exp(2*x)+c3*x^2*exp(2*x)+c4*cos(3*x)+c5*sin(3*x)
+(A+B*x+C*x^2)*exp(x)+(D*x+E*x^2)*cos(3*x)+(F*x+G*x^2)*sin(3*x)
show(yc)
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.9\textwidth]{p171}
\end{figure}
{\color{blue}\#Solving for the coeffients c1, c2, c3, c4, c5 we find:}
\begin{verbatim}
solve([yc.substitute(x=0)==1,diff(yc,x).substitute(x=0)==1,
diff(yc,x,2).substitute(x=0)==1,diff(yc,x,3).substitute(x=0)==1,
diff(yc,x,4).substitute(x=0)==1],c1,c2,c3,c4,c5
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=1.0\textwidth]{P181}
\end{figure}
{\color{blue}\#In short, the values of the coefficients c1, c2, c3, c4, c5 are:}
\begin{verbatim}
c1 =774782/371293; c2 = -43330/28561; c3 =1020/2197;
c4= -1737019/92823250; c5 = -4850123/556939500
\end{verbatim}
{\color{blue}\#And my complete solution (complementary and particular)for the differential equation with the initial conditions given, is::}
\begin{verbatim}
yc=c1*exp(2*x)+c2*x*exp(2*x)+c3*x^2*exp(2*x)+c4*cos(3*x)
+c5*sin(3*x)+(A+B*x+C*x^2)*exp(x)+(D*x+E*x^2)*cos(3*x)
+(F*x+G*x^2)*sin(3*x)
show ( yc )
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=1.0\textwidth]{p19}
\end{figure}
{\color{red} The previous equation solves the differential equation with initial conditions given in PROBLEM 01}
\newpage
\section{PROBLEM 02}
\label{Solucion del problema 2}
\%md\\
{\color{blue}\#PROBLEM 2\\
\#\#\# POWER SERIES:\\
\#\#\# Find the firs 6 nonzero terms in each of two linearly\\
\#\#\# independent solutions of the form $\sum{c_nx^n} $, for\\
\#\#\# the following differential equation:\\
\#\#\# $ xy''+(sin x)y'+xy=0$}\\
\begin{figure}[!ht]
\includegraphics[width=0.8\textwidth]{p210}
\end{figure}
{\color{blue}\# Lets start by generating a sum with 12 terms using Sage Worksheet}
\begin{verbatim}
reset()
n=12
a=list(var('a
x=var('x')
y=function('y')(x)
var('a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11')
a0=0
a1=1
y(x)=a0+a1*x+a2*x^2+a3*x^3+a4*x^4+a5*x^5+a6*x^6
+a7*x^7+a8*x^8+a9*x^9+a10*x^10+a11*x^11
show(y(x))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.9\textwidth]{p22}
\end{figure}
\pagebreak
{\color{blue}\# Expanding the sine function using the Mclaurin polynomial to substitute it in the differential equation.}
\begin{verbatim}
sinX=taylor(sin(x),x,0,12)
show (sinX)
a0=0
a1=1
eq = expand (x*diff(y,x,2)+sinX*diff(y,x,1)+x*y(x)==0)
\end{verbatim}
{\color{blue}\#Substituting the expansion in the differential equation given.}
\begin{verbatim}
show(eq)
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=1.2\textwidth]{p23}
\end{figure}
{\color{blue}\#grouping the coefficients of x and solving the system
to find a2 we have :}
\begin{verbatim}
solve ([eq.lhs().coefficient(x,1)==0],a2)
show (solve([eq.lhs().coefficient(x,1)==0],a2))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.6\textwidth]{p24}
\end{figure}
{\color{blue}\#performing this process recursively to find the other coefficients of our series we have:}
\begin{verbatim}
show (solve([eq.lhs().coefficient(x,2).substitute(a2=-1/2)==0],a3))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.4\textwidth]{p25}
\end{figure}
\begin{verbatim}
show (solve([eq.lhs().coefficient(x,3).substitute(a2=-1/2,a3=0)==0],a4))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.4\textwidth]{p26}
\end{figure}
\begin{verbatim}
show (solve([eq.lhs().coefficient(x,4).substitute(a2=-1/2,a3=0,
a4=1/18)==0],a5))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.4\textwidth]{p27}
\end{figure}
\begin{verbatim}
show (solve([eq.lhs().coefficient(x,5).substitute(a2=-1/2,a3=0,
a4=1/18,a5=-7/360)==0],a6))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.4\textwidth]{p28}
\end{figure}
\pagebreak
\begin{verbatim}
show (solve([eq.lhs().coefficient(x,6).substitute(a2=-1/2,a3=0,
a4=1/18,a5=-7/360,a6=1/900)==0],a7))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p29}
\end{figure}
\begin{verbatim}
show (solve([eq.lhs().coefficient(x,7).substitute(a2=-1/2,a3=0,
a4=1/18,a5=-7/360,a6=1/900,a7=157/113400)==0],a8))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p230}
\end{figure}
\begin{verbatim}
show (solve([eq.lhs().coefficient(x,8).substitute(a2=-1/2,a3=0,
a4=1/18,a5=-7/360,a6=1/900,a7=157/113400,a8=-19/39690)==0],a9))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p231}
\end{figure}
\begin{verbatim}
show (solve([eq.lhs().coefficient(x,9).substitute(a2=-1/2,a3=0,
a4=1/18,a5=-7/360,a6=1/900,a7=157/113400,a8=-19/39690,
a9=797/38102400)==0],a10))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.6\textwidth]{p232}
\end{figure}
\begin{verbatim}
show (solve([eq.lhs().coefficient(x,10).substitute(a2=-1/2,a3=0,
a4=1/18,a5=-7/360,a6=1/900,a7=157/113400,a8=-19/39690,
a9=797/38102400,a10=923/30618000)==0],a11))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.55\textwidth]{p233}
\end{figure}
\pagebreak
{\color{blue}\#Now that we have calculated the coefficients we can calculate our first solution.}
\begin{verbatim}
y1 (x)=0+1*x+(-1/2)*x^2+(0)*x^3+(1/18)*x^4+(-7/360)*x^5+(1/900)*x^6
+(157/113400)*x^7+(-19/39690)*x^8+(797/38102400)*x^9
+(923/30618000)*x^10+(-415519/47151720000)*x^11
show (y1(x))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.9\textwidth]{p234}
\end{figure}
{\color{red}The previous equation is our first solution for the differential equation}
\newpage
{\color{blue}\#Now we do the analogous process for our second linearly independent solution}\\
{\color{blue}\#And we star by generating a sum with the terms\underline{}\underline{}.}
\begin{verbatim}
reset ()
n=12
a= list (var('a
x=var('x')
y=function('y')(x)
var('a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11')
a0=1
a1=0
y(x)=a0+a1*x+a2*x^2+a3*x^3+a4*x^4+a5*x^5+a6*x^6+a7*x^7+a8*x^8
+a9*x^9+a10*x^10+a11*x^11
show(y(x))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=1.1\textwidth]{p235}
\end{figure}
{\color{blue}\#expanding the sine function using the Mclaurin polynomial to use it in the differential equation}
\begin{verbatim}
senoX=taylor(sin(x),x,0,12)
show (senoX)
a0=1
a1=0
eq = expand (x*diff(y,x,2)+senoX*diff(y,x,1)+x*y(x)==0)
\end{verbatim}
{\color{blue}\# Substituting the expansion in the differential equation given}
\pagebreak
\begin{verbatim}
show(eq)
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=1.11\textwidth]{p236}
\end{figure}
{\color{blue}\# Again, grouping the coefficients of x and solving the system to find a2 we have:}
\begin{verbatim}
solve([eq.lhs().coefficient(x,1)==0],a2)
show(solve([eq.lhs().coefficient(x,1)==0],a2))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.7\textwidth]{p237}
\end{figure}
{\color{blue}\# We now perform this process recursively to find the others coefficients of our series.}
\begin{verbatim}
show(solve([eq.lhs().coefficient(x,2).substitute(a2=-1/2)==0],a3))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p238}
\end{figure}
\pagebreak
\begin{verbatim}
show(solve([eq.lhs().coefficient(x,3).substitute(a2=-1/2,a3=1/6)==0],a4))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p239}
\end{figure}
\begin{verbatim}
show(solve([eq.lhs().coefficient(x,4).substitute(a2=-1/2,a3=1/6, a4=0)==0],a5))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p240}
\end{figure}
\begin{verbatim}
show(solve([eq.lhs().coefficient(x,5).substitute(a2=-1/2,a3=1/6,
a4=0,a5=-1/60)==0],a6))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p241}
\end{figure}
\begin{verbatim}
show(solve([eq.lhs().coefficient(x,6).substitute(a2=-1/2,a3=1/6,
a4=0,a5=-1/60,a6=1/180)==0],a7))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p242}
\end{figure}
\begin{verbatim}
show(solve([eq.lhs().coefficient(x,7).substitute(a2=-1/2,a3=1/6,
a4=0,a5=-1/60,a6=1/180,a7=-1/5040)==0],a8))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p243}
\end{figure}
\begin{verbatim}
show(solve([eq.lhs().coefficient(x,8).substitute(a2=-1/2,a3 =1/6,
a4=0,a5=-1/60,a6=1/180,a7=-1/5040,a8=-1/2520)==0],a9))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p244}
\end{figure}
\newpage
\begin{verbatim}
show(solve([eq.lhs().coefficient(x,9).substitute(a2=-1/2,a3 =1/6,
a4=0,a5=-1/60,a6=1/180,a7=-1/5040,a8=-1/2520,a9=11/90720)==0],a10))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p245}
\end{figure}
\begin{verbatim}
show(solve([eq.lhs().coefficient(x,10).substitute(a2=-1/2,a3=1/6,
a4=0,a5=-1/60,a6=1/180,a7=-1/5040,a8=-1/2520,a9=11/90720,
a10=-1/680400)==0],a11))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=0.5\textwidth]{p246}
\end{figure}
{\color{blue}\# Now that have calculated the coeffients of our seconds solution}
\begin{verbatim}
y2(x)=1+0*x+(-1/2)*x^2+(1/6)*x^3+(0)*x^4+(-1/60)*x^5+(1/180)*x^6
+(-1/5040)*x^7+(-1/2520)*x^8+(11/90720)*x^9+(-1/680400)*x^10
+(-4957/598752000)*x^11
show(y2(x))
\end{verbatim}
\begin{figure}[!ht]
\includegraphics[width=1.11\textwidth]{p247}
\end{figure}
{\color{red}The previous equation is our second solution for the differential equation.}
\pagebreak
\section{CONCLUSIONS}
In our first problem we were able to solve a long initial value differential equation with the given initial conditions. This problem was succesfully solved by using characteristics equations and finding the appropiate values for the indeterminate coefficients. Our answer for the first problem is:
\begin{figure}[!ht]
\includegraphics[width=1.0\textwidth]{p19}
\end{figure}
For the second problem we were able to solve a differential equation using a power series expansion of the form $\sum c_nx^n$ and also by expanding the Mclaurin series of $\sin(x)$. In doing so we found two solutions that are linearly independent. \\
Our first solution for the second problem, at 12 terms in the expansion of the sum is:
\begin{figure}[!ht]
\includegraphics[width=0.9\textwidth]{p234}
\end{figure}
And the second solution for the second problem, at 12 terms in the expansion of the sum, is:
\begin{figure}[!ht]
\includegraphics[width=1.11\textwidth]{p247}
\end{figure}
Through the use of the Python lenguaje, we facilitate the calculation and procesing of the solution for very extensive and laborious equations that, otherwise done by hand, become really complicated to solve due to the overwhelming work required to approach to their solution. Also, editors such as Latex facilitate the process of editing reports, improving their appearance and style to conform to international publishing standards.\\
This project has enabled us to practice our differential equation solving skills that we learn from M.Sc. Carlos Gamez in the course of MAT4109/EDG1109 during the second semester of 2018. Such skills will be proved to be useful in the next mandatory courses of our carreer. We thanks our professor for his invaluable help and patience, as well as to our instructor Br. Joel for his help during mentoring.
\end{document}