Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Course Project MAT4109/EDG1109

Project: Mate 4
Views: 10
1
\documentclass{article}
2
% set font encoding for PDFLaTeX, XeLaTeX, or LuaTeX
3
\usepackage{ifxetex,ifluatex}
4
\newif\ifxetexorluatex
5
\ifxetex
6
\xetexorluatextrue
7
\else
8
\ifluatex
9
\xetexorluatextrue
10
\else
11
\xetexorluatexfalse
12
\fi
13
\fi
14
15
\ifxetexorluatex
16
\usepackage{fontspec}
17
\else
18
\usepackage[T1]{fontenc}
19
\usepackage[utf8]{inputenc}
20
\usepackage{lmodern}
21
\fi
22
\usepackage{csquotes}
23
\usepackage{graphicx}
24
\usepackage{xcolor}
25
\usepackage{fancyhdr}
26
27
\pagestyle{fancy}
28
\fancyhf{}
29
\lhead{Saraí Pérez}
30
\rhead{MAT4109/EDG1109}
31
\rfoot{Page \thepage/14}
32
\usepackage{hyperref}
33
34
\title{UNIVERSIDAD DE EL SALVADOR\\
35
Facultad de Ciencias Naturales y Matemática\\
36
$\ $\\
37
Escuela de Física\\
38
$\ $\\
39
Course Project MAT4109/EDG1109 $-$ 2018\\
40
$\ $}
41
\author{Instructor: M.Sc. Carlos Gámez\\
42
$\ $\\
43
Br. Jennifer Saraí Castellón Pérez \ \ \ CP12071}
44
\date{November 22, 2018}
45
% Enable SageTeX to run SageMath code right inside this LaTeX file.
46
% http://mirrors.ctan.org/macros/latex/contrib/sagetex/sagetexpackage.pdf
47
% \usepackage{sagetex}
48
49
\begin{document}
50
\maketitle
51
\newpage
52
\tableofcontents
53
\section{PROBLEM 01}
54
\label{Solucion de problema 1}
55
56
\%md\\
57
{\color{blue} \#\# Problem 1\\
58
\#\#\# Solve the following diferential equation:}\\
59
60
$(D-2)^3 (D^2 +9)y=x^2 e^x + x\sin{(3x)}$\\
61
62
{\color{blue} \#\#\# subject to the initial conditions given:}\\
63
64
$y(0)=y'(0)=y"(0)=y^(3)*(0)=y^(4)*(0)=1$
65
66
\begin{figure}[!ht]
67
\includegraphics[width=1.12\textwidth]{p110}
68
\end{figure}
69
70
{\color{blue} \# Let us first find the characteristic equation and solve it:}
71
72
\begin{verbatim}
73
var('r')
74
solve([(r-2)^3*(r^2 + 9)== 0],r)
75
\end{verbatim}
76
77
\begin{figure}[!ht]
78
\includegraphics[width=0.8\textwidth]{p12}
79
\end{figure}
80
81
{\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:}\\
82
$\ $\\
83
{\color{blue} \#We have multiplied everything times x to take out the duplicity}
84
85
\begin{verbatim}
86
var ('x,A,B,C,D,E,F,G')
87
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)
88
show(yp)
89
\end{verbatim}
90
91
\begin{figure}[!ht]
92
\includegraphics[width=1.0\textwidth]{p131}
93
\end{figure}
94
95
{\color{blue}\#Now, we will substitute the previous equation into the original differential equation:}
96
97
\begin{verbatim}
98
rem0= diff(yp,x,2)+9*yp
99
rem1= diff(rem0,x)-2*rem0
100
rem2= diff(rem1,x)-2*rem1
101
rem3= diff(rem2,x)-2*rem2
102
remfinal= rem3-x^2*exp(x)-x*sin(3*x)
103
show(remfinal)
104
\end{verbatim}
105
106
\begin{figure}[!ht]
107
\includegraphics[width=1.0\textwidth]{p141}
108
\end{figure}
109
110
{\color{blue}\#Now, we will find the coefficients of the previous equation}
111
112
\begin{verbatim}
113
coeffEx=remfinal.coefficient(exp(x))
114
coeffCos=remfinal.coefficient(cos(3*x))
115
coeffSin=remfinal.coefficient(sin(3*x))
116
\end{verbatim}
117
118
{\color{blue}\#We will use the command Solve to find the coefficients A, B, C}
119
\begin{verbatim}
120
solve([coeffEx.coefficient(x,0)==0,coeffEx.coefficient(x,1)==0,
121
coeffEx.coefficient(x,2)==0],A,B,C)
122
\end{verbatim}
123
\begin{figure}[!ht]
124
\includegraphics[width=0.8\textwidth]{p15}
125
\end{figure}
126
127
{\color{blue}\#And now, we will find the remaining coefficients of the problem, which are the coefficients D, E, F, G}
128
129
\begin{verbatim}
130
solve ([coeffCos.coefficient(x,0)==0,coeffCos.coefficient(x,1)==0,
131
coeffSin.coefficient(x,0)==0,coeffSin.coefficient(x,1)==0],D,E,F,G)
132
\end{verbatim}
133
\begin{figure}[!ht]
134
\includegraphics[width=1.0\textwidth]{p16}
135
\end{figure}
136
137
{\color{blue}\#In short, the values of the coefficients found are the following ones:}
138
139
\begin{verbatim}
140
A=-267/250; B=-14/25; C=-1/10; D=-251/114244; E=-23/13182;
141
F=1379/514098; G=-3/8788;
142
\end{verbatim}
143
144
{\color{blue}\#We are now finally able to find the complementary solution as follows:}
145
146
\begin{verbatim}
147
var ('c1,c2,c3,c4,c5')
148
yc=c1*exp(2*x)+c2 *x*exp(2*x)+c3*x^2*exp(2*x)+c4*cos(3*x)+c5*sin(3*x)
149
+(A+B*x+C*x^2)*exp(x)+(D*x+E*x^2)*cos(3*x)+(F*x+G*x^2)*sin(3*x)
150
show(yc)
151
152
\end{verbatim}
153
\begin{figure}[!ht]
154
\includegraphics[width=0.9\textwidth]{p171}
155
\end{figure}
156
157
{\color{blue}\#Solving for the coeffients c1, c2, c3, c4, c5 we find:}
158
159
\begin{verbatim}
160
solve([yc.substitute(x=0)==1,diff(yc,x).substitute(x=0)==1,
161
diff(yc,x,2).substitute(x=0)==1,diff(yc,x,3).substitute(x=0)==1,
162
diff(yc,x,4).substitute(x=0)==1],c1,c2,c3,c4,c5
163
\end{verbatim}
164
165
\begin{figure}[!ht]
166
\includegraphics[width=1.0\textwidth]{P181}
167
\end{figure}
168
169
{\color{blue}\#In short, the values of the coefficients c1, c2, c3, c4, c5 are:}
170
171
\begin{verbatim}
172
c1 =774782/371293; c2 = -43330/28561; c3 =1020/2197;
173
c4= -1737019/92823250; c5 = -4850123/556939500
174
\end{verbatim}
175
176
{\color{blue}\#And my complete solution (complementary and particular)for the differential equation with the initial conditions given, is::}
177
178
\begin{verbatim}
179
yc=c1*exp(2*x)+c2*x*exp(2*x)+c3*x^2*exp(2*x)+c4*cos(3*x)
180
+c5*sin(3*x)+(A+B*x+C*x^2)*exp(x)+(D*x+E*x^2)*cos(3*x)
181
+(F*x+G*x^2)*sin(3*x)
182
show ( yc )
183
\end{verbatim}
184
185
\begin{figure}[!ht]
186
\includegraphics[width=1.0\textwidth]{p19}
187
\end{figure}
188
189
{\color{red} The previous equation solves the differential equation with initial conditions given in PROBLEM 01}
190
191
192
193
\newpage
194
\section{PROBLEM 02}
195
\label{Solucion del problema 2}
196
197
198
\%md\\
199
{\color{blue}\#PROBLEM 2\\
200
201
\#\#\# POWER SERIES:\\
202
203
\#\#\# Find the firs 6 nonzero terms in each of two linearly\\
204
205
\#\#\# independent solutions of the form $\sum{c_nx^n} $, for\\
206
207
\#\#\# the following differential equation:\\
208
209
\#\#\# $ xy''+(sin x)y'+xy=0$}\\
210
211
\begin{figure}[!ht]
212
\includegraphics[width=0.8\textwidth]{p210}
213
\end{figure}
214
215
{\color{blue}\# Lets start by generating a sum with 12 terms using Sage Worksheet}
216
217
\begin{verbatim}
218
reset()
219
n=12
220
a=list(var('a%d'%i)for i in range(n))
221
x=var('x')
222
y=function('y')(x)
223
var('a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11')
224
a0=0
225
a1=1
226
y(x)=a0+a1*x+a2*x^2+a3*x^3+a4*x^4+a5*x^5+a6*x^6
227
+a7*x^7+a8*x^8+a9*x^9+a10*x^10+a11*x^11
228
show(y(x))
229
\end{verbatim}
230
\begin{figure}[!ht]
231
\includegraphics[width=0.9\textwidth]{p22}
232
\end{figure}
233
234
235
\pagebreak
236
237
{\color{blue}\# Expanding the sine function using the Mclaurin polynomial to substitute it in the differential equation.}
238
239
\begin{verbatim}
240
sinX=taylor(sin(x),x,0,12)
241
show (sinX)
242
a0=0
243
a1=1
244
eq = expand (x*diff(y,x,2)+sinX*diff(y,x,1)+x*y(x)==0)
245
\end{verbatim}
246
247
{\color{blue}\#Substituting the expansion in the differential equation given.}
248
\begin{verbatim}
249
show(eq)
250
\end{verbatim}
251
252
\begin{figure}[!ht]
253
\includegraphics[width=1.2\textwidth]{p23}
254
\end{figure}
255
256
{\color{blue}\#grouping the coefficients of x and solving the system
257
to find a2 we have :}
258
\begin{verbatim}
259
solve ([eq.lhs().coefficient(x,1)==0],a2)
260
show (solve([eq.lhs().coefficient(x,1)==0],a2))
261
\end{verbatim}
262
\begin{figure}[!ht]
263
\includegraphics[width=0.6\textwidth]{p24}
264
\end{figure}
265
266
{\color{blue}\#performing this process recursively to find the other coefficients of our series we have:}
267
268
\begin{verbatim}
269
show (solve([eq.lhs().coefficient(x,2).substitute(a2=-1/2)==0],a3))
270
\end{verbatim}
271
\begin{figure}[!ht]
272
\includegraphics[width=0.4\textwidth]{p25}
273
\end{figure}
274
275
\begin{verbatim}
276
show (solve([eq.lhs().coefficient(x,3).substitute(a2=-1/2,a3=0)==0],a4))
277
\end{verbatim}
278
\begin{figure}[!ht]
279
\includegraphics[width=0.4\textwidth]{p26}
280
\end{figure}
281
282
283
\begin{verbatim}
284
show (solve([eq.lhs().coefficient(x,4).substitute(a2=-1/2,a3=0,
285
a4=1/18)==0],a5))
286
\end{verbatim}
287
\begin{figure}[!ht]
288
\includegraphics[width=0.4\textwidth]{p27}
289
\end{figure}
290
291
292
\begin{verbatim}
293
show (solve([eq.lhs().coefficient(x,5).substitute(a2=-1/2,a3=0,
294
a4=1/18,a5=-7/360)==0],a6))
295
\end{verbatim}
296
\begin{figure}[!ht]
297
\includegraphics[width=0.4\textwidth]{p28}
298
\end{figure}
299
300
\pagebreak
301
\begin{verbatim}
302
show (solve([eq.lhs().coefficient(x,6).substitute(a2=-1/2,a3=0,
303
a4=1/18,a5=-7/360,a6=1/900)==0],a7))
304
\end{verbatim}
305
\begin{figure}[!ht]
306
\includegraphics[width=0.5\textwidth]{p29}
307
\end{figure}
308
309
310
\begin{verbatim}
311
show (solve([eq.lhs().coefficient(x,7).substitute(a2=-1/2,a3=0,
312
a4=1/18,a5=-7/360,a6=1/900,a7=157/113400)==0],a8))
313
\end{verbatim}
314
\begin{figure}[!ht]
315
\includegraphics[width=0.5\textwidth]{p230}
316
\end{figure}
317
318
\begin{verbatim}
319
show (solve([eq.lhs().coefficient(x,8).substitute(a2=-1/2,a3=0,
320
a4=1/18,a5=-7/360,a6=1/900,a7=157/113400,a8=-19/39690)==0],a9))
321
\end{verbatim}
322
\begin{figure}[!ht]
323
\includegraphics[width=0.5\textwidth]{p231}
324
\end{figure}
325
326
327
\begin{verbatim}
328
show (solve([eq.lhs().coefficient(x,9).substitute(a2=-1/2,a3=0,
329
a4=1/18,a5=-7/360,a6=1/900,a7=157/113400,a8=-19/39690,
330
a9=797/38102400)==0],a10))
331
\end{verbatim}
332
\begin{figure}[!ht]
333
\includegraphics[width=0.6\textwidth]{p232}
334
\end{figure}
335
336
337
\begin{verbatim}
338
show (solve([eq.lhs().coefficient(x,10).substitute(a2=-1/2,a3=0,
339
a4=1/18,a5=-7/360,a6=1/900,a7=157/113400,a8=-19/39690,
340
a9=797/38102400,a10=923/30618000)==0],a11))
341
\end{verbatim}
342
\begin{figure}[!ht]
343
\includegraphics[width=0.55\textwidth]{p233}
344
\end{figure}
345
346
\pagebreak
347
{\color{blue}\#Now that we have calculated the coefficients we can calculate our first solution.}
348
\begin{verbatim}
349
y1 (x)=0+1*x+(-1/2)*x^2+(0)*x^3+(1/18)*x^4+(-7/360)*x^5+(1/900)*x^6
350
+(157/113400)*x^7+(-19/39690)*x^8+(797/38102400)*x^9
351
+(923/30618000)*x^10+(-415519/47151720000)*x^11
352
show (y1(x))
353
\end{verbatim}
354
\begin{figure}[!ht]
355
\includegraphics[width=0.9\textwidth]{p234}
356
\end{figure}
357
{\color{red}The previous equation is our first solution for the differential equation}
358
359
\newpage
360
{\color{blue}\#Now we do the analogous process for our second linearly independent solution}\\
361
362
{\color{blue}\#And we star by generating a sum with the terms\underline{}\underline{}.}
363
\begin{verbatim}
364
reset ()
365
n=12
366
a= list (var('a%d'%i) for i in range (n))
367
x=var('x')
368
y=function('y')(x)
369
var('a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11')
370
a0=1
371
a1=0
372
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
373
+a9*x^9+a10*x^10+a11*x^11
374
show(y(x))
375
\end{verbatim}
376
377
\begin{figure}[!ht]
378
\includegraphics[width=1.1\textwidth]{p235}
379
\end{figure}
380
381
{\color{blue}\#expanding the sine function using the Mclaurin polynomial to use it in the differential equation}
382
\begin{verbatim}
383
senoX=taylor(sin(x),x,0,12)
384
show (senoX)
385
a0=1
386
a1=0
387
eq = expand (x*diff(y,x,2)+senoX*diff(y,x,1)+x*y(x)==0)
388
\end{verbatim}
389
{\color{blue}\# Substituting the expansion in the differential equation given}
390
391
\pagebreak
392
\begin{verbatim}
393
show(eq)
394
\end{verbatim}
395
\begin{figure}[!ht]
396
\includegraphics[width=1.11\textwidth]{p236}
397
\end{figure}
398
{\color{blue}\# Again, grouping the coefficients of x and solving the system to find a2 we have:}
399
400
\begin{verbatim}
401
solve([eq.lhs().coefficient(x,1)==0],a2)
402
show(solve([eq.lhs().coefficient(x,1)==0],a2))
403
\end{verbatim}
404
\begin{figure}[!ht]
405
\includegraphics[width=0.7\textwidth]{p237}
406
\end{figure}
407
408
{\color{blue}\# We now perform this process recursively to find the others coefficients of our series.}
409
410
\begin{verbatim}
411
show(solve([eq.lhs().coefficient(x,2).substitute(a2=-1/2)==0],a3))
412
\end{verbatim}
413
\begin{figure}[!ht]
414
\includegraphics[width=0.5\textwidth]{p238}
415
\end{figure}
416
417
\pagebreak
418
\begin{verbatim}
419
show(solve([eq.lhs().coefficient(x,3).substitute(a2=-1/2,a3=1/6)==0],a4))
420
\end{verbatim}
421
\begin{figure}[!ht]
422
\includegraphics[width=0.5\textwidth]{p239}
423
\end{figure}
424
425
\begin{verbatim}
426
show(solve([eq.lhs().coefficient(x,4).substitute(a2=-1/2,a3=1/6, a4=0)==0],a5))
427
\end{verbatim}
428
\begin{figure}[!ht]
429
\includegraphics[width=0.5\textwidth]{p240}
430
\end{figure}
431
432
433
\begin{verbatim}
434
show(solve([eq.lhs().coefficient(x,5).substitute(a2=-1/2,a3=1/6,
435
a4=0,a5=-1/60)==0],a6))
436
\end{verbatim}
437
\begin{figure}[!ht]
438
\includegraphics[width=0.5\textwidth]{p241}
439
\end{figure}
440
441
\begin{verbatim}
442
show(solve([eq.lhs().coefficient(x,6).substitute(a2=-1/2,a3=1/6,
443
a4=0,a5=-1/60,a6=1/180)==0],a7))
444
\end{verbatim}
445
\begin{figure}[!ht]
446
\includegraphics[width=0.5\textwidth]{p242}
447
\end{figure}
448
449
\begin{verbatim}
450
show(solve([eq.lhs().coefficient(x,7).substitute(a2=-1/2,a3=1/6,
451
a4=0,a5=-1/60,a6=1/180,a7=-1/5040)==0],a8))
452
\end{verbatim}
453
\begin{figure}[!ht]
454
\includegraphics[width=0.5\textwidth]{p243}
455
\end{figure}
456
457
\begin{verbatim}
458
show(solve([eq.lhs().coefficient(x,8).substitute(a2=-1/2,a3 =1/6,
459
a4=0,a5=-1/60,a6=1/180,a7=-1/5040,a8=-1/2520)==0],a9))
460
\end{verbatim}
461
\begin{figure}[!ht]
462
\includegraphics[width=0.5\textwidth]{p244}
463
\end{figure}
464
465
\newpage
466
\begin{verbatim}
467
show(solve([eq.lhs().coefficient(x,9).substitute(a2=-1/2,a3 =1/6,
468
a4=0,a5=-1/60,a6=1/180,a7=-1/5040,a8=-1/2520,a9=11/90720)==0],a10))
469
\end{verbatim}
470
\begin{figure}[!ht]
471
\includegraphics[width=0.5\textwidth]{p245}
472
\end{figure}
473
474
\begin{verbatim}
475
show(solve([eq.lhs().coefficient(x,10).substitute(a2=-1/2,a3=1/6,
476
a4=0,a5=-1/60,a6=1/180,a7=-1/5040,a8=-1/2520,a9=11/90720,
477
a10=-1/680400)==0],a11))
478
\end{verbatim}
479
\begin{figure}[!ht]
480
\includegraphics[width=0.5\textwidth]{p246}
481
\end{figure}
482
483
{\color{blue}\# Now that have calculated the coeffients of our seconds solution}
484
\begin{verbatim}
485
y2(x)=1+0*x+(-1/2)*x^2+(1/6)*x^3+(0)*x^4+(-1/60)*x^5+(1/180)*x^6
486
+(-1/5040)*x^7+(-1/2520)*x^8+(11/90720)*x^9+(-1/680400)*x^10
487
+(-4957/598752000)*x^11
488
show(y2(x))
489
\end{verbatim}
490
\begin{figure}[!ht]
491
\includegraphics[width=1.11\textwidth]{p247}
492
\end{figure}
493
494
{\color{red}The previous equation is our second solution for the differential equation.}
495
496
\pagebreak
497
\section{CONCLUSIONS}
498
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:
499
500
\begin{figure}[!ht]
501
\includegraphics[width=1.0\textwidth]{p19}
502
\end{figure}
503
504
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. \\
505
506
Our first solution for the second problem, at 12 terms in the expansion of the sum is:
507
\begin{figure}[!ht]
508
\includegraphics[width=0.9\textwidth]{p234}
509
\end{figure}
510
511
And the second solution for the second problem, at 12 terms in the expansion of the sum, is:
512
513
\begin{figure}[!ht]
514
\includegraphics[width=1.11\textwidth]{p247}
515
\end{figure}
516
517
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.\\
518
519
520
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.
521
522
523
\end{document}
524
525