In short, OCaml uses different operators for integers and floats, i.e. ( *. )
instead ( * )
, (+.)
instead (+)
, etc. Also you should use 2.
instead of 2
to get "variable" of float type.
# let a_squared_b (a:float) (b:float) : float =
if(a<0. || b<0.)
then (a**2. +. b**2. +. 2. *. a*. b)
else (a**2. +. b**2. -. 2. *. a*. b);;
val a_squared_b : float -> float -> float = <fun>
# a_squared_b 2. 2.;;
More information you can get, for example, there