(*********************************************************)
(** * Definition of arccosine based on arctangent        *)
(*********************************************************)

(** acos is defined by cases so that it is defined in the full range from -1 .. 1 *)

Definition acos x :=
  if Rle_dec x (-1) then PI else
  if Rle_dec 1 x then 0 else
  PI/2 - atan (x/sqrt(1 - x²)).

(* Specifications: *)
Lemma acos_atan : forall x, 0 < x -> acos x = atan (sqrt (1 - x²) / x).
Lemma acos_asin : forall x, -1 <= x <= 1 -> acos x = PI/2 - asin x.
Lemma asin_acos : forall x, -1 <= x <= 1 -> asin x = PI/2 - acos x.
Lemma acos_0 : acos 0 = PI/2.
Lemma acos_1 : acos 1 = 0.
Lemma acos_opp : forall x, acos (- x) = PI - acos x.
Lemma acos_inv_sqrt2 : acos (/sqrt 2) = PI/4.
Lemma acos_bound : forall x, 0 <= acos x <= PI.
Lemma acos_bound_lt : forall x, -1 < x < 1 -> 0 < acos x < PI.
Lemma cos_acos : forall x, -1 <= x <= 1 -> cos (acos x) = x.
Lemma acos_cos : forall x, 0 <= x <= PI -> acos (cos x) = x.
Lemma sin_acos : forall x, -1 <= x <= 1 -> sin (acos x) = sqrt (1 - x²).
Lemma tan_acos : forall x, -1 <= x <= 1 -> tan (acos x) = sqrt (1 - x²) / x.
Lemma derivable_pt_acos : forall x, -1 < x < 1 -> derivable_pt acos x.
Lemma derive_pt_acos : forall (x : R) (Hxrange : -1 < x < 1), derive_pt acos x (derivable_pt_acos x Hxrange) = -1 / sqrt (1 - x²).
Lemma sin_gt_x x : x < 0 -> x < sin x.