let rec v_recip v = match v with
|N i -> v_recip (R (float_of_int i))
|R f -> if f = 0. then fail else return_R (1./.f)
|Vec (size, vec) -> make_vector size (fun i -> v_recip (vec i))
|Zero -> fail
|W -> return_R 0.