gsl-ocaml / examples /

open Gsl

let f alpha x =
  Gc.major ();
  (log (alpha *. x)) /. (sqrt x)

let compute f expected =
  let ws = Integration.make_ws 1000 in
  let gslfun = f in
  let {Fun.res = res ;
       Fun.err = err } = Integration.qags gslfun 
      ~a:0. ~b:1. ~epsabs:0. ~epsrel:1e-7 ws in
  Printf.printf "result          = % .18f\n" res ;
  Printf.printf "exact result    = % .18f\n" expected ;
  Printf.printf "estimated error = % .18f\n" err ;
  Printf.printf "actual error    = % .18f\n" (res -. expected) ;
  Printf.printf "intervals = %d\n" (Integration.size ws)

let _ = 
  Error.init ();
  compute (f 1.0) (-4.)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.