Assignment4_3.nim — James Ross - Assignment 4.3
runAssignment()
// James Ross — MTH220 Assignment 4.3
// Assignment 4.3
// Solve: x * sin(x) = 5
// Compiled from Nim to JavaScript:
nim js -o:assignment4_3.js assignment4_3.nim
// Funny... ECPI told me I NEEDED to take basic programming and couldn't skip
// it due to "experience"... lol ok
// Equation Setup
f
(
x
) =
x
* sin(
x
) − 5
f'
(
x
) = sin(
x
) +
x
* cos(
x
)
// xₐ₊₁ = xₐ − f(xₐ) / f'(xₐ)
// firstGuess (x₀)
// try: 8, 11, 14, 17, 20 to find all 5 roots
// decimalPlaces (10^-n)
// n=5 → 1e-5 tolerance
▶ Test
Iteration
x value
f(x) → 0
|Δx| → 0