(FPCore (x y z t)
:precision binary64
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
↓
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y (* z 3.0)))))
(if (<= (* z 3.0) -5e+138)
(+ t_1 (* t (/ (/ 0.3333333333333333 z) y)))
(if (<= (* z 3.0) 5e-143)
(+ x (* (/ -0.3333333333333333 z) (- y (/ t y))))
(+ t_1 (/ t (* 3.0 (* y z))))))))
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
↓
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x - (y / (z * 3.0d0))
if ((z * 3.0d0) <= (-5d+138)) then
tmp = t_1 + (t * ((0.3333333333333333d0 / z) / y))
else if ((z * 3.0d0) <= 5d-143) then
tmp = x + (((-0.3333333333333333d0) / z) * (y - (t / y)))
else
tmp = t_1 + (t / (3.0d0 * (y * z)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
\[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y - \frac{t}{y}, x\right)}
\]
Proof
(fma.f64 (/.f64 -1/3 z) (-.f64 y (/.f64 t y)) x): 0 points increase in error, 0 points decrease in error
(fma.f64 (/.f64 (Rewrite<= metadata-eval (/.f64 -1 3)) z) (-.f64 y (/.f64 t y)) x): 0 points increase in error, 0 points decrease in error
(fma.f64 (Rewrite<= associate-/r*_binary64 (/.f64 -1 (*.f64 3 z))) (-.f64 y (/.f64 t y)) x): 29 points increase in error, 13 points decrease in error
(fma.f64 (/.f64 -1 (Rewrite<= *-commutative_binary64 (*.f64 z 3))) (-.f64 y (/.f64 t y)) x): 0 points increase in error, 0 points decrease in error
(Rewrite<= fma-def_binary64 (+.f64 (*.f64 (/.f64 -1 (*.f64 z 3)) (-.f64 y (/.f64 t y))) x)): 3 points increase in error, 1 points decrease in error
(+.f64 (Rewrite<= distribute-lft-out--_binary64 (-.f64 (*.f64 (/.f64 -1 (*.f64 z 3)) y) (*.f64 (/.f64 -1 (*.f64 z 3)) (/.f64 t y)))) x): 2 points increase in error, 1 points decrease in error
(+.f64 (-.f64 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 -1 y) (*.f64 z 3))) (*.f64 (/.f64 -1 (*.f64 z 3)) (/.f64 t y))) x): 5 points increase in error, 15 points decrease in error
(+.f64 (-.f64 (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 y)) (*.f64 z 3)) (*.f64 (/.f64 -1 (*.f64 z 3)) (/.f64 t y))) x): 0 points increase in error, 0 points decrease in error
(+.f64 (-.f64 (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 y (*.f64 z 3)))) (*.f64 (/.f64 -1 (*.f64 z 3)) (/.f64 t y))) x): 0 points increase in error, 0 points decrease in error
(+.f64 (-.f64 (neg.f64 (/.f64 y (*.f64 z 3))) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 -1 t) (*.f64 (*.f64 z 3) y)))) x): 19 points increase in error, 24 points decrease in error
(+.f64 (-.f64 (neg.f64 (/.f64 y (*.f64 z 3))) (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 t)) (*.f64 (*.f64 z 3) y))) x): 0 points increase in error, 0 points decrease in error
(+.f64 (-.f64 (neg.f64 (/.f64 y (*.f64 z 3))) (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 t (*.f64 (*.f64 z 3) y))))) x): 0 points increase in error, 0 points decrease in error
(+.f64 (Rewrite<= unsub-neg_binary64 (+.f64 (neg.f64 (/.f64 y (*.f64 z 3))) (neg.f64 (neg.f64 (/.f64 t (*.f64 (*.f64 z 3) y)))))) x): 0 points increase in error, 0 points decrease in error
(+.f64 (+.f64 (neg.f64 (/.f64 y (*.f64 z 3))) (Rewrite=> remove-double-neg_binary64 (/.f64 t (*.f64 (*.f64 z 3) y)))) x): 0 points increase in error, 0 points decrease in error
(Rewrite<= +-commutative_binary64 (+.f64 x (+.f64 (neg.f64 (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))))): 0 points increase in error, 0 points decrease in error
(Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 x (neg.f64 (/.f64 y (*.f64 z 3)))) (/.f64 t (*.f64 (*.f64 z 3) y)))): 0 points increase in error, 0 points decrease in error
(+.f64 (Rewrite<= sub-neg_binary64 (-.f64 x (/.f64 y (*.f64 z 3)))) (/.f64 t (*.f64 (*.f64 z 3) y))): 0 points increase in error, 0 points decrease in error
herbie shell --seed 2022291
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:precision binary64
:herbie-target
(+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))