1 (* =========================================================== *)
2 (* OCaml univariate functions *)
3 (* Author: Thomas C. Hales *)
5 (* =========================================================== *)
7 (* port of univariate.cc
8 a univariate represents a function u:real->real.
9 its first derivative du:real->real
10 and its second derivative ddu;real->real.
12 For example, if the function is x |-> x,
13 its derivative is x |-> 1,
14 and second derivative is x |-> 0,
15 which is implemented as ux1.
17 We give a few other examples, sqrt, 1/x, atan.
21 needs "verifier/interval_m/interval.ml";;
23 module Univariate = struct
28 let eval uni x = function
33 let mk_univariate (u1,du1,ddu1) = { u = u1; du = du1; ddu = ddu1; };;
35 let raise_zero x = bounded_from_zero x or raise Unstable ;;
37 (* here are a couple of examples *)
53 let _ = raise_zero x in
54 one / (two * isqrt x)),
57 let _ = raise_zero x in
58 ineg (one / ((two * isqrt x) * (two * x))))
66 let _ = raise_zero x in
70 let _ = raise_zero x in
71 ineg (one / ( x * x))),
74 let _ = raise_zero x in
89 let t = one / (one + x * x) in
90 (ineg two * x) * (t * t))
101 ineg (one / isqrt (one - x * x))),
103 let t = one - x * x in
104 ineg (x / isqrt (t * t * t)))