open Impact let redLine(a, b ,m, xlen) = let mutable x = a-xlen let mutable xend = a+xlen let mutable y = b-xlen*m while (x < xend) do dot(x,y) red x <- x + 0.5 y <- y + m*0.5 dot(a,b) black clear() let f(x) = 2.0**x let fprime(x,h) = (f(x+h) - f(x)) / h //x <- 0.0 //uncomment these 4 lines to graph f(x) in pink //while x < 200.0 do // dot(x,f(x)) pink // x <- x + 1.0 h <- 0.001 x <- 0.0 while (x < 200.0) do //dot(x,fprime(x,h)*10.0) red //uncomment this line to graph f'(x) in red dot(x,10.0*fprime(x,h)/f(x)) green //ratio f(x)/f'(x), scaled up by factor of 10 m <- fprime(x,h) //redLine(x,f(x),m,h*2.0) //uncomment these 2 lines to plot the tangent lines //dot(x,f(x)) black x <- x + 1.0