needs "../formal_lp/formal_interval/m_taylor_old.hl";;
needs "../formal_lp/formal_interval/m_examples_poly.hl";;

(******************************)
(* Test 1 *)

let pp = 4;;

let poly_tm = lv_poly;;
let x_tm, z_tm = lv_dom;;

let n = (get_dim o fst o dest_abs) poly_tm;;
let xx1, zz1 = convert_to_float_list pp false x_tm, convert_to_float_list pp true z_tm;;


let dom_th = mk_m_center_domain n pp xx1 zz1;;
let eval = eval_m_taylor_poly0 pp poly_tm;;
let eval_old = M_taylor_old.eval_m_taylor_poly0 pp poly_tm;;

let t_th = eval pp pp dom_th;;
let t_th_old = eval_old pp pp dom_th;;

let bound = eval_m_taylor_upper_bound n pp t_th;;
let bound_old = M_taylor_old.eval_m_taylor_upper_bound n pp t_th_old;;

let p1 = eval_m_taylor_partial_upper n pp 1 t_th;;
let p1_old = M_taylor_old.eval_m_taylor_upper_partial n pp 1 t_th_old;;

let p_bounds = map (fun i -> eval_m_taylor_partial_bound n pp i t_th) (1--n);;
let p_bounds_old = map (fun i -> M_taylor_old.eval_m_taylor_interval_partial n pp i t_th_old) (1--n);;


(* 10: 0.764 *)
test 100 (mk_m_center_domain n pp xx1) zz1;;

(* 10: 1.148 *)
test 100 (eval pp pp) dom_th;;
(* 10: 1.148 *)
test 100 (eval_old pp pp) dom_th;;

(* 10: 0.744 *)
test 100 (eval_m_taylor_upper_bound n pp) t_th;;
(* 10: 1.168 *)
test 100 (M_taylor_old.eval_m_taylor_upper_bound n pp) t_th_old;;

(* 10: 0.204 *)
test 100 (eval_m_taylor_partial_upper n pp 1) t_th;;
(* 10: 0.252 *)
test 100 (M_taylor_old.eval_m_taylor_upper_partial n pp 1) t_th_old;;

(* 10: 0.944 *)
test 100 (map (fun i -> eval_m_taylor_partial_bound n pp i t_th)) (1--n);;
(* 10: 1.176 *)
test 100 (map (fun i -> M_taylor_old.eval_m_taylor_interval_partial n pp i t_th_old)) (1--n);;



(******************************)
(* Test 2 *)

let pp = 4;;

let poly_tm = butcher_poly;;
let x_tm, z_tm = butcher_dom;;

let n = (get_dim o fst o dest_abs) poly_tm;;
let xx1, zz1 = convert_to_float_list pp false x_tm, convert_to_float_list pp true z_tm;;


let dom_th = mk_m_center_domain n pp xx1 zz1;;
let eval = eval_m_taylor_poly0 pp poly_tm;;
let eval_old = M_taylor_old.eval_m_taylor_poly0 pp poly_tm;;

let t_th = eval pp pp dom_th;;
let t_th_old = eval_old pp pp dom_th;;

let bound = eval_m_taylor_upper_bound n pp t_th;;
let bound_old = M_taylor_old.eval_m_taylor_upper_bound n pp t_th_old;;

let p1 = eval_m_taylor_partial_upper n pp 1 t_th;;
let p1_old = M_taylor_old.eval_m_taylor_upper_partial n pp 1 t_th_old;;

let p_bounds = map (fun i -> eval_m_taylor_partial_bound n pp i t_th) (1--n);;
let p_bounds_old = map (fun i -> M_taylor_old.eval_m_taylor_interval_partial n pp i t_th_old) (1--n);;


(* 10: 1.400 *)
test 100 (mk_m_center_domain n pp xx1) zz1;;

(* 10: 1.644 *)
test 100 (eval pp pp) dom_th;;
(* 10: 1.680 *)
test 100 (eval_old pp pp) dom_th;;

(* 10: 1.516 *)
test 100 (eval_m_taylor_upper_bound n pp) t_th;;
(* 10: 2.428 *)
test 100 (M_taylor_old.eval_m_taylor_upper_bound n pp) t_th_old;;

(* 10: 0.300 *)
test 100 (eval_m_taylor_partial_upper n pp 1) t_th;;
(* 10: 0.408 *)
test 100 (M_taylor_old.eval_m_taylor_upper_partial n pp 1) t_th_old;;

(* 10: 1.988 *)
test 100 (map (fun i -> eval_m_taylor_partial_bound n pp i t_th)) (1--n);;
(* 10: 2.560 *)
test 100 (map (fun i -> M_taylor_old.eval_m_taylor_interval_partial n pp i t_th_old)) (1--n);;



(******************************)
(* Test 3 *)

let pp = 10;;

let poly_tm = heart_poly;;
let x_tm, z_tm = heart_dom;;

let n = (get_dim o fst o dest_abs) poly_tm;;
let xx1, zz1 = convert_to_float_list pp false x_tm, convert_to_float_list pp true z_tm;;


let dom_th = mk_m_center_domain n pp xx1 zz1;;
let eval = eval_m_taylor_poly0 pp poly_tm;;
let eval_old = M_taylor_old.eval_m_taylor_poly0 pp poly_tm;;

let t_th = eval pp pp dom_th;;
let t_th_old = eval_old pp pp dom_th;;

let bound = eval_m_taylor_upper_bound n pp t_th;;
let bound_old = M_taylor_old.eval_m_taylor_upper_bound n pp t_th_old;;

let p1 = eval_m_taylor_partial_upper n pp 1 t_th;;
let p1_old = M_taylor_old.eval_m_taylor_upper_partial n pp 1 t_th_old;;

let p_bounds = map (fun i -> eval_m_taylor_partial_bound n pp i t_th) (1--n);;
let p_bounds_old = map (fun i -> M_taylor_old.eval_m_taylor_interval_partial n pp i t_th_old) (1--n);;


(* 10: 2.368 *)
test 100 (mk_m_center_domain n pp xx1) zz1;;

(* 10: 9.977 *)
test 100 (eval pp pp) dom_th;;
(* 10: 9.756 *)
test 100 (eval_old pp pp) dom_th;;

(* 10: 3.920 *)
test 100 (eval_m_taylor_upper_bound n pp) t_th;;
(* 10: 6.124 *)
test 100 (M_taylor_old.eval_m_taylor_upper_bound n pp) t_th_old;;

(* 10: 0.572 *)
test 100 (eval_m_taylor_partial_upper n pp 1) t_th;;
(* 10: 0.664 *)
test 100 (M_taylor_old.eval_m_taylor_upper_partial n pp 1) t_th_old;;

(* 10: 5.024 *)
test 100 (map (fun i -> eval_m_taylor_partial_bound n pp i t_th)) (1--n);;
(* 10: 6.336 *)
test 100 (map (fun i -> M_taylor_old.eval_m_taylor_interval_partial n pp i t_th_old)) (1--n);;