-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise14.tex
1258 lines (1140 loc) · 45.9 KB
/
exercise14.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[11pt]{article}
% \def\hidesolutions{}
\input{header}
% \usepackage[margin=5mm]{geometry}
\begin{document}
\exsheet{14}{19}{December} % parameters are the number of the session and the day
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%% EXERCISE 1 %%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}
Given the following functions over an interval $[0,1)$,
\begin{enumerate}[label=(\alph*)]
\item $f(x) = x$
\item $g(x) = x^2$
\item $h(x) = e^x$
\item $s(x) = sin(\pi x)$
\end{enumerate}
sketch their extension to
\begin{itemize}
\item a periodic function with period $1$,
\item an even periodic function with period $2$,
\item an odd periodic function with period $2$.
\end{itemize}
State the formulas for the even and odd $2$-periodic extensions over the interval $[-1,1]$.
\end{exercise}
\begin{solution}
We begin with these plots:
\begin{center}
\begin{tabular}{cc} % 2x2 matrix structure
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-2:-1,smooth,variable=\x,blue] plot({\x},{\x+2});
\draw[domain=-1:0,smooth,variable=\x,blue] plot({\x},{\x+1});
\draw[domain=0:1,smooth,variable=\x,blue] plot({\x},{\x});
\draw[domain=1:2,smooth,variable=\x,blue] plot({\x},{\x-1});
\node[blue,above right] at (0.5,0.5) {$f(x)=x$};
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-2:-1,smooth,variable=\x,red] plot({\x},{(\x+2)*(\x+2)});
\draw[domain=-1:0,smooth,variable=\x,red] plot({\x},{(\x+1)*(\x+1)});
\draw[domain=0:1,smooth,variable=\x,red] plot({\x},{\x*\x});
\draw[domain=1:2,smooth,variable=\x,red] plot({\x},{(\x-1)*(\x-1)});
\node[red,above] at (0.5,0.5) {$g(x)=x^2$};
\end{tikzpicture}
\\
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-2:-1,smooth,variable=\x,green] plot({\x},{exp(\x+2)});
\draw[domain=-1:0,smooth,variable=\x,green] plot({\x},{exp(\x+1)});
\draw[domain=0:1,smooth,variable=\x,green] plot({\x},{exp(\x)});
\draw[domain=1:2,smooth,variable=\x,green] plot({\x},{exp(\x-1)});
\node[green,above right] at (0.5,1.5) {$h(x)=e^x$};
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-2:-1,smooth,variable=\x,orange] plot({\x},{sin(3.14159*(\x+2) r)});
\draw[domain=-1:0,smooth,variable=\x,orange] plot({\x},{sin(3.14159*(\x+1) r)});
\draw[domain=0:1,smooth,variable=\x,orange] plot({\x},{sin(3.14159*\x r)});
\draw[domain=1:2,smooth,variable=\x,orange] plot({\x},{sin(3.14159*(\x-1) r)});
\node[orange,above] at (0.5,0.5) {$s(x)=\sin(\pi x)$};
\end{tikzpicture}
\end{tabular}
\end{center}
\begin{center}
\begin{tabular}{cc} % 2x2 matrix structure
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-1:1,smooth,variable=\x,blue] plot({\x},{abs(\x)});
\draw[domain=1:2,smooth,variable=\x,blue] plot({\x},{abs(\x-2)});
\draw[domain=-2:-1,smooth,variable=\x,blue] plot({\x},{abs(\x+2)});
\node[blue,above right] at (0.5,0.5) {$f_{\text{even}}(x)$};
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-1:1,smooth,variable=\x,red] plot({\x},{\x*\x});
\draw[domain=1:2,smooth,variable=\x,red] plot({\x},{abs(\x-2)*abs(\x-2)});
\draw[domain=-2:-1,smooth,variable=\x,red] plot({\x},{abs(\x+2)*abs(\x+2)});
\node[red,above] at (0.5,0.5) {$g_{\text{even}}(x)$};
\end{tikzpicture}
\\
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-1:1,smooth,variable=\x,green] plot({\x},{exp(abs(\x))});
\draw[domain=1:2,smooth,variable=\x,green] plot({\x},{exp(abs(\x-2))});
\draw[domain=-2:-1,smooth,variable=\x,green] plot({\x},{exp(abs(\x+2))});
\node[green,above right] at (0.5,1.5) {$h_{\text{even}}(x)$};
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-1:1,smooth,variable=\x,orange] plot({\x},{sin(3.14159*abs(\x) r)});
\draw[domain=1:2,smooth,variable=\x,orange] plot({\x},{sin(3.14159*abs(\x-2) r)});
\draw[domain=-2:-1,smooth,variable=\x,orange] plot({\x},{sin(3.14159*abs(\x+2) r)});
\node[orange,above] at (0.5,0.5) {$s_{\text{even}}(x)$};
\end{tikzpicture}
\end{tabular}
\end{center}
\begin{center}
\begin{tabular}{cc} % 2x2 matrix structure
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-1:1,smooth,variable=\x,blue] plot({\x},{\x});
\draw[domain=1:2,smooth,variable=\x,blue] plot({\x},{\x-2});
\draw[domain=-2:-1,smooth,variable=\x,blue] plot({\x},{\x+2});
\node[blue,above right] at (0.5,0.5) {$f_{\text{odd}}(x)$};
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-2:-1,smooth,variable=\x,red] plot({\x}, {(\x+2)*(\x+2)});
\draw[domain=-1: 0,smooth,variable=\x,red] plot({\x},-{\x*\x});
\draw[domain= 0: 1,smooth,variable=\x,red] plot({\x}, {\x*\x});
\draw[domain= 1: 2,smooth,variable=\x,red] plot({\x},-{(\x-2)*(\x-2)});
\node[red,above] at (0.5,0.5) {$g_{\text{odd}}(x)$};
\end{tikzpicture}
\\
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-2:-1,smooth,variable=\x,green] plot({\x}, {exp( \x+2)});
\draw[domain=-1: 0,smooth,variable=\x,green] plot({\x},-{exp(-\x )});
\draw[domain= 0: 1,smooth,variable=\x,green] plot({\x}, {exp( \x )});
\draw[domain= 1: 2,smooth,variable=\x,green] plot({\x},-{exp(-\x+2)});
\node[green,above right] at (0.5,1.5) {$h_{\text{odd}}(x)$};
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
\draw[domain=-2:2,smooth,variable=\x,orange] plot({\x},{sin(3.14159*\x r)});
\node[orange,above] at (0.5,0.5) {$s_{\text{odd}}(x)$};
\end{tikzpicture}
\end{tabular}
\end{center}
We state the formulas for the even and odd extensions of period $2$.
Over \([-1,1]\), define the even extensions:
\begin{align*}
f_{\text{even}}(x) &= |x|,
\\
g_{\text{even}}(x) &= x^2,
\\
h_{\text{even}}(x) &= e^{|x|},
\\
s_{\text{even}}(x) &= |\sin(\pi x)|,
\end{align*}
and we define the odd extensions:
\begin{align*}
f_{\text{odd}}(x) &= x,
\\
g_{\text{odd}}(x) &= \begin{cases}
x^2 & x \in [0,1) \\
-(-x)^2 = -x^2 & x \in [-1,0)
\end{cases}
\\
h_{\text{odd}}(x) &= \begin{cases}
e^x & x \in [0,1) \\
-e^{-x} & x \in [-1,0)
\end{cases},
\\
s_{\text{odd}}(x) &= \sin(\pi x).
\end{align*}
\end{solution}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%% EXERCISE 2 %%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}
Consider the function
\begin{align*}
f : [0,1] \to \bbR, \quad x \mapsto x^{3}.
\end{align*}
Extend this to an odd function with period $T = 2$. Sketch the graph of that function from $-2$ to $2$.
Compute its Fourier coefficients in standard form. Compute the complex Fourier coefficients.
\end{exercise}
\begin{solution}
We first sketch the odd extensions of that function:
\begin{center}
\begin{tikzpicture}[scale=0.6]
\draw[->] (-2,0)--(2,0) node[right]{$x$};
\draw[->] (0,-3)--(0,3) node[above]{$y$};
% g(x) = x^3, odd extension
\draw[domain=-2:-1,smooth,variable=\x,red] plot({\x}, {(\x+2)*(\x+2)*(\x+2)});
\draw[domain=-1: 0,smooth,variable=\x,red] plot({\x}, {\x*\x*\x});
\draw[domain= 0: 1,smooth,variable=\x,red] plot({\x}, {\x*\x*\x});
\draw[domain= 1: 2,smooth,variable=\x,red] plot({\x}, {(\x-2)*(\x-2)*(\x-2)});
\node[red,above] at (0.5,0.5) {$g_{\text{odd}}(x)$};
\end{tikzpicture}
\end{center}
The odd extension of period 2 is given by
\begin{align*}
f_{\text{odd}}(x) = x^3, \quad x \in [-1,1].
\end{align*}
For the Fourier coefficients in standard form, we note that $a_n = 0, n \in \mathbb{N}$ since the function is odd by construction. For the sine-terms, we have
\begin{align*}
b_n = \int_{-1}^1 f_{\text{odd}}(x) \sin(\pi n x) \ dx = 2 \int_{0}^1 x^3 \sin(\pi n x) \ dx
= \frac{2(-1)^n (6 - \pi^2 n^2)}{\pi^3 n^3}.
\end{align*}
We directly compute the integral via repeated integration by parts:
\begin{align*}
\int_{0}^1 x^3 \sin(\pi n x) \ dx
&
=
\left[ x^3 \tfrac{(-1)}{\pi n} \cos(\pi n x)\right]_{x=0}^{x=1}
+
3 \tfrac{(-1)}{\pi n} \int_{0}^1 x^2 \cos(\pi n x) \ dx
\\&
=
\tfrac{(-1)}{\pi n} \cos(\pi n)
+
3 \tfrac{(-1)}{\pi n} \int_{0}^1 x^2 \cos(\pi n x) \ dx
\\&
=
- \tfrac{(-1)^{n}}{\pi n}
+
3 \tfrac{(-1)}{\pi n} \int_{0}^1 x^2 \cos(\pi n x) \ dx
.
\end{align*}
\begin{align*}
\int_{0}^1 x^2 \cos(\pi n x) \ dx
=
\left[ x^2 \tfrac{1}{\pi n} \sin(\pi n x)\right]_{x=0}^{x=1}
+
2 \tfrac{1}{\pi n} \int_{0}^1 x \sin(\pi n x) \ dx
=
2 \tfrac{1}{\pi n} \int_{0}^1 x \sin(\pi n x) \ dx
.
\end{align*}
\begin{align*}
\int_{0}^1 x \sin(\pi n x) \ dx
&
=
\left[ x \tfrac{(-1)}{\pi n} \cos(\pi n x)\right]_{x=0}^{x=1}
+
\tfrac{(-1)}{\pi n}
\int_{0}^1 \cos(\pi n x) \ dx
\\&
=
\left[ x \tfrac{(-1)}{\pi n} \cos(\pi n x)\right]_{x=0}^{x=1}
+
\tfrac{1}{\pi^{2} n^{2}}
\left[ \sin(\pi n x)\right]_{x=0}^{x=1}
\\&
=
(-1)^{n}
\tfrac{(-1)}{\pi n}
.
\end{align*}
Putting all this together, we obtain
\begin{align*}
\int_{0}^1 x^3 \sin(\pi n x) \ dx
&
=
- \tfrac{(-1)^{n}}{\pi n}
+
3 \tfrac{(-1)}{\pi n}
2 \tfrac{1}{\pi n}
(-1)^{n}
\tfrac{(-1)}{\pi n}
\\&
=
- \frac{(-1)^{n}}{\pi n}
+
\frac{6}{\pi^{3} n^{3}}
(-1)^{n}
\\&
=
(-1)^{n}
\frac{ \pi^{2} n^{2} - 6 }{ \pi^{3} n^{3} }
.
\end{align*}
For the complex Fourier coefficients, we find for $n \in \mathbb{N}$:
\begin{align*}
c_0 &= a_0 = 0,
\\
c_n &= \frac 1 2 (a_n - i b_n) = \frac{i (-1)^{n+1} (\pi^2 n^2 - 6)}{\pi^3 n^3},
\\
c_{-n} &= \frac 1 2 (a_n + i b_n) = \frac{i(-1)^n(\pi^2 n^2 - 6)}{\pi^3 n^3}.
\end{align*}
\end{solution}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%% EXERCISE 3 %%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}
Suppose that
\begin{align*}
f(x) = \left\{\begin{array}{cc} x+1 & \text{ if $-1 < x < 0$ }, \\ 1-x & \text{ if $ 0 < x < 1$ }, \\ 0 & \text{ otherwise. } \end{array}\right.
\qquad
g(x) = \left\{\begin{array}{cc} \frac 1 2 & \text{ if $-1 < x < 1$ }, \\ 0 & \text{ otherwise. } \end{array}\right.
\qquad
h(x) = |x|
.
\end{align*}
Compute the convolutions $u(x) = (f \star g)(x)$ and $v(x) = (g \star g)(x)$ and $w(x) = (g \star h)(x)$.
\end{exercise}
\begin{solution}
We can compute these convolutions via direct computations or by results from Fourier analysis.
\begin{itemize}
\item
This first one is the most difficult one. First, we note that
\begin{align*}
g(x) = \frac 1 2 1_{[-1,1]}(x), & & 1_{[-1,1]}(x) = \begin{cases}
1 & x \in [-1,1],\\
0 & \text{otherwise},
\end{cases}
\end{align*}
and
\begin{align*}
f(x) = (x+1) 1_{[-1,0]}(x) + (1-x) 1_{(0,1]}(x).
\end{align*}
Furthermore, we have for any $x, y \in \mathbb R$ that
\begin{align*}
1_{[-1, 1]}(x - y) &= 1_{[x - 1, x + 1]}(y).
\end{align*}
Hence, we can write
\begin{align*}
( f \star g )(x) &= \frac 1 2 \int_{-\infty}^\infty f(y) 1_{[x - 1, x + 1]}(y) dy.
\end{align*}
We think of this as a subinterval $[x-1,x+1]$ that moves over the real line,
and we integrate $f$ over this subinterval.
Since $f$ change its behavior three different times, the integral in the definition of $f \star g$ above will also change its behavior several times, depending on $x$.
We therefore use a case distinction.
\begin{enumerate}
\item If $x < -2$, the integral is just over the region where $f$ equals zero,
and so $( f \star g )(x) = 0$.
\item If $-2 < x < -1$, then we only need to integrate $f$ over $[-1,x+1] \subseteq [-1,0]$. We find
\begin{align*}
(f \star g)(x) = \frac 1 2 \int_{-1}^{x + 1} (y + 1) dy = \frac 1 4 (y+1)^{2} \Big|_{y=-1}^{y=x+1} = \frac 1 4 (x + 2)^2.
\end{align*}
\item If $-1 < x < 0$, then we integrate $f$ over $[-1,0] \cup [0,x+1] \subseteq [-1,1]$. We find
\begin{align*}
(f \star g)(x)
&
=
\frac 1 2\int_{-1}^{0} (y + 1) dy + \frac 1 2\int_{0}^{x + 1} (1 - y) dy
\\&
=
\frac 1 4 (y+1)^{2} \Big|_{y=-1}^{y=0} - \frac 1 4 (1-y)^{2} \Big|_{y=0}^{y=x+1}
=
\frac 1 4
-
\left( \frac{x^{2}}{4} - \frac 1 4 \right)
=
\frac 1 2
-
\frac 1 4 x^2
.
\end{align*}
\item If $0 < x < 1$, then we integrate $f$ over $[x-1,0] \cup [0,1] \subseteq [-1,1]$. We find
\begin{align*}
(f \star g)(x)
&=
\frac 1 2 \int_{x - 1}^{0} (y + 1) dy + \frac 1 2 \int_{0}^{1} (1 - y) dy = \frac 1 2 - \frac 1 4 x^2
\\&
=
\frac 1 4 (y+1)^{2} \Big|_{y=x-1}^{y=0} - \frac 1 4 (1-y)^{2} \Big|_{y=0}^{y=1}
=
\left( \frac 1 4 - \frac{x^{2}}{4} \right)
+
\frac 1 4
=
\frac 1 2
-
\frac 1 4 x^2
.
\end{align*}
\item If $1 < x < 2$, then we integrate $f$ over $[x-1,1] \subseteq [0,1]$. We find
\begin{align*}
(f \star g)(x) = \frac 1 2 \int_{x - 1}^{1} (1 - y) dy = \frac 1 4 ( x - 2)^2
\end{align*}
\item Lastly, if $2 < x$, the integral is just over the region where $f$ equals zero,
and so $( f \star g )(x) = 0$.
\end{enumerate}
\item
Note that
\begin{align*}
\hat{f}(\omega) &= \frac{1}{\sqrt{2 \pi}} \left(\frac{\sin(\omega / 2)}{\omega / 2}\right),
\\
\hat{g}(\omega) &= \frac{1}{\sqrt{2 \pi}} \frac{\sin(\omega)}{\omega}.
\end{align*}
Using the Convolution Theorem, we find
\begin{align*}
\hat{v}(\omega) = \sqrt{2 \pi}(\hat g (\omega))^2 = \hat f(2 \omega)
\end{align*}
Using the Modulation Theorem, we find
\begin{align*}
v(x) &= \frac 1 2 \mathcal{F}^{-1}(2 \hat f(2 \omega)) = \frac 1 2 f(\frac x 2)\\
&= \frac 1 4 \begin{cases}
2 + x,& -2 \leq x < 0,\\
2 - x,& 0 \leq x < 2.
\end{cases}
\end{align*}
Alternatively, consider
\begin{align*}
( g \star g )(x) = \frac 1 2 \int_{x-1}^{x+1} g(y) \ dy.
\end{align*}
The $g$ in the integral has support $[-1,1]$.
Clearly, this integral equals $0$ when $x < -2$ or when $x > 2$ because then $(x-1,x+1)$ and $(-1,1)$ are disjoint.
So it remains to consider the case $-2 < x < 2$.
The integral equals (up to a factor of $\tfrac 1 2$, the length of the intersection of $(x-1,x+1)$ and $(-1,1)$.
To put this into a formula, it seems reasonable to distinguish whether $x$ lies to the left or to the right of the origin.
If $-2 \leq x \leq 0$, then
\begin{align*}
\int_{x-1}^{x+1} g(y) \ dy = \int_{-1}^{x+1} g(y) \ dy = \frac 1 2 ( (x+1) - (-1) ) = \frac 1 2 ( x + 2 ).
\end{align*}
Hence
\begin{align*}
( g \star g )(x) = \frac 1 4 ( x + 2 ).
\end{align*}
If $0 \leq x \leq 2$, then
\begin{align*}
\int_{x-1}^{x+1} g(y) \ dy = \int_{x-1}^{1} g(y) \ dy = \frac 1 2 ( (1) - (x-1) ) = \frac 1 2 ( 2 - x ).
\end{align*}
Hence
\begin{align*}
( g \star g )(x) = \frac 1 4 ( 2 - x ).
\end{align*}
\item
We first observe
\begin{align*}
( g \star h )(x) = \frac 1 2 \int_{x-1}^{x+1} |y| dy.
\end{align*}
The absolute value function has two different regimes.
From here, we make a case distinction, depending on whether $(x-1,x+1)$ lies in one of the regimes or the other.
If $0 < x-1$, which means $1 < x$, then $(x-1,x+1)$ lies within the positive real numbers and
\begin{align*}
( g \star h )(x) = \frac 1 2 \int_{x-1}^{x+1} y dy = x.
\end{align*}
If $x+1 < 0$, which means $x < -1$, then $(x-1,x+1)$ lies within the negative real numbers and
\begin{align*}
( g \star h )(x) = \frac 1 2 \int_{x-1}^{x+1} (-y) dy = -x.
\end{align*}
The case $x-1 < 0 < x+1$, which is $-1 < x < 1$, is more demanding. We split
\begin{align*}
( g \star h )(x)
&=
\frac 1 2 \int_{x-1}^{ 0} -y dy
+
\frac 1 2 \int_{ 0}^{x+1} y dy
\\&
=
\frac 1 2 \left[ -\frac 1 2 y^{2}\right]_{y=x-1}^{y= 0}
+
\frac 1 2 \left[ \frac 1 2 y^{2}\right]_{y= 0}^{y=x+1}
\\&
=
\frac 1 4 (x-1)^{2}
+
\frac 1 4 (x+1)^{2}
=
\frac 1 2 x^2 + \frac 1 2
.
\end{align*}
Note: if you plot this function, it will look like a moving average of $|x|$ that has been smoothed around $x=0$.
\end{itemize}
\end{solution}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%% EXERCISE 4 %%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}
Suppose that $f(x) = x^2$ and that
\begin{align*}
g(x) = \left\{\begin{array}{cc} \frac 1 2 & \text{ if $-1 < x < 1$ }, \\ 0 & \text{ otherwise. } \end{array}\right.
\qquad
h(x) = \left\{\begin{array}{cc} e^{-x} & \text{ if $x > 0$ }, \\ 0 & \text{ otherwise. } \end{array}\right.
\end{align*}
Compute the convolutions $u(x) = (f \star g)(x)$ and $v(x) = (f \star h)(x)$ .
\end{exercise}
\begin{solution}
We find by direct computation:
\begin{align*}
(f \star g)(x) = (g \star f)(x)
&
=
\frac 1 2 \int_{-1}^1 (x - y)^2 dy
\\&
=
\frac 1 2 \left( \frac{1}{3} (x+1)^{3} - \frac{1}{3} (x-1)^{3} \right)
\\&
=
\frac 1 6
\left(
( x^{3} + 3x^{2} + 3x + 1 )
-
( x^{3} - 3x^{2} + 3x - 1 )
\right)
\\&
=
\frac 1 6
\left(
6x^{2} + 2
\right)
\\&
=
x^2 + \frac 1 3
.
\end{align*}
Similarly,
\begin{align*}
(f \star h)(x)
=
\int_{0}^\infty (x - y)^2 e^{-y} dy
=
\int_{0}^\infty (y - x)^2 e^{-y} dy
.
\end{align*}
We proceed here with integration by parts: first,
\begin{align*}
\int_{0}^\infty (y - x)^2 e^{-y} dy
&=
\left[ - (y - x)^2 e^{-y} \right]_{y=0}^{y=\infty}
-
\int_{0}^\infty (-1)2(y - x) e^{-y} dy
\\
&=
x^2
+
2
\int_{0}^\infty (y - x) e^{-y} dy
.
\end{align*}
Then,
\begin{align*}
\int_{0}^\infty (y - x) e^{-y} dy
&=
\left[ - (y - x) e^{-y} \right]_{y=0}^{y=\infty}
-
\int_{0}^\infty (-1) e^{-y} dy
\\
&=
-x
+
\int_{0}^\infty e^{-y} dy
.
\end{align*}
Lastly,
\begin{align*}
\int_{0}^\infty e^{-y} dy = \left[ - e^{-y} \right]_{y=0}^{y=\infty} = 1
.
\end{align*}
Thus, in total, we obtain
\begin{align*}
(f \star h)(x)
=
x^{2} + 2 \left( -x + 1 \right) = x^{2} - 2 x + 2.
\end{align*}
\end{solution}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%% EXERCISE 5 %%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}
We have discussed solutions to the differential equation
\begin{align*}
- \Delta u(x) + k^2 u(x) = e^{-|x|}, \quad x \in \mathbb R.
\end{align*}
\begin{itemize}
\item
Verify that, in the case $k=1$, we have a solution
\begin{align*}
u(x) = \frac 1 2 (1+|x|) e^{-|x|}
\end{align*}
Verify that every function of the form
\begin{align*}
v(x) = \frac 1 2 (1+|x|) e^{-|x|} + c_1 e^{-x} + c_2 e^{x}
\end{align*}
is a solution. For which values of $c_1$ and $c_2$ does the function decay towards zero as $x$ goes to $\pm \infty$?
%
\item
Verify that, in the case $k \neq 1$, we have a solution
\begin{align*}
u(x) = - \frac{ e^{-k|x|} }{ k (k^2-1) } + \frac{ e^{-|x|} }{ k^2-1 }
\end{align*}
Verify that every function of the form
\begin{align*}
v(x) = - \frac{ e^{-k|x|} }{ k (k^2-1) } + \frac{ e^{-|x|} }{ k^2-1 } + c_1 e^{-kx} + c_2 e^{kx}
\end{align*}
is a solution.
\end{itemize}
\end{exercise}
\begin{solution}
\begin{itemize}
\item
Consider the function
\begin{align*}
v(x) = \frac 1 2 (1+|x|) e^{-|x|} + c_1 e^{-x} + c_2 e^{x}.
\end{align*}
Obviously, $u(x)$ is a special case of a function of that form when $c_1 = c_2 = 0$.
This function is continuous and it is differentiable over $(-\infty,0)$ and $(0,\infty)$.
Its derivative equals
\begin{align*}
v'(x) = - \frac 1 2 x e^{-|x|} - c_1 e^{-x} + c_2 e^{x}.
\end{align*}
To see that, we can, e.g., compute the $v'$ for $x > 0$ and $x < 0$ and verify that $v'$ matches this description.
This function is again continuous and it is differentiable over $(-\infty,0)$ and $(0,\infty)$.
Its derivative equals
\begin{align*}
v''(x) = \frac 1 2 e^{-|x|} \left( |x| - 1 \right) + c_1 e^{-x} + c_2 e^{x}.
\end{align*}
That this is a solution to the differential equations is evident from
\begin{align*}
- v''(x) + v(x)
&
=
- \frac 1 2 e^{-|x|} \left( |x| - 1 \right) - c_1 e^{-x} - c_2 e^{x} + \frac 1 2 (1+|x|) e^{-|x|} + c_1 e^{-x} + c_2 e^{x}
\\&
=
\frac 1 2 e^{-|x|} \left( 1 - |x| \right) + \frac 1 2 (1+|x|) e^{-|x|}
=
e^{-|x|}
.
\end{align*}
To ensure that the solution decays towards zero as $x$ goes to $\pm \infty$, we need to have $c_1 = c_2 = 0$.
\item
We repeat the same type of arguments.
Consider the function
\begin{align*}
v(x)
&=
- \frac{ e^{-k|x|} }{ k (k^2-1) }
+
\frac{ e^{-|x|} }{ k^2-1 }
+
c_1 e^{-kx}
+
c_2 e^{kx}
.
\end{align*}
Obviously, $u(x)$ is a special case of a function of that form when $c_1 = c_2 = 0$.
Clearly, $v$ is continuous and it is differentiable over $(-\infty,0)$ and $(0,\infty)$.
Calculations, for $v \neq 0$ show that the derivative (in the sense of distributions) equals
\begin{align*}
v'(x)
=
\operatorname{sign}(x) \frac{ \left( e^{-k|x|} - e^{-|x|} \right) }{ k^{2}-1 }
+
(-k) c_1 e^{-kx}
+
k c_2 e^{kx}
.
\end{align*}
This function is still continuous and obviously differentiable over $(-\infty,0)$ and $(0,\infty)$.
We find that
\begin{align*}
v''(x)
&=
2\delta_{0} \cdot \frac{ \left( e^{-k|x|} - e^{-|x|} \right) }{ k^{2}-1 }
+
\operatorname{sign}(x)^{2} \frac{ \left( - k e^{-k|x|} + e^{-|x|} \right) }{ k^{2}-1 }
+
k^{2} c_1 e^{-kx}
+
k^{2} c_2 e^{kx}
\\&
=
\frac{ \left( - k e^{-k|x|} + e^{-|x|} \right) }{ k^{2}-1 }
+
k^{2} c_1 e^{-kx}
+
k^{2} c_2 e^{kx}
.
\end{align*}
Here, we have used that the $e^{-|x|} - e^{-k|x|} = 0$ at $x=0$.
That being settled, we check
\begin{align*}
&
- v''(x) + k^{2} v(x)
\\&\qquad
=
-
\frac{ - k e^{-k|x|} + e^{-|x|} }{ k^{2}-1 }
-
k^{2} c_1 e^{-x}
-
k^{2} c_2 e^{x}
-
k^{2} \frac{ e^{-k|x|} }{ k (k^2-1) }
+
k^{2} \frac{ e^{-|x|} }{ k^2-1 }
+
c_1 e^{-x}
+
c_2 e^{x}
\\&\qquad
=
\frac{ k e^{-k|x|} - e^{-|x|} }{ k^{2}-1 }
-
\frac{ k e^{-k|x|} }{ (k^2-1) }
+
k^{2} \frac{ e^{-|x|} }{ k^2-1 }
\\&\qquad
=
e^{-|x|}
.
\end{align*}
This is the desired differential equation.
\end{itemize}
\begin{comment}
We first note that the Fourier transform of $e^{-|x|}$ is given by
\begin{align*}
\mathcal F(e^{-|x|})(\omega) = \sqrt{\frac{2}{\pi}} \frac{1}{1+\omega^2}.
\end{align*}
Therefore, if $u(x)$ is a solution, then its Fourier transform $\hat u(\omega)$ satisfies
\begin{align*}
(\omega^2 + k^2) \hat u(\omega) = \sqrt{\frac{2}{\pi}} \frac{1}{1+\omega^2}.
\end{align*}
Therefore, if $k = 1$, then
\begin{align*}
\hat u(\omega) &= \sqrt{\frac{2}{\pi}} \frac{1}{(1+\omega^2)^2}\\
&= \mathcal{F}^{-1}(\frac{1}{2}(1 + |x|) e^{-|x|}).
\end{align*}
The last step can be seen from the results in the lecture.
Thus, it is clear that $u(x) = \frac 1 2 (1+|x|) e^{-|x|}$ is a solution. Furthermore,
For the case $k \neq 1$, note that
\begin{align*}
\mathcal{F}(e^{-k|x|})(\omega) = \sqrt{\frac{2}{\pi}} \frac{k}{k^2 + \omega^2}.
\end{align*}
Therefore, the Fourier transform of the solution $u(x)$ satisfies
\begin{align*}
(\omega^2 + k^2) \hat u(\omega) &= \sqrt{\frac{2}{\pi}} (k^2 + \omega^2) \left[ \frac{-1}{(k^2 + \omega^2)(k^2 - 1)} + \frac{1}{(\omega^2 + 1)(k^2 - 1)} \right]
\\
&= \sqrt{\frac{2}{\pi}} (k^2 + \omega^2) \left[ \frac{k^2 -1}{(\omega^2 + 1)(k^2 - 1)(k^2 + \omega^2)} \right]
\\
&= \sqrt{\frac{2}{\pi}} \frac{1}{(1 + \omega^2)},
\end{align*}
as desired. The argument for the general solution is the same as for the case $k=1$.
\end{comment}
\end{solution}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%% EXERCISE 6 %%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}
We want to find a solution to the boundary value problem
\begin{gather*}
- \Delta u(x) + k^2 u(x) = x, \quad 0 < x < L,
\\
u(0) = 0, \quad u(L) = 0.
\end{gather*}
\begin{itemize}
\item Extend the right-hand side $f(x) = x$ to an odd function with period $2L$ and compute its Fourier coefficients.
\item Using these coefficients, find the Fourier series of the solution $u$. Verify that the boundary condition $u(0) = u(L) = 0$ is satisfied.
\end{itemize}
\end{exercise}
\begin{solution}
\begin{itemize}
\item The odd extension of period 2 is simply given by
\begin{align*}
f_{\mathrm{odd}}(x) = x, \quad x \in [-L,L].
\end{align*}
\item
Since $f_{\mathrm{odd}}$ is odd by construction, we have
\begin{align*}
f_{\mathrm{odd}}(x) = \sum_{n=1}^{\infty} f_n \sin(\frac{n \pi x}{L}),
\end{align*}
with
\begin{align*}
f_n
=
\frac{2}{L} \int_{0}^{L} x \sin(\frac{n \pi x}{L}) \ dx
&
=
\frac{2}{L}
\left[ -x \frac{L}{n \pi} \cos\left( \frac{n \pi}{L} x \right) \right]_{x=0}^{x=L}
+
\frac{2}{L}
\int_{0}^{L} \frac{L}{n \pi} \cos\left( \frac{n \pi}{L} x \right) \ dx
\\&
=
\left[ -x \frac{2}{n \pi} \cos\left( \frac{n \pi}{L} x \right) \right]_{x=0}^{x=L}
+
\frac{2}{n \pi}
\int_{0}^{L} \cos\left( \frac{n \pi}{L} x \right) \ dx
\\&
=
\left[ -x \frac{2}{n \pi} \cos\left( \frac{n \pi}{L} x \right) \right]_{x=0}^{x=L}
+
\frac{2}{n \pi}
\left[ \left( \frac{L}{n \pi} \right) \sin\left( \frac{n \pi}{L} x \right) \right]_{x=0}^{x=L}
\\&
=
\left[ -x \frac{2}{n \pi} \cos\left( \frac{n \pi}{L} x \right) \right]_{x=0}^{x=L}
\\&
=
-L \frac{2}{n \pi} \cos\left( n \pi \right)
=
(-1)^{n+1}\frac{2L}{\pi n}
.
\end{align*}
\item
For the solution, we make a sine ansatz $u(x) = \sum_{n=1}^{\infty} u_n \sin(\frac{n \pi x}{L})$
because this satisfies the boundary conditions.
Then, the PDE can be written in terms of the Fourier coefficients as
\begin{align*}
\left[ k^2 + \left(\frac{\pi n}{L} \right)^2 \right] u_n = (-1)^{n+1}\frac{2L}{\pi n}, & & \forall n \in \mathbb{N}.
\end{align*}
Therefore, the solution is given by
\begin{align*}
u_n
=
(-1)^{n+1}\frac{2L}{\pi n}
\left[ k^2 + \left(\frac{\pi n}{L} \right)^2 \right]^{-1}
.
\end{align*}
\end{itemize}
\end{solution}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%% EXERCISE 7 %%%%%%%%%%%
%%%%% %%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{exercise}[Fun with Neumann boundary conditions]
Consider the Poisson problem with \textit{Neumann boundary conditions} over the interval $[a,b] = [0,1]$:
\begin{gather*}
- u''(x) + k^2 u(x) = x - \frac 1 2, \quad a < x < b,
\\
u'(a) = 0, \quad u'(b) = 0,
\end{gather*}
for some $k \geq 0$.
\begin{enumerate}[label=(\alph*)]
\item
Extend $f(x) = x - \frac 1 2$ to an \textit{even} function over the real line with period $2$.
\item
Compute the Fourier coefficients of that even extension of $f$.
\item
Find the Fourier series of a function that satisfies the above differential equation.
\end{enumerate}
\end{exercise}
\begin{solution}
\begin{itemize}
\item The even extension of period 2 is given by $f_{\text{even}}(x) = |x| - \frac 1 2, x \in [-1, 1]$.
\item Since $f_{\text{even}}$ is even by construction, we only have cosine terms, i.e.
\begin{align*}
f_{\text{even}}(x) = \frac{f_0}{2} + \sum_{n=1}^{\infty} f_n \cos(\pi n x)
.
\end{align*}
Here,
\begin{align*}
f_0 = \frac{1}{2} \int_{-1}^{1} (|x| - \frac 1 2) \ dx = \int_{-1}^1 (x - \frac 1 2) \ dx = 0
,
\end{align*}
and for any $n \geq 1$,
\begin{align*}
f_n
&
=
\int_{-1}^{1} (x- \frac 1 2) \cos(\pi n x) \ dx
\\&
=
2 \int_{ 0}^{1} (x- \frac 1 2) \cos(\pi n x) \ dx
=
2 \int_{ 0}^{1} x \cos(\pi n x) \ dx
=
\frac{2}{\pi^2 n^2}\left( (-1)^n - 1 \right) % OKAY 7
.
\end{align*}
\item
For the solution, we make a cosine ansatz
\begin{align*}
u(x) = u_0 + \sum_{n=1}^{\infty} u_n \cos(\pi n x)
\end{align*}
because the cosine modes satisfy the Neumann boundary conditions.
We have expressed the (even extension) of the right-hand side as a Fourier cosine series,
and therefore the PDE can be written in terms of the Fourier coefficients: