(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) -2e+65)
(+ t_1 (/ t (* 3.0 (* z y))))
(if (<= (* z 3.0) 5e+14)
(+ t_1 (* (/ 0.3333333333333333 z) (/ t y)))
(fma
(/ t z)
(pow (* 3.0 y) -1.0)
(+ x (* y (/ -0.3333333333333333 z))))))))double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if ((z * 3.0) <= -2e+65) {
tmp = t_1 + (t / (3.0 * (z * y)));
} else if ((z * 3.0) <= 5e+14) {
tmp = t_1 + ((0.3333333333333333 / z) * (t / y));
} else {
tmp = fma((t / z), pow((3.0 * y), -1.0), (x + (y * (-0.3333333333333333 / z))));
}
return tmp;
}
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function code(x, y, z, t) t_1 = Float64(x - Float64(y / Float64(z * 3.0))) tmp = 0.0 if (Float64(z * 3.0) <= -2e+65) tmp = Float64(t_1 + Float64(t / Float64(3.0 * Float64(z * y)))); elseif (Float64(z * 3.0) <= 5e+14) tmp = Float64(t_1 + Float64(Float64(0.3333333333333333 / z) * Float64(t / y))); else tmp = fma(Float64(t / z), (Float64(3.0 * y) ^ -1.0), Float64(x + Float64(y * Float64(-0.3333333333333333 / z)))); end return tmp end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * 3.0), $MachinePrecision], -2e+65], N[(t$95$1 + N[(t / N[(3.0 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * 3.0), $MachinePrecision], 5e+14], N[(t$95$1 + N[(N[(0.3333333333333333 / z), $MachinePrecision] * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t / z), $MachinePrecision] * N[Power[N[(3.0 * y), $MachinePrecision], -1.0], $MachinePrecision] + N[(x + N[(y * N[(-0.3333333333333333 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;z \cdot 3 \leq -2 \cdot 10^{+65}:\\
\;\;\;\;t_1 + \frac{t}{3 \cdot \left(z \cdot y\right)}\\
\mathbf{elif}\;z \cdot 3 \leq 5 \cdot 10^{+14}:\\
\;\;\;\;t_1 + \frac{0.3333333333333333}{z} \cdot \frac{t}{y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{z}, {\left(3 \cdot y\right)}^{-1}, x + y \cdot \frac{-0.3333333333333333}{z}\right)\\
\end{array}
| Original | 3.6 |
|---|---|
| Target | 1.8 |
| Herbie | 0.8 |
if (*.f64 z 3) < -2e65Initial program 0.4
Taylor expanded in z around 0 0.4
if -2e65 < (*.f64 z 3) < 5e14Initial program 8.2
Applied egg-rr0.7
if 5e14 < (*.f64 z 3) Initial program 0.4
Applied egg-rr1.2
Applied egg-rr1.2
Applied egg-rr1.2
Final simplification0.8
herbie shell --seed 2022185
(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))))