Mathematica Solution
Mathematica Solution
Mathematica Solution
Solutions to Exercises
This appendix provides solutions to selected exercises in Chapters 2 and 3.
Section 2.1.20
1. (10 Sqrt[(10.8 × 10^3)/300] + 4)^(1/3)
11. θ = N [ArcCos[2/3]/Degree]
Tan [θ Degree]^2
21. ourdata = {{0.5, 4.2}, {1.0, 16.1}, {1.5, 35.9}, {2.0, 64.2}}
Fix [ourdata, {t^2}, t]
2 × 16.0328ft/s^2
CleaR [ourdata]
23. data = {{0.1, 1.1}, {0.3, 3.2}, {0.5, 4.9}, {0.7, 6.8}, {0.9, 9.1}}
Fit [data, {x}, x]
9.98182 1b/in
41. (a^3) NItegrate [Sqrt [x^2 + y^2], {x, –1, 0}, {y, –Sqrt [1 –x^2], 0}]
45. NDSolve [{y '' [x] + (Sin [x]^2y' [x] + 3y[x]^2 == Exp [–x^2],
y[0] == 1, y' [0] == 0}, y, {x, 0, 3}
Table [y [x] /. %[[1]], {x, 3}]
Plot [Evaluate [y[x] /. %%], {x, 0, 3}, AxesLabel → {"x", "y"}]
Section 2.2.20
1. Apart [ (x^2 + 2x –1) / (2x^3 + 3x^2 –2x)]
19. Simplify [(Sec [α] – 2 Sin [α]) (Csc[α] + 2 Cos [α]) Sin [α] Cos[α]]
23. TrigFactor [(Sin [x] ^3) Sin [3x] + cos[x]^3) Cos [3x]] // Simplify
27. FullSimplify [Sec [x] Tan [x] (sec[x] + Tan[x] + (Sec[x] – Tan[x])]
29. Simplify [ (Sec[x] – Csc[x]) / (tan[x] + Cot [x]) == (Tan [x] – Cot [x]) / (Sec [x]
39. Simplify [Sin[nπ – θ], ((n – 1/2) /2) ∊ Integrs] Table [2 k + 1/2, {k, –10, 10}]
55.
65. P = n R T/V
Dt [P, t, Constants → {n, R}]
% /. {Dt [T, t, Constants → {n, R}] → α,
Dt [V, t, Constants → {n, R}] → β} // Simplify
Clear [P]
73. Integrate [ (x^2) Exp [–2 a x^2], {x, –∞, ∞}, Assumptions → a > 0]
85. Limit [
Log[10, x – a] / ((a – b) (a – c)) + Log[10, 2 (x – b)] / ((b – c) (b –
Log [10, x – c] / ((c – a) (c – b)), x → ∞] // FullSimplify
87. Limit [1/ (Exp[x] – Exp[x – x^ (–2)]), x → ∞]
99. FourierTransform [Piecewise [{{–A, –b, < x < 0}, {A, 0 < x < b}}],
x, –k, Assumptions → b > 0] //FullSimplify
3. sol =
NDSolve [{y'' [t] == – (t^3) y [t] + 1, y[0] == 1, y' [0] == 0}. {t, 0
Plot [Evaluate [y[t] /. sol], {t, 0, 8}, AxesLabel → {"t", "y"}]
Clear [sol]
5. n = 5;
sol = NDSolve[{ψ '' [ξ] + (– ξ2 + 2n + 1) ψ [ξ] == 0,
ψ[0] == 0, ψ' [0] == 1}, ψ, {ξ –5, 5]
{ψ[–5], ψ[5]}/. sol [[1]]
Plot [Evaluate [ψ[ξ]/. sol], {ξ, –5, 5}, AxesLabel - > {"ξ", "ψ"}]
Clear [n, sol]
Plot [1/ (1 + Exp[1/t]), {t, 0, 4}, AxesLabel → {"T (€/k)", "E (€)"}]
2. The heat capacity C is
D[E, T]
Let
c = C/k
t = kT/€
Thus,
k Log[Z] + E/T
Let
s = S/k
t = kT/€
Thus,
23.
25. ClockPane [Plot [ {Abs [(Sin[x] –x) /Sin[x]], 0.01}, {x, 0, 03.}],
(xycoord = #) &]
FindRoot [Abs [(Sin[x] – x) /Sin[x]] == 0.01, {x, xycoord[[1]]}]
% [[1, 2]]/Degree
Clear [xycoord]
ClickPane [Plot [{Abs [(Sin [x] – x)/Sin[x]], 0.005}, {x, 0, 0.2}],
(xycoord = #) &]
FindRoot [Abs[(Sin [x] – x) /Sin[x]]] == 0.005, {x, xycoord [[1]]}]
%[[1, 2]]/Degree
Clear[xycoord]
31. data = {{0, 1}, {0.1, 1.05409}, {0.2, 1.11803}, {0.3, 1.19523},
{0.4, 1.29099}, {0.5, 1.41421}, {0.6, 1.58114},
{0.7, 1.82574}, {0.8, 2.23607}, {0.9, 3.16228}};
Fit [data, {1, x, x2, x3}, x]
Plot [%, {x, 0, 1}, AxesLabel → {"x", "f(x)"}]
ListPlot[data, PlotStyle → PointSize[0.02],
AxesLabel → {"x", "f(x)"}]
Show [%, %%]
Clear [data]
35.
37. Do [vdP = NDSolve[{x' [t] == v[t], v'[t] == 0.5(–x[t]^2)v[t] – x[t],
v[0] == 0, x[0] == i}, {x, v}, {t, 0, 50}];
Print [ParametricPlot [Evaluate [{x[t], v[t]}/ .vdP],
{t, 0, 7π}, AxesLabel → {"x", "v"}]], {i, 1, 3, 0.5}]
Clear[vdP]
39. Plot 3D[x^2 + y^2, {x, –2, 2}, {y, –2, 2},
BoxRatios - > {1, 1, 1}, AxesLael - > {"x", "y", "z"}]
43. Plot3D[x(y^2) –x^3, {x, –2, 2}, {y, –2, 2}, BoxRations → {1, 1, 1},
Boxed → False, Axes → False, ViewPoint → {–0.060, 3.354, 0.447}]
47. ListAnimate [Table [Plot 3D [(t + x) ((x^2) – 3 (y^2)), {x, –2, 2},
{y, –2, 2}, BoxRations → {1, 1, 1}, PlotRange → {–150, 150},
Boxed → False, Axes → False], {t –12, 12, 1}]]
53. g[i_] : =
Plot[
{Exp [–16 (x - i) ^2] + 1.5 Exp [–(x + i) ^2],
1.5 Exp [– (x + i) ^2] + 3, Exp [–16 {x – i) ^2] + 5}, {x, –3.0, 3.0},
PlotStyle → {{Thickness [0.01], Black},
{Thickness[0.005], Red}, {Thickness [0.005], Blue}},
PlotRange → {–0.1, 6.25}, Axes → False,
Frame - > True, FrameTicks - > None]
Grid [Partotopm [Table [g [i], {i, –2.0, 3.5, 0.5}], 3]]
Clear [g]
Section 2.4.12
1. RandomInteger[20, {5, 5}]
% // MatrixForm
15. mylist = {a, {d, {e, {f, {g, h}}}}, {{i, {j, k}}, {p, q, {r, s}}}}
Position [mylist, {g, h}]
Position [mylist, {r, s}]
FlattenAt {mylist, {{2, 2, 2,2}, {3, 2, 3}}]
Clear [mylist]
31. T = {15, 20, 25, 30, 40, 50, 60, 70, 80, 90,
100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
210, 220, 230, 240, 250, 260, 270, 280, 290, 298.1};
Cp = {0.311, 0.605, 0.858, 1.075, 1.452, 1.772, 2.084,
2.352, 2.604, 2.838, 3.060, 3.254, 3.445, 3.624, 3.795,
3.964, 4.123, 4.269, 4.404, 4.526, 4.639, 4.743, 4.841,
4.927, 5.010, 5.083, 5.154, 5.220, 5.286, 5.350, 5.401};
Integrate [Interpolation [Transpose [{T, Cp/T}]] [x], {x, 15, 298.1}]
Clear [T, Cp]
35. data = {{0.46, 0.19}, {0.69, 0.27}, {0.71, 0.28}, {1.04, 0.62},
{1.11, 0.68}, {1.14, 0.70}, {1.14, 0.74}, {1.20, 0.81},
{1.31, 0.93}, {2.03, 2.49}, {2.14, 2.73}, {2.52, 3.57},
{3.24, 3.90}, {3.46, 3.55}, {3.81, 2.87}, {4.06, 2.24},
{4.93, 0.65}, {5.11, 0.39}, {5.26, 0.33}, {5.38, 0.26}};
FindFit [data, a1 Exp[–(1/2) (((x – a2) /a3)^2)], {a1, a2, a3}, x]
Thus, a1, = 3.97924, a2 = 2.99725, and a3 = 1.00152.
Show [ListPlot [data, PlotStyle - > PointSyze [0.025]],
Plot [Evaluate [a1 Exp [–(1/2) (((x –a2) /a3) ^2)]/.%], {x, 0, 6}],
AxesLabel → {"x", "y"}]
Clear [data]
43. 1. Let us begin with the assignment for the list of numbers of decays observed in 1 min
dpm = {9, 11, 15, 16, 19, 22, 24}
For each number of decays observed in 1 minute, there is a number of times observe
numbers of times observed is
freq = {2, 2, 2, 1, 1, 1, 1}
and the list of fractional numbers of times observed is
frac = freq/Total [freq]
The best estimate of the mean number of decays in 1 minute is the sample mean:
μ = Total [dpmfrac] // N
The best estimate of the standard deviation is
NumberForm [Sqrt [μ], 2]
The best estimate of the standard deviation of the mean σ is given by
μ
49. data =
Import [" /2nd Edition 2008/ApGTM2ND/OurFolder/ACDC.txt", "Table"]
mydata = Drop [data, 9]
func[x_] : = Take [x, {2, 13}]
ourdata = func/@mydata
newdata = ourdata // Flatten
concentration = interpolation [newdata]
Plot [concentration [x], {x, 1, 480},
Axes → False, Frame → True, FrameTicks →
{{Automatic, Automatic}, {Transpose [{Table [i, {i, 1, 433, 72}],
Table [1964 + i, {i, 1, 37, 6}]}], Automatic}},
FrameLabel → {"Year", "Concentration (ppm)"}]
Clear [data, mydata, func, ourdata, newdata, concentration]
Section 2.5.4
1.
1.
2.
3.
4.
5.
6. T = {15, 20, 25, 30, 40, 50, 60, 70, 80, 90,
7. 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
8. 210, 220, 230, 240, 250, 260, 270, 280, 290, 298.1};
9. Cp = {0.311, 0.605, 0.858, 1.075, 1.452, 1.772, 2.084,
10. 2.352, 2.604, 2.838, 3.060, 3.254, 3.445, 3.624, 3.795,
11. 3.964, 4.123, 4.269, 4.404, 4.526, 4.639, 4.743, 4.841,
12. 4.927, 5.010, 5.083, 5.154, 5.220, 5.286, 5.350, 5.401};
where C is the capital script c.
3.
1.
2.
5.
7.
(a)
(b) Solve [∂r % == 0, r] [[4]]]
9.
and cos φ = 1. Thus, the average power delivered by the source at resonance can be w
We have avoided making assignments for XL and XC because L and Calready have ass
{XL,Xc}
Using transformation rules allows us to bypass this difficulty.
Clear [C, L, R, Subscript, OverBar]
Section 3.1.4
1. 1. x – y // FullForm
2. x^2/y^2//Fullform
3. {a, {b, {c, d}}, {e, f}}//FullForm
4. (a + Ib) / (c – Id) // FullForm
5. Integrate [x^2, x] // Hold// FullForm
6. DSolve[y'' [x] – 3y' [x] – 18y[x] == x Exp[4x], y[x], x] // Hold// Fullform
7. f[a] + g[c, d]/ .f[x_] → x^3//Hold//FullForm
8. Sin/@ (a + b + c) // Hold //FullForm
9. CrossProduct [a, CrossProduct [b, c]] +
10. CrossProduct [b, CrossProduct [b, c]] +
11. CrossProduct [c, CrossProduct [a, b]] // FullForm
3. complexConjugate [expr_] : = (expr /. Complex [x_, y_] → Complex [x, –y])
For example,
ComplexConjudgate [(a + b)/ (c – d)^2]
Clear [complexConjugate]
5.
13.
15.
21. yourlist = {{a, {b, c}}, {d, {e, {f, {g, h}}}}, {{i, j}, k}};
1. FlattenAt [yourlist, Position [yourlist, {g, h}]]
2. Flatten [yourlist, 2]
Clear [yourlist]
23. t = {15, 20, 25, 30, 40, 50, 60, 70, 80, 90,
100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
210, 220, 230, 240, 250, 260, 270, 280, 290, 298.1};
cp = {0.311, 0.605, 0.858, 1.075, 1.452, 1,772, 2.084,
2.352, 2.604, 2.838, 3.060, 3.254, 3.445, 3.624, 3.795,
3.964, 4.123, 4.269, 4.404, 4.526, 4.639, 4.743, 4.841,
4.927, 5.010, 5.083, 5.154, 5.220, 5.286, 5.350, 5.401};
1. cp/t
2. f [x_, y_] : = x/y
Thread [f [cp, t]]
Clear[cp, t, f]
25.
29.
31.
Here is another way to do this:
Section 3.2.9
1.
ClearAll [vectorClassify]
7. Cases [{a, {a}, {a, a}, {b, c}, {d, {e, f}}, {Sin [ax], Sin [ax]},
{a, a, a}, {Sin [bx], Tan [cx]}}, {x_, y_}/; x = ! = y, Infinity]
9.
ClearAll [ourfunc]
23.
Section 3.3.7
1. 1. f[x_] : = 1 + x^3
2. ClearAll[f]
3. func [x_] : = {x, x2}
4. ClearAll [func]
5. my f [z_] : z/. x → y
6. ClearAll [myf]
7. g[x_, y_] : = 1/xy
8. ClearAll [g]
9. h[x_, y_, z_] : = (x, y^z)
10. ClearAll[h]
11. myg[y_] : = – D [y, x]
12. ClearAll [myg]
13. g[y_] : = y3
14. f[x_] : = g/@x
15. ClearAll [g, f]
16. hisf [x_] : = Apply [And, Map [OddQ, x]]
17. ClearAll [hisf]
18. herf [x_] : = Delete [x, RandomInteger [{1, Length [x]}]]
19. ClearAll [herf]
9. Needs ["VectorAnalysis'"]
CoordinateSystem
Coordinates []
SetCoordinates [Cartesian [x, y, z]]
A = {Ax [x, y, z], Ay [x, y, z], Az [x, y, z]};
B = {Bx [x, y, z], By [x, y, z], Bz [x, y, z]};
15. 1. m = 3. 00 10–3;
2. b = 0. 0300;
3. g = 9.8;
4. vT = –gm/b
The terminal speed is 0.98 m/s. Ninety-nine Percent of the terminal speed is 0.9702 m
Abs [%]0.99
5. t[0] = 0;
6. x[0] = 0;
7. v[0] = 0;
8. a[n_] : = a[n] = –g– (b/m)v[n]
9. Δt = 0.005;
10. t[n_] : = t[n] = t [n – 1] + Δt
11. v[n_] : = v[n] = v [n – 1] + a[n – 1] Δt
12. x[n_] : = x[n] = x [n – 1] + v[n – 1] Δt
13. velocity = Table [v[n], {n, 0, 90}];
14. time = Table [t[n], {n, 0, 90}];
15. ListPlot [Transpose [{time, velocity}],
16. AxesLabel → {"time (s)", "velocity (m/s)"}]
17. position = Table [x[n], {n, 0, 90}];
18. ListPlot [Transpose [{time, position}],
19. AxesLael → {"time(s)", "position (m)"}]
20. TableForm [Transpose [{time, position, velocity}], TableHeadings →
21. {None, {"Time (s)", "Position (m)", "Velocity (m/s)"}]
22. ClearAll [m, b, g, vT, t, x, v, a, Δt, velocity, time, position]
23.
Note that there are discrepancies between the results of Euler’s method and NDSolve. Decre
size would improve the accuracy of the Euler method solution.
19.
1. The point x = 0 is a stable fixed point when the map parameter μ is less than 1/2:
21. 1.
The head of is Power rather than Sqrt. Thus, the additional rules associated with
apply to .
2.
Section 3.4.6
1. Single-clause definition:
scf [x_] : = If [x ≥ 0, x, –x]
Another single-clause definition:
anotherscf [x_] : = Piecewise [{{x, x ≥ 0}, {–x, x < 0}}]
Multiclause definition:
mcf [x_/ ; x ≥ 0] : = x
mcf [x_/ ; x < 0] : = –x
Derivative of f at 0:
∂x {scf[x], anotherscf[x], mcf[x]}/ .x → 0
The answer 1 for scf' [0] is wrong because f is not differentiable at 0, and we cannot find
multiclause definition.
ClearAll [scf, anotherscf, mcf]
3. 1. scV[x_] : =
2. Which [x < –2 || –1 ≤ x < 1, 0, –2≤x < –1, –2, 1≤x < 3, –1, x ≥ 3, 1]
3. anotherscV [x_] : = Piecewise [{{0, x < –2 || –1 ≤ x < 1},
4. {–2, –2 ≤ x < –1}, {–1, 1 ≤ x < 3}, {1, x ≥ 3}}]
5. mcV [x_/ ; x < –2 || –1 ≤ x < 1] : = 0
6. mcV [x_/ ; –2 ≤ x < –1] : = –2
7. mcV [x_/ ; 1 ≤ x < 3] : = –1
8. mcV [x_/ ; x ≥ 3] : = 1
9. Plot [scV[x], {x, –4, 4}, AxesLabel → {"x(a)", "V(b)"}]
10. Plot [anotherscV[x], {x, –4, 4}, AxesLabl → {"x (a)", "V (b)"}]
11. Plot [mcV[x], {x, –4, 4}, AxesLabel → {"x (a)", "V(b)"}]
12. ClearAll [scV, anotherscV, mcV]
7.
9. 1. Options [binomialExpansion] = {caption → False, exponent → 2};
2.
3. binomialExpansion [x_Symbol, y_Symbol, opts_ _ _Rule] : =
4. Module [{caption, exponent},
5. Print[{opts}];
6. Print [Options [binomial Expansion]];
7. Print [caption];
8. Print [exponent];
9. caption = caption/ . {opts}/. Options [binomialExpansion];
10. exponent = exponent/. {opts]/. Options [binomialExpansion];
11. Print [caption] ;
12. Print [exponent];
13. If [caption = = = True, Print ["Expansion of ", (x + y)exponent]];
14. Expand [(x + y)exponent]]
15.
16. binomialExpansion [a, b]
17.
18. binomialExpansion [a, b, caption → True, exponent → 10]
Within Module, caption and exponent are declared local variables and, thus,
become caption$n and exponent$n. In the evaluation of caption = caption/ . {opts}/
Options[binomialExpansion] and exponent = exponent/ . {opts}/. Options [binomial
caption$n and exponent$n do not match the (unaltered) option
names caption and exponent in {opts} and OPtions [binomial Expansion] and therefo
unchanged because the option rules do not apply.
ClearAll [binomialExpansion]
19. ClearAll ["Global' *"]
20. Options [binomialExpansion] = {Caption → False, exponent → 2};
21. binomialExpansion [x_Symbol, y_Symbol, opts _ _ _Rule] : =
22. Module [{cap, exp},
23. cap = caption/. {opts}/. Options[binomialExpansion];
24. exp = exponent/. {opts}/. Options [binomialExpansion];
25. If [cap = = = True, Print ["Expansion of ", (x + y)exp]];
26. Expand [(x + y)exp]]
27.
28. binomialExpansion[a, b]
29.
30. binomialExpansion [a, b, exponent → 10, caption → True]
Here, the local variables are cap and exp rather than caption and exponent.
ClearAll [binomialExpansion]
13.
1.
2. (* name the options and specify their default values *)
3. Options [newmotion1DPlot] =
4. {PositionPlot → True,
5. velocityPlot → True,
6. accelerationPlot → True,
7. combinationPlot → True,
8. positionAFLabel → {"t (s)", "x (n)"},
9. velocityAFLabel → {"t (s)", "v(m/s"},
10. accelerationAFLabel → {"t (s)", "a (m/s2)"},
11. combinationAFLabel → {"t (s)", None}};
12.
13. newmotion1DPlot [
14. eqn_/ ; Head [eqn] == Equal,
15. x0_/ ; (NumberQ[x0] && Im [x0] == 0),
16. v0_/ ; (NumberQ[v0] && Im [v0] == 0),
17. tmax_/ ; (NumberQ [tmax] && Im [tmax] == 0 && Positive [tmax]),
18. opts _ _ _ Rule]:=
19. Module [
20. {(* declare local variables *)
21. sol, corves ={}, plotx, plotv, plota,
22.
23. (* determine option values and assign
24. them as initial values to local variables *)
25. position = positionPlot/. {opts}/. Options [newmotion1Dplot],
26. velocity = velocityPlot/. {opts}/. Options [newmotion1DPlot],
27. acceleration = accelerationPlot/. {opts}/.
28. Options [newmotion1DPlot], combination =
29. combinationPlot/. {opts}/. Options [newmotion1DPlot],
30. positionLabel = positionAFLabel/. {opts}/.
31. Options [newmotion1DPlot], velocityLabel =
32. velocityAFLabel/. {opts}/. Options [newmotion1DPlot],
33. accelerationLabel = accelerationAFLable/. {opts}/.
34. Options [newmotion1DPlot], combinationLabel =
35. combinationAFLabel/. {opts}/. Options [newmotion1DPlot],
36.
37.
38. (* select vaild options for Plot and Show and
39. assign them as initial values to local variables *)
40. optPlot = Sequence @@FilterRules [{opts}, Options [Plot]],
41. optShow = Sequence @@FilterRules [{opts}, Options [Graphics]]},
42.
43. (* set text of a warning message *)
44. newmotion1DPlot : : argopt =
45. "Each of the values for the options positionPlot,
46. velocityPlot, accelerationPlot, and
47. combinationPlot must be either True or False.";
48.
49. (* verify option specifications *)
50. If [Count [{position, velocity,
51. acceleration, combination}, True |False] = ! = 4,
52. Message [newmotion1DPlot: : argopt]; Return [$Failed]];
53.
54. (* solve the equation of motion numberically *)
55. sol = NDSolve [{eqn, x[0] == x0, x' [0] == v0}, x, {t, 0, tmax}];
56. (* plot position vs. time *)
57. If [position,
58. Plotx = Plot [Evaluate [x [t]/. sol], {t, 0, tmax},
59. PlotLabel → "position vs. time", AxesLabel → positionLabel,
60. Ticks → Automatic, FrameLabel → positionLabel,
61. FrameTicks → Automatic, Evaluate [optPlot],
62. PlotRange → All, Axes → False, Frame → True];
63. Print [plotx];
64. AppendTo [curves, plotx]];
65.
66. (* plot velocity vs. time *)
67. If[velocity,
68. plotv = Plot [Evaluate [x' [t]/. sol],
69. {t, 0, tmax}, PlotLabel → "velocity vs. time",
70. AxesLabel → velocityLabel, Ticks → Automatic,
71. FrameLabel → velocityLabel, FrameTicks → Automatic,
72. Evaluate [optPlot], PlotStyle → Dashing [{0.03, 0.03}],
73. PlotRange → All, Axes → False, Frame → True];
74. Print [plotv];
75. AppendTo [curves, plotv]];
76.
77. (* plot acceleration vs. time *)
78. If [acceleration,
79. plota = Plot [Evaluate [(eqn [[2]])/. sol], {t, 0, tmax},
80. PlotLabel → "acceleration vs. time",
81. Axeslabel → accelerationLabel, Ticks → Automatic,
82. FrameLabel → accelerationLabel, FrameTicks → Automatic,
83. Evaluate [optPlot], PlotStyle → RGBColor [1, 0, 0],
84. PlotRange → All, Axes → False, Frame → True];
85. Print [plota];
86. AppendTo [curves, plota]];
87.
88. (* combine the plots *)
89. If [(combination) && (Length [curves] > 1),
90. Show [curves,
91. PlotLabel → "combination", Axeslabel → combinationLabel,
92. Ticks → {automatic, None}, FrameLabel → combinationLabel,
93. FrameTicks → {Automatic, None}, optShow]]
94. ]
95.
96. newmotion1DPlot [eqn_, x0_, v0_, tmax_, opts _ _ _ Rule]: =
97. (newmotion1DPlot: : argtype =
98. "One or more arguments entered are of the wrong type." ;
99. Message [newmotion1DPlot: :argtype]; Return [$Failed])
100.
101. ClearAll [newmotion1DPlot]
Section 3.5.4
1.
5. Graphics [
{{Green, Polygon [{{0, 10}, {5, 16}, {10, 10}}],
Polygon [{{1, 15}, {5, 21}, {9, 15}}],
Polygon [{{2, 20}, {5, 25}, {8, 20}}]},
Rectangle [{4.5, 5}, {5.5, 10}],
{Red, Rectangle [{2, 2}, {8, 5}]},
Text [Style ["Merry x' mas",
FontFamily → "Times", 14, Yellow], {5, 3.35}]}]
7.
1.
2.
Section 3.6.4
1.
scores = {52, 80, 59, 44, 67, 53, 59, 50, 56, 69, 70, 58, 68, 79,
70, 55, 66, 76, 73, 50, 68, 57, 59, 59, 52, 59, 45, 63, 56, 70, 47,
55, 54, 64, 78, 48, 48, 56, 74, 45, 62, 58, 54, 57, 77, 45, 91, 61,
49, 39, 46, 65, 52, 62, 50, 65, 58, 51, 59, 60, 62, 57, 46, 57, 57,
56, 51, 48, 69, 67, 61, 66, 73, 61, 53, 44, 66, 62, 47, 58, 52, 69,
59, 58, 57, 70, 81, 50, 74, 49, 56, 62, 78, 71, 56, 62, 53, 55, 51};
distribution [scores]
5. For an illustration, drop only five elements and use the values:
s0 = 0.2; μmin = 2.9; μmax = 3.0; Δ = 0.01; nmax = 10;
Here is the dissection:
NestList [
(# + Δ) &,
μmin,
Round [(μmax – μmin) /Δ]
]
%( #(1 – #))
Map [Function, %]
Map [NestList [#, x0, nmax] &, %]
Map [Drop [#, 5] &, %]
NestList [
(# + Δ) &,
μmin,
Round [(μmax – μmin)/Δ]
]
7. Unprotect [NonCommutativeMultiply];
A_ ** U: = A
U ** A_ : = A
A_ ** (B_ + C_) : = A ** B + A ** C
(A_ + B_) ** C : = A ** C + B ** C
number3Q[x_, y_, n_] : = NumberQ[x] && NumberQ[y] && NumberQ[n]
A_ ** (B_(x_. y_ ^n_./ ; number3Q[x, y, n])) : = ((xy^n) A ** B)
(A_ (x_. y_^n_./ ; number3Q[x, y, n])) ** B_ : = ((xy^n) A ** B)
Protect [NonCommutativeMultiply];
commutator [A_, B_] : = A ** B – B ** A
NumberQ[ћ] ^ = True;
xp3DCommutator [expr_] : =
ExpandAll [expr //. {px ** x :→ x ** px – ћ u, py ** y : → y ** py – ћ
pz ** z : → z ** pz – ћ u, x ** y : → y ** x, x ** z : → z **x,
y ** z : → z ** y, py ** x : → x ** py, pz ** x : → x ** pz, px ** y : →
pz ** y : → y ** pz, px ** z : → z ** px, py ** z : → z ** py,
px ** py : → py ** px, px ** pz : → pz ** px, py ** pz : → pz ** py}]
lx = y ** pz – z ** Py;
ly = z ** px – x ** pz;
lz = X ** py – y ** px;
(commutator [lx, ly] – ћ lz == 0) // xp3DCommutator
(commutator [ly, lz] – ћ lx == 0) // xp3DCommutator
(commutator [lz, lx] – ћ ly == 0) // xp3DCommutator
(commutator [lz, lx ** lx + ly ** ly + lz ** lz] == 0) // xp3DCommutator
ClearAll [number 3Q, commutator, ћ, ex3DCommutator, Subscript]
Section 3.7.5
5. BeginPackage ["HarmonicOscillator'"]
HarmonicOscillator: : usage =
"HarmonicOscillator' is a package that provides
functions for the eigenenergies and normalized energy
eigenfunctions of the simple harmonic oscillator."
φ: :quannum =
"The quantum number must be a nonnegative integer. your
quantum number '1' is not allowed."
ε: :badarg =
"The argument must be a nonnegative integer. You entered '1'."
End[]
Protect [φ, ε]
EndPackage[]
Copy
Add Highlight
Add Note
https://www.safaribooksonline.com/library/view/a-physicists-guide/9780126831924/apc.html