# Ok to post #Eshaan Gandhi, 09/12/2020, Assignment 1 #1. Teach yourself Maple #A. 10/2; #I like to use a Semi colon for my understanding. Basic arithmetic 5 int(10*x, x); #I intergrate 10x with respect to x 2 5 x #Next I am going to write a procedure to multiply all 4 arguments lc := proc(s, u, t, v) description "multiply 4 arguments"; s*u*t*v; end proc; lc := proc (s, u, t, v) description "multiply 4 arguments"; s*u*t*v end proc lc(1, 2, 3, 4); 24 #End of answer to question 1 #2. Human Problem: Let F(n) be the set of lists using {1,2} that add-up to n. For example, F(0)={[]}, F(1)={[1]}, F(2)={[1,1],[2]}, F(3)={[1,1,1],[1,2],[2,1]}. Write down F(6). #F(6) = {[1,1,1,1,1,1], [1, 1, 1, 1, 2], [1, 1, 1, 2, 1], [1, 1, 2, 1, 1], [1, 2, 1, 1, 1], [2, 1, 1, 1, 1], [1, 1, 2, 2], [1, 2, 1, 2], [1, 2, 2, 1], [2, 1, 1, 2], [2, 1, 2, 1], [2, 2, 1, 1], [2, 2, 2]} #End of answer to question 2 3. #a. L2:=[op(L1), Mars] # convverts L1 to L2 #b. If m or n or both are negative there is no path to the goal as they are outside the manhattan grid so we initialize it to the empty set #c. If m=0 and n=0 there are no steps/walks needed to reach needed to reach the goal as they are already at the goal. #End of question 3 4. Write a Maple procedure: #ANS F := proc(n) local l1, ans, j, i; option remember; with(combinat); l1 := [seq(1, i = 1 .. n)]; ans := {op([l1])}; do if nops(l1) < 1/2*n + 1 then break; end if; l1 := [2, op(l1[1 .. nops(l1) - 2])]; ans := {op(permute(l1)), op(ans)}; end do; ans; end proc #This gives the same exact answer I got in question 2. Here is the output as generated by maple. {[2, 2, 2], [1, 1, 2, 2], [1, 2, 1, 2], [1, 2, 2, 1], [2, 1, 1, 2], [2, 1, 2, 1], [2, 2, 1, 1], [1, 1, 1, 1, 2], [1, 1, 1, 2, 1], [1, 1, 2, 1, 1], [1, 2, 1, 1, 1], [2, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]} #5. Another Maple procedure NuF := proc(n) local l1, ans, j, i; option remember; with(combinat); l1 := [n, 0]; ans := 0; do ans := ans + (l1[1] + l1[2])!/(l1[1]!*l1[2]!); l1[1] := l1[1] - 2; l1[2] := l1[2] + 1; if l1[1] = -2 or l1[1] = -1 then break; end if; end do; ans; end proc #nops(F(n))=NuF(n) are equal for n=1..10 #NuF(1000) = 70330367711422815821835254877183549770181269836358732742604905087154537118196933579742249494562611733487750449241765991088186363265450223647106012053374121273867339111198139373125598767690091902245245323403501 #Maple would complain a lot because F is actually calculating all the n number of permutations and then counting the number. This is a lot of permutations as one can see in the number above. That is why it would take a lot lot of time.