eQuate It CAS UDFs — Calculus (TI-Nspire CAS) =============================================== 1. avgroc(f, x, lo, hi) — Average rate of change ------------------------------------------------------- Define avgroc(f, x, lo, hi) = Prgm Local result result := (f | x = hi) - (f | x = lo)) / (hi - lo) Disp "Average ROC on [", lo, ",", hi, "]: ", result EndPrgm 2. avgval(f, x, lo, hi) — Average value of a function ------------------------------------------------------- Define avgval(f, x, lo, hi) = Prgm Local result result := (1/(hi - lo)) * ∫(f, x, lo, hi) Disp "Average value on [", lo, ",", hi, "]: ", result EndPrgm 3. boundarea(f1, f2, x) — Area between two curves ------------------------------------------------------- Define boundarea(f1, f2, x) = Prgm Local pts, area, i, lo, hi pts := solve(f1 = f2, x) area := 0 Disp "Intersection points: ", pts If dim(pts) >= 2 Then For i, 1, dim(pts) - 1 lo := pts[i] hi := pts[i + 1] area := area + abs(∫(f1 - f2, x, lo, hi)) EndFor EndIf Disp "Total bound area: ", area EndPrgm 4. boundaread(f1, f2, x, lo, hi) — Area between curves in domain ------------------------------------------------------- Define boundaread(f1, f2, x, lo, hi) = Prgm Local area area := abs(∫(f1 - f2, x, lo, hi)) Disp "Bound area on [", lo, ",", hi, "]: ", area EndPrgm 5. intguess — Integral multiple choice solver ------------------------------------------------------- (Case 1: One integral given, find transformed integral) Define intguess(known, trans, target) = Prgm Local l1, u1, v1, l2, u2, result l1 := known[1] u1 := known[2] v1 := known[3] l2 := target[1] u2 := target[2] Disp "Known: integral from ", l1, " to ", u1, " = ", v1 Disp "Transformations: ", trans Disp "Target: integral from ", l2, " to ", u2 Disp "Use substitution and transformation rules" Disp "to determine the target integral value." EndPrgm 6. newtons(f, x, x0, n) — Newton's method ------------------------------------------------------- Define newtons(f, x, x0, n) = Prgm Local xi, i, fp xi := x0 fp := d(f, x) For i, 1, n xi := xi - (f | x = xi) / (fp | x = xi) Disp "Iteration ", i, ": x = ", approx(xi) EndFor Disp "Root approx: ", approx(xi) EndPrgm 7. nroot(poly, x, k, n) — Parameter values for n roots ------------------------------------------------------- Define nroot(poly, x, k, n) = Prgm Local disc, result Disp "Finding k for ", n, " roots" disc := discrim(poly, x) If n = 2 Then result := solve(disc > 0, k) ElseIf n = 1 Then result := solve(disc = 0, k) ElseIf n = 0 Then result := solve(disc < 0, k) EndIf Disp "k values: ", result EndPrgm 8. nstp(poly, x, k, n) — Parameter values for n stationary points ------------------------------------------------------- Define nstp(poly, x, k, n) = Prgm Local fp, disc, result fp := d(poly, x) Disp "f'(x) = ", fp disc := discrim(fp, x) If n = 2 Then result := solve(disc > 0, k) ElseIf n = 1 Then result := solve(disc = 0, k) ElseIf n = 0 Then result := solve(disc < 0, k) EndIf Disp "k for ", n, " stationary points: ", result EndPrgm 9. npoi(poly, x, k, n) — Parameter values for n points of inflection ------------------------------------------------------- Define npoi(poly, x, k, n) = Prgm Local fpp, disc, result fpp := d(d(poly, x), x) Disp "f''(x) = ", fpp disc := discrim(fpp, x) If n = 2 Then result := solve(disc > 0, k) ElseIf n = 1 Then result := solve(disc = 0, k) ElseIf n = 0 Then result := solve(disc < 0, k) EndIf Disp "k for ", n, " POI: ", result EndPrgm 10. pois(f, x) — Points of inflection ------------------------------------------------------- Define pois(f, x) = Prgm Local fpp, xvals, i, y fpp := d(d(f, x), x) xvals := solve(fpp = 0, x) Disp "f''(x) = ", fpp Disp "Points of inflection:" For i, 1, dim(xvals) y := f | x = xvals[i] Disp "(", xvals[i], ", ", y, ")" EndFor EndPrgm 11. signtab(f, x) — Sign table for stationary points ------------------------------------------------------- Define signtab(f, x) = Prgm Local fp, xvals, i, left, right, nature fp := d(f, x) xvals := solve(fp = 0, x) Disp "f'(x) = ", fp Disp "Stationary points at x = ", xvals For i, 1, dim(xvals) left := sign(fp | x = xvals[i] - 0.001) right := sign(fp | x = xvals[i] + 0.001) If left > 0 and right < 0 Then nature := "Local maximum" ElseIf left < 0 and right > 0 Then nature := "Local minimum" Else nature := "Stationary point of inflection" EndIf Disp "x = ", xvals[i], ": ", nature EndFor EndPrgm 12. stps(f, x) — Stationary points ------------------------------------------------------- Define stps(f, x) = Prgm Local fp, xvals, i, y fp := d(f, x) xvals := solve(fp = 0, x) Disp "f'(x) = ", fp Disp "Stationary points:" For i, 1, dim(xvals) y := f | x = xvals[i] Disp "(", xvals[i], ", ", y, ")" EndFor EndPrgm 13. tangsolve(f, x, x0, y0) — Tangent lines through a point ------------------------------------------------------- Define tangsolve(f, x, x0, y0) = Prgm Local fp, m, tang, eq, tvals fp := d(f, x) Disp "Finding tangent lines to f through (", x0, ",", y0, ")" tvals := solve(y0 - (f | x = t) = (fp | x = t) * (x0 - t), t) Disp "Tangent points at x = ", tvals For i, 1, dim(tvals) m := fp | x = tvals[i] tang := m * (x - tvals[i]) + (f | x = tvals[i]) Disp "y = ", tang EndFor EndPrgm 14. trapapprox(f, x, lo, hi, n) — Trapezoidal approximation ------------------------------------------------------- Define trapapprox(f, x, lo, hi, n) = Prgm Local h, s, i, xi h := (hi - lo)/n s := (f | x = lo) + (f | x = hi) For i, 1, n - 1 xi := lo + i*h s := s + 2*(f | x = xi) EndFor s := (h/2)*s Disp "h = ", h Disp "Trapezoid approx (", n, " strips): ", approx(s) Disp "Exact integral: ", approx(∫(f, x, lo, hi)) EndPrgm