Ans.
1(a):
s = 0;
Do[s = s + i^2, {i, 1, 41, 2}]
s
out: 12341
a = 0;
For[j = 1, j <= 41, j = j + 2, a = a + j^2;]
a
out: 12341
b = 0;
k = 1;
While[k <= 41, b = b + k^2; k = k + 2 ]
b
out: 12341
Ans. 1(b):
a = ( {{1, 2, 1, 17},{1, 4, -3, 21},{2, 2, 3, 3}} );
d = a[[ All, {1, 2, 3}]]
out: {{1, 2, 1}, {1, 4, -3}, {2, 2, 3}}
dx = a[[All, {4, 2, 3}]]
out: {{17, 2, 1}, {21, 4, -3}, {3, 2, 3}}
dy = a[[All, {1, 4, 3}]]
out: {{1, 17, 1}, {1, 21, -3}, {2, 3, 3}}
dz = a[[All, {1, 2, 4}]]
out: {{1, 2, 17}, {1, 4, 21}, {2, 2, 3}}
x = Det[dx]/Det[d]
out: -32
y = Det[dy]/Det[d]
out: 20
z = Det[dz]/Det[d]
out: 9
Ans. 2(a)
?Plot
Plot[f, {x, xmin, xmax}] generates a plot of f as a function of x from xmin to
xmax. Plot[{f1, f2, ... }, {x, xmin, xmax}] plots several functions fi. More\
[Ellipsis]
?ImplicitPlot
Information::notfound: Symbol ImplicitPlot not found. More\[Ellipsis]
?Factor
Factor[poly] factors a polynomial over the integers. Factor[poly, Modulus->p]
factors a polynomial modulo a prime p. Factor[poly, Extension->{a1, a2, ... }]
factors a polynomial allowing coefficients that are rational combinations of the
algebraic numbers ai. More\[Ellipsis]
?Expand
Expand[expr] expands out products and positive integer powers in expr. Expand[expr,
patt] leaves unexpanded any parts of expr that are free of the pattern patt. More\
[Ellipsis]
?Simplify
Simplify[expr] performs a sequence of algebraic and other transformations on expr,
and returns the simplest form it finds. Simplify[expr, assum] does simplification
using assumptions. More\[Ellipsis]
Ans. 2(b)
s = 0;
Do[s = s + (n^2)*4^n/((n + 1)*(n + 2)), {n, 1, 150}]
s // N
out: 2.66244*10^90
b = 0;
Do[b = b + ArcCot[2*j^2], {j, 1, 5000}]
b // N
out: 0.785298
Ans. 3(a)
f[1] = 1
f[2] = 1
f[n_] := f[n - 1] + f[n - 2]
f[4]
out: 1
out: 1
out: 3
f[31] // Timing
out: {3.25 Second, 1346269}
f[31]
out: 1346269
Ans. 3(b)
s = {};
k = 1;
j = 1;
s1 = {};
While[Prime[k] <= 22, s = Append[s, Prime[k]]; k++]
While[j <= 22, s1 = Append[s1, j]; j++]
s1;
s;
t = Complement[s1, s];
TableForm[{s, t}]
out: 2, 3, 5, 7, 11, 13, 17, 19
1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22
Ans. 4(a)
f[x_] = x^4 - 24 x^2 - 13 x + 35;
f[x + h] // Expand
out: 35 - 13 h - 24 h^2 + h^4 - 13 x - 48 h x + 4 h^3 x - 24 x^2 + 6 h^2 x^2 + 4 h
x^3 + x^4
Coefficient[f[x + h], x^2]
out: -24 + 6 h^2
Solve[6 h^2 - 24 == 0]
out: {{h -> -2}, {h -> 2}}
f[x] /. x -> (x + 2) // Expand
out: -71 - 77 x + 8 x^3 + x^4
Ans. 4(b)
<< Calculus`VectorAnalysis`
X = {6 x*y + z^3, 3 x^3 - z, 3 x*z^2 - y};
Curl[ X, Cartesian[x, y, z]]
out: {0, 0, -6 x + 9 x^2}
Solve[9 x^2 - 6 x == 0]
out: {{x -> 0}, {x -> 2/3}}
Div[X, Cartesian[x, y, z]]
out: 6 y + 6 x z
Solve[6 y + 6 x*z == 0]
out: {{y -> -x z}}