(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ z (- a z)))
(t_2 (/ y (- a z)))
(t_3 (+ x (/ (* (- y z) (- t x)) (- a z)))))
(if (<= t_3 -4e-296)
(fma (/ (- t x) (- a z)) y (+ x (* z (/ (- x t) (- a z)))))
(if (<= t_3 0.0)
(- t (/ (* (- t x) (- y a)) z))
(+ (* x t_1) (- (fma t (- t_2 t_1) x) (* x t_2)))))))double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = z / (a - z);
double t_2 = y / (a - z);
double t_3 = x + (((y - z) * (t - x)) / (a - z));
double tmp;
if (t_3 <= -4e-296) {
tmp = fma(((t - x) / (a - z)), y, (x + (z * ((x - t) / (a - z)))));
} else if (t_3 <= 0.0) {
tmp = t - (((t - x) * (y - a)) / z);
} else {
tmp = (x * t_1) + (fma(t, (t_2 - t_1), x) - (x * t_2));
}
return tmp;
}
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function code(x, y, z, t, a) t_1 = Float64(z / Float64(a - z)) t_2 = Float64(y / Float64(a - z)) t_3 = Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) tmp = 0.0 if (t_3 <= -4e-296) tmp = fma(Float64(Float64(t - x) / Float64(a - z)), y, Float64(x + Float64(z * Float64(Float64(x - t) / Float64(a - z))))); elseif (t_3 <= 0.0) tmp = Float64(t - Float64(Float64(Float64(t - x) * Float64(y - a)) / z)); else tmp = Float64(Float64(x * t_1) + Float64(fma(t, Float64(t_2 - t_1), x) - Float64(x * t_2))); end return tmp end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -4e-296], N[(N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * y + N[(x + N[(z * N[(N[(x - t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[(t - N[(N[(N[(t - x), $MachinePrecision] * N[(y - a), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * t$95$1), $MachinePrecision] + N[(N[(t * N[(t$95$2 - t$95$1), $MachinePrecision] + x), $MachinePrecision] - N[(x * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
t_1 := \frac{z}{a - z}\\
t_2 := \frac{y}{a - z}\\
t_3 := x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
\mathbf{if}\;t_3 \leq -4 \cdot 10^{-296}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{a - z}, y, x + z \cdot \frac{x - t}{a - z}\right)\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;t - \frac{\left(t - x\right) \cdot \left(y - a\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot t_1 + \left(\mathsf{fma}\left(t, t_2 - t_1, x\right) - x \cdot t_2\right)\\
\end{array}
| Original | 24.5 |
|---|---|
| Target | 11.2 |
| Herbie | 6.9 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < -4e-296Initial program 20.8
Simplified9.8
Taylor expanded in y around 0 18.7
Simplified8.2
if -4e-296 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) < 0.0Initial program 60.2
Simplified60.3
Taylor expanded in z around -inf 1.0
Simplified1.0
if 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y z) (-.f64 t x)) (-.f64 a z))) Initial program 21.6
Simplified9.9
Taylor expanded in y around 0 19.9
Simplified8.6
Taylor expanded in t around 0 13.9
Simplified6.7
Final simplification6.9
herbie shell --seed 2022210
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))
(+ x (/ (* (- y z) (- t x)) (- a z))))