- Solve a quadratic equation, exact and decimal
- Study a function: derivative and table of values
- A fractions word problem
- Probability of at least two sixes
- A cubic from its roots: expand, factor, study
- Solve a right triangle and its six trig ratios
- A class test: mode, frequency table, two variances
- Arithmetic, geometric and harmonic means
- Rounding, truncating and the sign of negative numbers
- Simplify an expression, then solve with roots
Solve a quadratic equation, exact and decimal
Solve 3x^2 - 5x - 4 = 0: discriminant, exact roots, decimal roots rounded to 4 places, and a numerical check.
#1. Discriminant of 3x^2 - 5x - 4 = 0; -> "[a]" 3; -> "[b]" -5; -> "[c]" -4; -> "[delta]" (math calc "[b]^2-4*[a]*[c]"); #2. Exact roots; -> "[exact]" (cas solve "3*x^2-5*x-4 = 0" "x"); #3. Decimal roots; -> "[x1]" (math calc "(-[b]-sqrt([delta]))/(2*[a])"); -> "[x2]" (math calc "(-[b]+sqrt([delta]))/(2*[a])"); concat "delta = " [delta] " > 0, two roots: " [exact] " ~ " (math round [x1] 4) " and " (math round [x2] 4) "; check: " (num poly_roots "[-4, -5, 3]")
delta = 73 > 0, two roots: [{"x":"1\/6*(5-sqrt(73))"},{"x":"1\/6*(5+sqrt(73))"}] ~ -0.5907 and 2.2573; check: ["-0.5906672908862551","2.257333957552922"]- Factor the left side with
cas factor - With a negative discriminant,
num poly_rootsgives the complex roots
Study a function: derivative and table of values
For f(x) = x^3 - 3x^2 - 9x + 5, compute f'(x), find where it vanishes, and build the table of values on [-3, 5] to draw the variations.
#1. f and its derivative; -> "[f]" "x^3-3*x^2-9*x+5"; -> "[df]" (math diff [f] "x"); #2. Where f' = 0; -> "[crit]" (cas solve (concat [df] " = 0") "x"); #3. Table of values from -3 to 5; concat "f'(x) = " [df] "; f' = 0 for " [crit] "; table: " (num table [f] "x" -3 5 1)
f'(x) = 3*x^2 - 6*x - 9; f' = 0 for [{"x":"-1"},{"x":"3"}]; table: [
[-3,-22],
[-2,3],
[-1,10],
[0,5],
[1,-6],
[2,-17],
[3,-22],
[4,-15],
[5,10]
]- Find the three roots of f with
num poly_roots"[5, -9, -3, 1]" - Draw the curve with
plot function
A fractions word problem
Lily eats 1/4 of a pizza, then Tom eats 2/5 of what is left. Which fraction did Tom eat, and what part of the pizza remains (as a fraction and a percentage)?
#1. Lily eats 1/4 of the pizza; -> "[rest]" (arith frac_sub 1 "1/4"); #2. Tom eats 2/5 of the rest; -> "[tom]" (arith frac_mul "2/5" [rest]); #3. What is left; -> "[left]" (arith frac_sub [rest] [tom]); concat "Tom ate " [tom] " of the pizza, " [left] " is left = " (math calc (concat [left] "*100")) " %"
Tom ate 3/10 of the pizza, 9/20 is left = 45 %
- Turn a decimal answer back into a fraction with
arith to_fraction - Put fractions on the same denominator with
arith lcm
Probability of at least two sixes
A die is thrown 5 times. Compute P(at least two sixes) as an exact fraction with combinations, then check it with the binomial law.
#1. 5 throws of a die, X = number of sixes. P of 0 and of 1 six, as exact fractions; -> "[p0]" (arith frac_mul (arith ncr 5 0) "3125/7776"); -> "[p1]" (arith frac_mul (arith ncr 5 1) "625/7776"); #2. At least two sixes; -> "[p]" (arith frac_sub 1 (arith frac_add [p0] [p1])); #3. Decimal value and check with the binomial law; concat "P(X >= 2) = " [p] " = " (math round (math calc [p]) 4) "; check with the binomial law: " (math calc (concat "1-" (stat dist_cdf "binomial" "[5, 0.16666666666666666]" 1)))
P(X >= 2) = 763/3888 = 0.1962; check with the binomial law: 0.1962448559670782
- Get P(X = 2) directly with
stat dist_pdf - Simulate 1000 series of throws with
stat dist_random
A cubic from its roots: expand, factor, study
Build p(x) = (x-1)(x-2)(x+3) from its roots, check the expansion and the factorisation with the CAS, find the critical points (decimal and exact), the area between the roots 1 and 2, and where the curve meets the line y = 6 - x.
#1. Is the CAS available on this server; -> "[cas]" (json load select "rx_cas" (cas status) /installed); #2. Cubic with roots 1, 2 and -3, coefficients from x^0 upwards; -> "[p]" (num poly_mul (num poly_mul "[-1, 1]" "[-2, 1]") "[3, 1]"); -> "[expanded]" (cas expand "(x-1)*(x-2)*(x+3)"); -> "[factored]" (cas factor "x^3-7*x+6"); #3. Critical points: roots of p prime, decimal then exact; -> "[crit]" (num poly_roots (num poly_derive [p])); -> "[critx]" (cas solve "3*x^2-7 = 0" "x"); #4. Area under the x axis between the roots 1 and 2; -> "[P]" (num poly_integrate [p]); -> "[area]" (math calc (concat "abs(" (num poly_eval [P] 2) "-(" (num poly_eval [P] 1) "))")); #5. Intersections with the line y = 6 - x: roots of p - line; -> "[inter]" (num poly_roots (num poly_add [p] "[-6, 1]")); concat "{\"cas\": " [cas] ", \"p\": " [p] ", \"expanded\": \"" [expanded] "\", \"factored\": \"" [factored] "\", \"critical_x\": " [crit] ", \"critical_exact\": " [critx] ", \"area_1_2\": " [area] ", \"meets_line_at\": " [inter] "}"
{"cas": true, "p": [6,-7,0,1], "expanded": "6-7*x+x^3", "factored": "(-2+x)*(-1+x)*(3+x)", "critical_x": ["-1.5275252316519465","1.5275252316519465"], "critical_exact": [{"x":"-sqrt(7\/3)"},{"x":"sqrt(7\/3)"}], "area_1_2": 0.75, "meets_line_at": ["-2.449489742783178","0","2.449489742783178"]}- Draw p and the line with
plot functionand a JSON array of two expressions. cas solve "x^3-7*x+6 = 6-x" "x"gives the exact intersections.
Solve a right triangle and its six trig ratios
A ladder reaches 12 m up a wall with its foot 5 m from the wall. Find its length, the angle with the ground in degrees, and check the six ratios sin, cos, tan, csc, sec, cot of that angle (13, 5, 12 triangle).
#1. Legs of the triangle in m; -> "[a]" 5; -> "[b]" 12; -> "[L]" (math hypot [a] [b]); #2. Angle with the ground, atan2 of opposite and adjacent; -> "[t]" (math atan2 [b] [a]); -> "[deg]" (math round (math rad_to_deg [t]) 2); #3. The six ratios, expected 12/13 5/13 12/5 13/12 13/5 5/12; concat "length = " [L] " m, angle = " [deg] " deg, same with atan 12/5: " (math round (math rad_to_deg (math atan 2.4)) 2) "; sin = " (math round (math sin [t]) 4) ", cos = " (math round (math cos [t]) 4) ", tan = " (math round (math tan [t]) 4) ", csc = " (math round (math csc [t]) 4) ", sec = " (math round (math sec [t]) 4) ", cot = " (math round (math cot [t]) 4)
length = 13 m, angle = 67.38 deg, same with atan 12/5: 67.38; sin = 0.9231, cos = 0.3846, tan = 2.4, csc = 1.0833, sec = 2.6, cot = 0.4167
- Ask the class to explain why atan2 is safer than atan when the adjacent side is negative or zero.
- Use
arith to_fractionon the ratios to get 12/13, 5/13...
A class test: mode, frequency table, two variances
Twenty pupils got marks out of 10. Build the frequency table with cumulative frequencies, find the mode, the mean and the median, and compare the population variance (divide by n) with the sample variance (divide by n - 1).
-> "[m]" "[7, 5, 8, 6, 7, 9, 4, 7, 6, 8, 5, 7, 10, 6, 7, 8, 3, 6, 7, 9]"; #1. Sorted marks and frequency table; -> "[sorted]" (math order_double [m]); -> "[freq]" (stat frequency [m]); #2. Centre and spread; -> "[pv]" (stat pvariance [m]); -> "[sv]" (stat variance [m]); concat "sorted: " [sorted] "; mode = " (stat mode [m]) ", mean = " (math avg [m]) ", median = " (stat median [m]) ", population variance = " [pv] ", sample variance = " [sv] ", ratio = " (math calc "[sv]/[pv]") " = 20/19; table " [freq]
sorted: [3.0,4.0,5.0,5.0,6.0,6.0,6.0,6.0,7.0,7.0,7.0,7.0,7.0,7.0,8.0,8.0,8.0,9.0,9.0,10.0]; mode = [7], mean = 6.75, median = 7, population variance = 2.7875, sample variance = 2.9342105263157894, ratio = 1.0526315789473684 = 20/19; table [
{"value": 3, "count": 1, "frequency": 0.05, "cumulative_count": 1, "cumulative_frequency": 0.05},
{"value": 4, "count": 1, "frequency": 0.05, "cumulative_count": 2, "cumulative_frequency": 0.1},
{"value": 5, "count": 2, "frequency": 0.1, "cumulative_count": 4, "cumulative_frequency": 0.2},
{"value": 6, "count": 4, "frequency": 0.2, "cumulative_count": 8, "cumulative_frequency": 0.4},
{"value": 7, "count": 6, "frequency": 0.3, "cumulative_count": 14, "cumulative_frequency": 0.7},
{"value": 8, "count": 3, "frequency": 0.15, "cumulative_count": 17, "cumulative_frequency": 0.85},
{"value": 9, "count": 2, "frequency": 0.1, "cumulative_count": 19, "cumulative_frequency": 0.95},
{"value": 10, "count": 1, "frequency": 0.05, "cumulative_count": 20, "cumulative_frequency": 1}
]- Read the median on the cumulative_frequency column: the first mark where it reaches 0.5.
- Draw the marks with
plot histogram.
Arithmetic, geometric and harmonic means
Three classic problems: a round trip at 60 then 40 km/h (harmonic mean), an investment growing +10 %, +50 %, -20 % (geometric mean of the factors), and the inequality AM >= GM >= HM on the same numbers.
#1. Round trip: the average speed is the harmonic mean; -> "[v]" "[60, 40]"; -> "[hm]" (stat harm_mean [v]); #2. Yearly growth factors; -> "[f]" "[1.10, 1.50, 0.80]"; -> "[gm]" (stat geo_mean [f]); -> "[gm2]" (math nroot (math calc "1.10*1.50*0.80") 3); #3. AM, GM, HM of the factors; concat "speed: AM = " (math avg [v]) " km/h is wrong, HM = " (math round [hm] 2) " km/h; growth: GM = " (math round [gm] 5) " = cube root " (math round [gm2] 5) " so " (math round (math calc "([gm]-1)*100") 2) " % a year, not " (math round (math calc (concat "(" (math avg [f]) "-1)*100")) 2) "; AM " (math avg [f]) " >= GM " (math round [gm] 4) " >= HM " (math round (stat harm_mean [f]) 4)
speed: AM = 50.0 km/h is wrong, HM = 48 km/h; growth: GM = 1.09696 = cube root 1.09696 so 9.7 % a year, not 13.33; AM 1.1333333333333335 >= GM 1.097 >= HM 1.0617
- Prove AM >= GM for two numbers with (sqrt a - sqrt b)^2 >= 0.
- Use
stat weighted_meanfor a trip with different distances.
Rounding, truncating and the sign of negative numbers
A lesson on rounding: compare floor, ceil, trunc, rint (round half to even) and round on 2.5, 3.5 and -2.7, take the fractional part, and the sign functions.
-> "[x]" -2.7; #1. Four ways to get an integer from -2.7; -> "[r1]" (concat "floor " (math floor [x]) ", ceil " (math ceil [x]) ", trunc " (math trunc [x]) ", round " (math round [x] 0)); #2. Ties: rint rounds half to even, banker's rounding; -> "[r2]" (concat "rint 2.5 = " (math rint 2.5) ", rint 3.5 = " (math rint 3.5) ", round 2.5 = " (math round 2.5 0)); #3. Fractional part keeps the sign; -> "[r3]" (concat "frac_part -2.7 = " (math frac_part [x]) ", frac_part 3.14 = " (math frac_part 3.14)); concat [r1] "; " [r2] "; " [r3] "; sign -2.7 = " (math sign [x]) ", signum 0 = " (math signum 0)
floor -3, ceil -2, trunc -2, round -3; rint 2.5 = 2, rint 3.5 = 4, round 2.5 = 3; frac_part -2.7 = -0.7, frac_part 3.14 = 0.14; sign -2.7 = -1, signum 0 = 0
- Explain why banker's rounding avoids a bias when summing many rounded values.
- Compare with
math round_sigfor significant figures.
Simplify an expression, then solve with roots
Simplify x^2*x + 3*x^3 - x*x^2 + 0*y, evaluate it at x = 2, then solve 3x^3 = 81 with a cube root and x^5 = 7776 with a fifth root, checking with powers.
#1. Simplify; -> "[e]" (math simplify "x^2*x+3*x^3-x*x^2+0*y"); -> "[v]" (math eval [e] "{\"x\": 2}"); #2. 3x^3 = 81 so x = cube root of 27; -> "[x1]" (math cbrt (math calc "81/3")); #3. x^5 = 7776; -> "[x2]" (math nroot 7776 5); concat "simplified: " [e] ", value at 2 = " [v] "; 3x^3 = 81 gives x = " [x1] ", check 3*x^3 = " (math calc (concat "3*" (math power [x1] 3))) "; x^5 = 7776 gives x = " [x2] ", check " (math power [x2] 5) "; the real cube root of -8 is " (math nroot -8 3)
simplified: 3*x^3, value at 2 = 24; 3x^3 = 81 gives x = 3, check 3*x^3 = 81; x^5 = 7776 gives x = 6, check 7776; the real cube root of -8 is -2
cas factorcan factor the polynomial before solving.- Show that an even root of a negative number has no real value.
