
(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 (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 84.7%
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
--lowering--.f6499.2
Applied egg-rr99.2%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ z (- z a)) y x))) (if (<= z -3.8e-140) t_1 (if (<= z 4.3e-63) (fma y (/ t a) 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.8e-140) {
tmp = t_1;
} else if (z <= 4.3e-63) {
tmp = fma(y, (t / a), 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.8e-140) tmp = t_1; elseif (z <= 4.3e-63) tmp = fma(y, Float64(t / a), 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.8e-140], t$95$1, If[LessEqual[z, 4.3e-63], N[(y * N[(t / a), $MachinePrecision] + 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.8 \cdot 10^{-140}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{-63}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.79999999999999998e-140 or 4.2999999999999999e-63 < z Initial program 79.1%
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
--lowering--.f6499.9
Applied egg-rr99.9%
Taylor expanded in t around 0
/-lowering-/.f64N/A
--lowering--.f6482.6
Simplified82.6%
if -3.79999999999999998e-140 < z < 4.2999999999999999e-63Initial program 96.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f6487.8
Simplified87.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma y (- 1.0 (/ t z)) x))) (if (<= z -2.85e-87) t_1 (if (<= z 1.36e-27) (fma y (/ t a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, (1.0 - (t / z)), x);
double tmp;
if (z <= -2.85e-87) {
tmp = t_1;
} else if (z <= 1.36e-27) {
tmp = fma(y, (t / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(y, Float64(1.0 - Float64(t / z)), x) tmp = 0.0 if (z <= -2.85e-87) tmp = t_1; elseif (z <= 1.36e-27) tmp = fma(y, Float64(t / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(1.0 - N[(t / z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -2.85e-87], t$95$1, If[LessEqual[z, 1.36e-27], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, 1 - \frac{t}{z}, x\right)\\
\mathbf{if}\;z \leq -2.85 \cdot 10^{-87}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.36 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.85e-87 or 1.36e-27 < z Initial program 76.8%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
div-subN/A
*-inversesN/A
--lowering--.f64N/A
/-lowering-/.f6483.8
Simplified83.8%
if -2.85e-87 < z < 1.36e-27Initial program 97.0%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f6482.7
Simplified82.7%
(FPCore (x y z t a) :precision binary64 (if (<= z -6.5e+41) (+ y x) (if (<= z 1.3e+33) (fma y (/ t a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -6.5e+41) {
tmp = y + x;
} else if (z <= 1.3e+33) {
tmp = fma(y, (t / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -6.5e+41) tmp = Float64(y + x); elseif (z <= 1.3e+33) tmp = fma(y, Float64(t / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -6.5e+41], N[(y + x), $MachinePrecision], If[LessEqual[z, 1.3e+33], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+41}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -6.49999999999999975e41 or 1.2999999999999999e33 < z Initial program 73.7%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6485.9
Simplified85.9%
if -6.49999999999999975e41 < z < 1.2999999999999999e33Initial program 93.8%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f6474.0
Simplified74.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -5.5e+41) (+ y x) (if (<= z 6.6e+33) (fma t (/ y a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -5.5e+41) {
tmp = y + x;
} else if (z <= 6.6e+33) {
tmp = fma(t, (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -5.5e+41) tmp = Float64(y + x); elseif (z <= 6.6e+33) tmp = fma(t, Float64(y / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -5.5e+41], N[(y + x), $MachinePrecision], If[LessEqual[z, 6.6e+33], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+41}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -5.5000000000000003e41 or 6.59999999999999953e33 < z Initial program 73.7%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6485.9
Simplified85.9%
if -5.5000000000000003e41 < z < 6.59999999999999953e33Initial program 93.8%
Taylor expanded in z around 0
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6469.4
Simplified69.4%
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f6472.6
Applied egg-rr72.6%
(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 84.7%
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
--lowering--.f6494.6
Applied egg-rr94.6%
(FPCore (x y z t a) :precision binary64 (if (<= t 4.6e+245) (+ y x) (* y (/ t a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 4.6e+245) {
tmp = y + x;
} else {
tmp = y * (t / a);
}
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 (t <= 4.6d+245) then
tmp = y + x
else
tmp = y * (t / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= 4.6e+245) {
tmp = y + x;
} else {
tmp = y * (t / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= 4.6e+245: tmp = y + x else: tmp = y * (t / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= 4.6e+245) tmp = Float64(y + x); else tmp = Float64(y * Float64(t / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= 4.6e+245) tmp = y + x; else tmp = y * (t / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, 4.6e+245], N[(y + x), $MachinePrecision], N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 4.6 \cdot 10^{+245}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{t}{a}\\
\end{array}
\end{array}
if t < 4.5999999999999999e245Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6464.5
Simplified64.5%
if 4.5999999999999999e245 < t Initial program 70.9%
Taylor expanded in t around inf
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
distribute-neg-frac2N/A
/-lowering-/.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
mul-1-negN/A
+-lowering-+.f64N/A
mul-1-negN/A
neg-lowering-neg.f6477.0
Simplified77.0%
Taylor expanded in a around inf
Simplified77.3%
(FPCore (x y z t a) :precision binary64 (if (<= x -2.6e-144) x (if (<= x 9e-103) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -2.6e-144) {
tmp = x;
} else if (x <= 9e-103) {
tmp = y;
} else {
tmp = 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 (x <= (-2.6d-144)) then
tmp = x
else if (x <= 9d-103) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -2.6e-144) {
tmp = x;
} else if (x <= 9e-103) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if x <= -2.6e-144: tmp = x elif x <= 9e-103: tmp = y else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (x <= -2.6e-144) tmp = x; elseif (x <= 9e-103) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (x <= -2.6e-144) tmp = x; elseif (x <= 9e-103) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[x, -2.6e-144], x, If[LessEqual[x, 9e-103], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{-144}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-103}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.6000000000000001e-144 or 9e-103 < x Initial program 84.2%
Taylor expanded in x around inf
Simplified65.9%
if -2.6000000000000001e-144 < x < 9e-103Initial program 85.9%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6449.6
Simplified49.6%
Taylor expanded in y around inf
Simplified43.7%
(FPCore (x y z t a) :precision binary64 (if (<= a 9.4e+26) (+ y x) x))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 9.4e+26) {
tmp = y + x;
} else {
tmp = 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 (a <= 9.4d+26) then
tmp = y + x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= 9.4e+26) {
tmp = y + x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= 9.4e+26: tmp = y + x else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= 9.4e+26) tmp = Float64(y + x); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a <= 9.4e+26) tmp = y + x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, 9.4e+26], N[(y + x), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 9.4 \cdot 10^{+26}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < 9.3999999999999995e26Initial program 82.8%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6467.0
Simplified67.0%
if 9.3999999999999995e26 < a Initial program 92.3%
Taylor expanded in x around inf
Simplified56.2%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return 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 = x
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 84.7%
Taylor expanded in x around inf
Simplified49.1%
(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 2024199
(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))))