(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))) (/ t (* y (* z 3.0))))))
(if (<= t_1 (- INFINITY))
(+ x (/ -0.3333333333333333 (* z (/ (- y) t))))
(if (<= t_1 1e+308)
t_1
(pow (sqrt (fma (/ -0.3333333333333333 z) (- y (/ t y)) x)) 2.0)))))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))) + (t / (y * (z * 3.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x + (-0.3333333333333333 / (z * (-y / t)));
} else if (t_1 <= 1e+308) {
tmp = t_1;
} else {
tmp = pow(sqrt(fma((-0.3333333333333333 / z), (y - (t / y)), x)), 2.0);
}
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(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(y * Float64(z * 3.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x + Float64(-0.3333333333333333 / Float64(z * Float64(Float64(-y) / t)))); elseif (t_1 <= 1e+308) tmp = t_1; else tmp = sqrt(fma(Float64(-0.3333333333333333 / z), Float64(y - Float64(t / y)), x)) ^ 2.0; 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[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x + N[(-0.3333333333333333 / N[(z * N[((-y) / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+308], t$95$1, N[Power[N[Sqrt[N[(N[(-0.3333333333333333 / z), $MachinePrecision] * N[(y - N[(t / y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]]]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x + \frac{-0.3333333333333333}{z \cdot \frac{-y}{t}}\\
\mathbf{elif}\;t_1 \leq 10^{+308}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt{\mathsf{fma}\left(\frac{-0.3333333333333333}{z}, y - \frac{t}{y}, x\right)}\right)}^{2}\\
\end{array}
| Original | 3.5 |
|---|---|
| Target | 1.8 |
| Herbie | 0.7 |
if (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < -inf.0Initial program 64.0
Simplified0.4
Taylor expanded in z around 0 0.7
Applied egg-rr0.4
Taylor expanded in y around 0 64.0
Simplified5.0
if -inf.0 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) < 1e308Initial program 0.5
if 1e308 < (+.f64 (-.f64 x (/.f64 y (*.f64 z 3))) (/.f64 t (*.f64 (*.f64 z 3) y))) Initial program 62.4
Simplified0.7
Applied egg-rr5.9
Final simplification0.7
herbie shell --seed 2022210
(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))))