###########################################
1(a) Compute 15! using Do loop, While loop, For Loop with the help of Mathematica
fact = 1; n = 15;
Do[fact = fact*k, {k, n}]
fact
Out = 1307674368000
Clear[fact]
fact = 1; n = 15;
While[n > 0, fact = fact*n; n--]
fact
Out = 1307674368000
Clear[fact]
For[fact = 1; n = 1, n ≤ 15, n++, fact = fact*n]
fact
Out = 1307674368000
1(b) Prove that the following statements are logically equivalent using Mathematica command
lhs = p ∨ ¬(q ∧ r);
rhs = (p ∨ ¬q) ∨ ¬r;
LogicalExpand[lhs] == LogicalExpand[rhs]
Out = True
##################################
2(a)(i) Sum the following using Mathematica command
Sum[(2n-1)/(n(n+1)(n+2)), {n, 1, Infinity}]
Out = 3/4
2(a)(ii) Sum the following using Mathematica command
Sum[ArcCot[2m²], {m, 1, Infinity}] // FullSimplify
Out = π/4
2(b) Using Mathematica command, find from first principles the derivative of Sin[3x]
f[x_] = Sin[3x];
Limit[(f[x+h] - f[x])/h, h → 0]
Out = 3 Cos[3x]
###################################
3(a) Find the sum of the fourth power of roots of the equation x^4-x^3-7x^2+x+6=0
s = Solve[x^4 - x^3 - 7x^2 + x + 6 == 0, x];
Sum[s[[k, 1, 2]]^4, {k, 1, 4}]
Out = 99
3(b) Write Mathematica command to find all numbers less than 1500 which are both Prime and Fibonacci. Find also total such numbers
list1 = {}; i = 1; While[Prime[i] < 1500, list1 = Append[list1, Prime[i]]; i++]
list2 = {}; i = 1; While[Fibonacci[i] < 1500, list2 = Append[list2, Fibonacci[i]]; i++]
list3 = Intersection[list1, list2]
Length[list3]
Out = {2, 3, 5, 13, 89, 233}
Out = 6
############################################
(*4(a) Draw the graph and verify if f(x) is differentiable or not at x=1 and x=2*)
f[x_] := 5 x - 4 /; 0 < x <= 1
f[x_] := 4 x^2 - 3 x /; 1 < x < 2
f[x_] := 3 x + 4 /; x >= 2
Plot[f[x], {x, 0, 4}]
OUT= GRAPH BER HOBE
lhd = Limit[(f[x+h] - f[x])/h, h → 0, Direction → 1] /. x → 1
rhd = Limit[(f[x+h] - f[x])/h, h → 0, Direction → -1] /. x → 1
Out = 5
Out = 5
4(b) Write Mathematica code to verify the Cayley-Hamilton theorem for Matrix A
########################################
5(a) Write Mathematica code to find shortest distance between the lines
##########################################
(*Answer 6 (a)*)
Graphics[{EdgeForm[Thick], Blue, Opacity[0.2], Polygon[{{3, 4}, {1, 2}, {2, 0}}],
Opacity[1], Red, PointSize[Large], Point[{{3, 4}, {1, 2}, {2, 0}}],
Black, Text[Style["D(3,4)", 12, Bold], {3, 4}, {-1, -1}],
Text[Style["E(1,2)", 12, Bold], {1, 2}, {1, 1}],
Text[Style["F(2,0)", 12, Bold], {2, 0}, {0, 1}]},
Axes True, GridLines Automatic, PlotRange {{0, 5}, {-1, 5}}]
OUT=GRAPH BER HOBE TRIANGLE ER
(*Answer 6 (b)*)
over = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
runs = {9, 3, 5, 7, 12, 10, 10, 7, 11, 16};
BarChart[runs, ChartLabels over, LabelingFunction Above, ChartStyle "Pastel"]
OUT=CHART BER HOBE
##################################################
7(a) Evaluate the triple integral
\!\(
\*SubsuperscriptBox[\(\[Integral]\), \(-1\), \(1\)]\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(2\)]\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(1\)]\((
\*SuperscriptBox[\(x\), \(2\)] +
\*SuperscriptBox[\(y\), \(2\)] +
\*SuperscriptBox[\(z\), \(2\)])\) \[DifferentialD]x \[DifferentialD]y \
\[DifferentialD]z\)\)\)
(*7(b) GCD and LCM of polynomials*)
p = 2 x^4 - 15 x^3 + 39 x^2 - 40 x + 12;
q = 4 x^4 - 24 x^3 + 45 x^2 - 29 x + 6;
a = PolynomialGCD[p, q]
out= -6 + 17 x - 11 x^2 + 2 x^3
b = PolynomialLCM[p, q]
out= (-2 + x) (6 - 29 x + 45 x^2 - 24 x^3 + 4 x^4)
Expand[a*b] == Expand[p*q]
out=True
#########################
(*8(a) Show vectors form a right angle triangle*)a = 3 i - 2 j + k;
b = i - 3 j + 5 k;
c = 2 i + j - 4 k;
u1 = 3; u2 = -2; u3 = 1;
v1 = 1; v2 = -3; v3 = 5;
w1 = 2; w2 = 1; w3 = -4;
u = {u1, u2, u3};
v = {v1, v2, v3};
w = {w1, w2, w3};
If[u.Cross[v, w] == 0,
Print["The given vectors form the side of a right angle triangle"]]
(*8(b) Table:radian equivalents 0\[Degree] to 180\[Degree] step 15\
\[Degree]*)
lst = Table[{deg, N[deg Degree]}, {deg, 0, 180, 15}];
TableForm[lst, TableDirections -> Column,
TableHeadings -> {None, {"Degree", "Radian"}},
TableSpacing -> {1, 5}]
out= ekta table ber hobe
