Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.81 KB | None | 0 0
  1. module A = Archimedes;;
  2. module R = Root_finding;;
  3. module G = Q2a;;
  4.  
  5. let f x = x *. x -. 2.;;
  6. let df x = 2. *. x;;
  7. let g x = x *. x *. x;;
  8. let dg x = 3. *. x *. x;;
  9. let h x = x *. x *. x *. x *. x;;
  10. let dh x = 5. *. x *. x *. x *. x;;
  11. let i x = cos x;;
  12. let di x = -. sin x;;
  13.  
  14. let graph_fonction root_fonction f df a b =
  15.   let tab = Array.make 20 0. in
  16.   for i=0 to 20 do
  17.     let a,b = root_fonction
  18.       ~good_enough:R.stop_iter ~max_iter:i f df a b in
  19.     Array.set tab i a
  20.   done;
  21.   tab;;
  22.  
  23. let graph_bissection f df a b =
  24.   graph_fonction (R.bissection) f df a b;;
  25.  
  26. let graph_fausse_position f df a b =
  27.   graph_fonction (R.fausse_position) f df a b;;
  28.  
  29. let graph_secante f df a b =
  30.   graph_fonction (R.secante) f df a b;;
  31.  
  32. let graph_newton f df a b =
  33.   graph_fonction (R.newton) f df a b;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement