
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y * (z - t)) / (z - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y * (z - t)) / (z - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
(FPCore (x y z t a) :precision binary64 (+ (/ y (/ (- z a) (- z t))) x))
double code(double x, double y, double z, double t, double a) {
return (y / ((z - a) / (z - t))) + x;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (y / ((z - a) / (z - t))) + x
end function
public static double code(double x, double y, double z, double t, double a) {
return (y / ((z - a) / (z - t))) + x;
}
def code(x, y, z, t, a): return (y / ((z - a) / (z - t))) + x
function code(x, y, z, t, a) return Float64(Float64(y / Float64(Float64(z - a) / Float64(z - t))) + x) end
function tmp = code(x, y, z, t, a) tmp = (y / ((z - a) / (z - t))) + x; end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(N[(z - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{\frac{z - a}{z - t}} + x
\end{array}
Initial program 83.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6497.1
Applied rewrites97.1%
Final simplification97.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ (- z t) z) y x))) (if (<= z -4.9e-29) t_1 (if (<= z 1.7e+77) (+ (* (/ y (- a z)) t) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - t) / z), y, x);
double tmp;
if (z <= -4.9e-29) {
tmp = t_1;
} else if (z <= 1.7e+77) {
tmp = ((y / (a - z)) * t) + x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - t) / z), y, x) tmp = 0.0 if (z <= -4.9e-29) tmp = t_1; elseif (z <= 1.7e+77) tmp = Float64(Float64(Float64(y / Float64(a - z)) * t) + x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -4.9e-29], t$95$1, If[LessEqual[z, 1.7e+77], N[(N[(N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{if}\;z \leq -4.9 \cdot 10^{-29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{+77}:\\
\;\;\;\;\frac{y}{a - z} \cdot t + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.8999999999999998e-29 or 1.69999999999999998e77 < z Initial program 71.8%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6492.3
Applied rewrites92.3%
if -4.8999999999999998e-29 < z < 1.69999999999999998e77Initial program 92.4%
lift-/.f64N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
neg-sub0N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate--r+N/A
neg-sub0N/A
remove-double-negN/A
lower--.f6492.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6492.3
Applied rewrites92.3%
Taylor expanded in t around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6488.4
Applied rewrites88.4%
Final simplification90.2%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ (- z t) z) y x))) (if (<= z -1e-44) t_1 (if (<= z 1.3e+30) (fma (/ y a) t x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - t) / z), y, x);
double tmp;
if (z <= -1e-44) {
tmp = t_1;
} else if (z <= 1.3e+30) {
tmp = fma((y / a), t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - t) / z), y, x) tmp = 0.0 if (z <= -1e-44) tmp = t_1; elseif (z <= 1.3e+30) tmp = fma(Float64(y / a), t, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -1e-44], t$95$1, If[LessEqual[z, 1.3e+30], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{if}\;z \leq -1 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+30}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -9.99999999999999953e-45 or 1.29999999999999994e30 < z Initial program 71.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6490.5
Applied rewrites90.5%
if -9.99999999999999953e-45 < z < 1.29999999999999994e30Initial program 94.0%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6482.6
Applied rewrites82.6%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ z (- z a)) y x))) (if (<= z -3.7e-39) t_1 (if (<= z 0.000135) (fma (/ y a) t x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / (z - a)), y, x);
double tmp;
if (z <= -3.7e-39) {
tmp = t_1;
} else if (z <= 0.000135) {
tmp = fma((y / a), t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / Float64(z - a)), y, x) tmp = 0.0 if (z <= -3.7e-39) tmp = t_1; elseif (z <= 0.000135) tmp = fma(Float64(y / a), t, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -3.7e-39], t$95$1, If[LessEqual[z, 0.000135], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{if}\;z \leq -3.7 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.000135:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.70000000000000015e-39 or 1.35000000000000002e-4 < z Initial program 72.4%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6489.7
Applied rewrites89.7%
if -3.70000000000000015e-39 < z < 1.35000000000000002e-4Initial program 93.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6482.7
Applied rewrites82.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma z (/ y (- z a)) x))) (if (<= z -3.7e-39) t_1 (if (<= z 0.000135) (fma (/ y a) t x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(z, (y / (z - a)), x);
double tmp;
if (z <= -3.7e-39) {
tmp = t_1;
} else if (z <= 0.000135) {
tmp = fma((y / a), t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(z, Float64(y / Float64(z - a)), x) tmp = 0.0 if (z <= -3.7e-39) tmp = t_1; elseif (z <= 0.000135) tmp = fma(Float64(y / a), t, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(z * N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -3.7e-39], t$95$1, If[LessEqual[z, 0.000135], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{y}{z - a}, x\right)\\
\mathbf{if}\;z \leq -3.7 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.000135:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.70000000000000015e-39 or 1.35000000000000002e-4 < z Initial program 72.4%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6489.7
Applied rewrites89.7%
Applied rewrites86.9%
if -3.70000000000000015e-39 < z < 1.35000000000000002e-4Initial program 93.8%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6482.7
Applied rewrites82.7%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.72e-31) (+ y x) (if (<= z 6.4e+30) (fma (/ y a) t x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.72e-31) {
tmp = y + x;
} else if (z <= 6.4e+30) {
tmp = fma((y / a), t, x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.72e-31) tmp = Float64(y + x); elseif (z <= 6.4e+30) tmp = fma(Float64(y / a), t, x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.72e-31], N[(y + x), $MachinePrecision], If[LessEqual[z, 6.4e+30], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.72 \cdot 10^{-31}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 6.4 \cdot 10^{+30}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.71999999999999996e-31 or 6.39999999999999945e30 < z Initial program 71.3%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6483.9
Applied rewrites83.9%
if -1.71999999999999996e-31 < z < 6.39999999999999945e30Initial program 94.0%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6482.6
Applied rewrites82.6%
(FPCore (x y z t a) :precision binary64 (if (<= z -2.4e-269) (+ y x) (if (<= z 5.4e-78) (* (/ y a) t) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.4e-269) {
tmp = y + x;
} else if (z <= 5.4e-78) {
tmp = (y / a) * t;
} else {
tmp = y + x;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-2.4d-269)) then
tmp = y + x
else if (z <= 5.4d-78) then
tmp = (y / a) * t
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.4e-269) {
tmp = y + x;
} else if (z <= 5.4e-78) {
tmp = (y / a) * t;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -2.4e-269: tmp = y + x elif z <= 5.4e-78: tmp = (y / a) * t else: tmp = y + x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.4e-269) tmp = Float64(y + x); elseif (z <= 5.4e-78) tmp = Float64(Float64(y / a) * t); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -2.4e-269) tmp = y + x; elseif (z <= 5.4e-78) tmp = (y / a) * t; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.4e-269], N[(y + x), $MachinePrecision], If[LessEqual[z, 5.4e-78], N[(N[(y / a), $MachinePrecision] * t), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{-269}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{-78}:\\
\;\;\;\;\frac{y}{a} \cdot t\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -2.4000000000000001e-269 or 5.39999999999999987e-78 < z Initial program 80.1%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6471.4
Applied rewrites71.4%
if -2.4000000000000001e-269 < z < 5.39999999999999987e-78Initial program 93.5%
Taylor expanded in y around inf
distribute-lft-out--N/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6461.8
Applied rewrites61.8%
Taylor expanded in z around 0
Applied rewrites59.6%
Final simplification68.7%
(FPCore (x y z t a) :precision binary64 (fma (/ (- z t) (- z a)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - t) / (z - a)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - t) / Float64(z - a)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - t}{z - a}, y, x\right)
\end{array}
Initial program 83.2%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
(FPCore (x y z t a) :precision binary64 (fma (/ y (- z a)) (- z t) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / (z - a)), (z - t), x);
}
function code(x, y, z, t, a) return fma(Float64(y / Float64(z - a)), Float64(z - t), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{z - a}, z - t, x\right)
\end{array}
Initial program 83.2%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.4
Applied rewrites95.4%
(FPCore (x y z t a) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a) {
return y + x;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = y + x
end function
public static double code(double x, double y, double z, double t, double a) {
return y + x;
}
def code(x, y, z, t, a): return y + x
function code(x, y, z, t, a) return Float64(y + x) end
function tmp = code(x, y, z, t, a) tmp = y + x; end
code[x_, y_, z_, t_, a_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 83.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6462.2
Applied rewrites62.2%
(FPCore (x y z t a) :precision binary64 (+ x (/ y (/ (- z a) (- z t)))))
double code(double x, double y, double z, double t, double a) {
return x + (y / ((z - a) / (z - t)));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + (y / ((z - a) / (z - t)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y / ((z - a) / (z - t)));
}
def code(x, y, z, t, a): return x + (y / ((z - a) / (z - t)))
function code(x, y, z, t, a) return Float64(x + Float64(y / Float64(Float64(z - a) / Float64(z - t)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y / ((z - a) / (z - t))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y / N[(N[(z - a), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{\frac{z - a}{z - t}}
\end{array}
herbie shell --seed 2024255
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, A"
:precision binary64
:alt
(! :herbie-platform default (+ x (/ y (/ (- z a) (- z t)))))
(+ x (/ (* y (- z t)) (- z a))))