(FPCore (x y z t) :precision binary64 (+ x (* (- y x) (/ z t))))
(FPCore (x y z t) :precision binary64 (if (<= z 1e+15) (fma (- y x) (/ z t) x) (fma z (pow (/ t (- y x)) -1.0) x)))
double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1e+15) {
tmp = fma((y - x), (z / t), x);
} else {
tmp = fma(z, pow((t / (y - x)), -1.0), x);
}
return tmp;
}
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) * Float64(z / t))) end
function code(x, y, z, t) tmp = 0.0 if (z <= 1e+15) tmp = fma(Float64(y - x), Float64(z / t), x); else tmp = fma(z, (Float64(t / Float64(y - x)) ^ -1.0), x); end return tmp end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[z, 1e+15], N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision] + x), $MachinePrecision], N[(z * N[Power[N[(t / N[(y - x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] + x), $MachinePrecision]]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, {\left(\frac{t}{y - x}\right)}^{-1}, x\right)\\
\end{array}
| Original | 2.0 |
|---|---|
| Target | 2.1 |
| Herbie | 1.8 |
if z < 1e15Initial program 1.7
Simplified1.7
if 1e15 < z Initial program 3.8
Simplified3.8
Taylor expanded in y around 0 17.3
Simplified1.9
Applied egg-rr2.3
Final simplification1.8
herbie shell --seed 2022182
(FPCore (x y z t)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
:precision binary64
:herbie-target
(if (< (* (- y x) (/ z t)) -1013646692435.8867) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) 0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))
(+ x (* (- y x) (/ z t))))