# Please do not post homework # Matthew Esaia, 2/2/2025, Homework 2 # 4.1 Sequences print(`Section 4.1`); x := 1,2,3: y := 4,5,6: s := x,y: s[4]; f:='f': seq(f(i), i=1..6): seq(i^2, i=1..5): x := 'x': x$4: # $ is the repetition operator # 4.2 Sets # Order is not important print(`Section 4.2`); y:= 'y': {x,y,z,y}; a:={1,2,3,4}: b:={2,4,6,8}: a union b; a intersect b; a minus b; # 4.3 Lists # Order is important print(`Section 4.3`); s := seq( i/(i + 1), i=1..6): M := [s]; # 4.4 Tables print(`Section 4.4`); a := 'a': b := 'b': T := table([a,b]): T[2]; S := table([(1) = A, (3) = B + C, (5) = A * B * C]); S[3]; S; op(S); # 4.5 Arrays print(`Section 4.5`); A := array(1..2, 1..3, []); B := array(1..2, 1..2, 1..2); C := array(1..2, 1..2): C[1, 1] := 1: C[1, 2] := 2: C[2, 1] := 3: C[2, 2] := 7: op(C); # 4.6 Data Conversions # type() checks the type of an object # convert() converts an object to the specified type # 5.1 Defining functions print(`Section 5.1`); f := x -> x^2 - 3*x + 5; f(2); # 5.2 Composition of functions print(`Section 5.2`); (sin @ cos)(x); f := x -> x^2: g := x -> sqrt(1 - x): (f@g)(x); (g@f)(x); f@@(-1)(x): # 5.3 Summation and Product print(`Section 5.3`); f:='f': Sum(f(i), i = 1..n): Sum(i^2,i=1..10); value(%); sum(i^2,i=1..10); # Product works similarly # 5.4 Limits print(`Section 5.4`); Limit(f(x), x=a, right); # 5.5 Differentiation print(`Section 5.5`); f := sqrt(1-x^2): diff(f, x); g:= z -> z^2*exp(z) + sin(z): D(g); # 5.6 Extrema print(`Section 5.6`); maximize(sin(x) + cos(x)); minimize(x^2+y^2, x); # 5.7 Integration print(`Section 5.7`); Int(x^2/sqrt(1-x^3),x); value(%); # 5.7.1 Techniques of integration # changevar -> substitution # intparts -> integration by parts # 5.8 Taylor and series expansions print(`Section 5.8`); y := 1/sqrt(1-x); taylor(y, x=0,5); # 5.9 Solving differential equations print(`Section 5.9`); f:='f': y := f(x): dy := diff(y,x): ddy := diff(dy, x): dsolve(ddy + 5*dy + 6*y = sin(x)*exp(-3*x), y);