
(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 9 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 88.6%
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
--lowering--.f6497.5
Applied egg-rr97.5%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.1e+64) (fma (/ (- t z) a) y x) (if (<= a 2.15e-119) (fma y (- 1.0 (/ t z)) x) (fma t (/ y a) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.1e+64) {
tmp = fma(((t - z) / a), y, x);
} else if (a <= 2.15e-119) {
tmp = fma(y, (1.0 - (t / z)), x);
} else {
tmp = fma(t, (y / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.1e+64) tmp = fma(Float64(Float64(t - z) / a), y, x); elseif (a <= 2.15e-119) tmp = fma(y, Float64(1.0 - Float64(t / z)), x); else tmp = fma(t, Float64(y / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.1e+64], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[a, 2.15e-119], N[(y * N[(1.0 - N[(t / z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{+64}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\
\mathbf{elif}\;a \leq 2.15 \cdot 10^{-119}:\\
\;\;\;\;\mathsf{fma}\left(y, 1 - \frac{t}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\end{array}
\end{array}
if a < -1.10000000000000001e64Initial program 85.9%
+-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 a around inf
associate-*r/N/A
/-lowering-/.f64N/A
mul-1-negN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
unsub-negN/A
mul-1-negN/A
remove-double-negN/A
--lowering--.f6495.9
Simplified95.9%
if -1.10000000000000001e64 < a < 2.15e-119Initial program 90.1%
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-/.f6487.3
Simplified87.3%
if 2.15e-119 < a Initial program 87.9%
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
--lowering--.f6498.3
Applied egg-rr98.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f6481.0
Simplified81.0%
(FPCore (x y z t a) :precision binary64 (if (<= a -1.6e+109) (fma y (/ t a) x) (if (<= a 2.15e-119) (fma y (- 1.0 (/ t z)) x) (fma t (/ y a) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -1.6e+109) {
tmp = fma(y, (t / a), x);
} else if (a <= 2.15e-119) {
tmp = fma(y, (1.0 - (t / z)), x);
} else {
tmp = fma(t, (y / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -1.6e+109) tmp = fma(y, Float64(t / a), x); elseif (a <= 2.15e-119) tmp = fma(y, Float64(1.0 - Float64(t / z)), x); else tmp = fma(t, Float64(y / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -1.6e+109], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[a, 2.15e-119], N[(y * N[(1.0 - N[(t / z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{+109}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{elif}\;a \leq 2.15 \cdot 10^{-119}:\\
\;\;\;\;\mathsf{fma}\left(y, 1 - \frac{t}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\end{array}
\end{array}
if a < -1.6000000000000001e109Initial program 85.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f6492.6
Simplified92.6%
if -1.6000000000000001e109 < a < 2.15e-119Initial program 90.0%
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-/.f6486.6
Simplified86.6%
if 2.15e-119 < a Initial program 87.9%
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
--lowering--.f6498.3
Applied egg-rr98.3%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f6481.0
Simplified81.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -0.000125) (+ y x) (if (<= z 1.65e-32) (fma y (/ t a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -0.000125) {
tmp = y + x;
} else if (z <= 1.65e-32) {
tmp = fma(y, (t / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -0.000125) tmp = Float64(y + x); elseif (z <= 1.65e-32) 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, -0.000125], N[(y + x), $MachinePrecision], If[LessEqual[z, 1.65e-32], N[(y * N[(t / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.000125:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{-32}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.25e-4 or 1.65000000000000013e-32 < z Initial program 82.6%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6477.2
Simplified77.2%
if -1.25e-4 < z < 1.65000000000000013e-32Initial program 93.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f6477.2
Simplified77.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.2e-6) (+ y x) (if (<= z 1.65e-32) (fma t (/ y a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.2e-6) {
tmp = y + x;
} else if (z <= 1.65e-32) {
tmp = fma(t, (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.2e-6) tmp = Float64(y + x); elseif (z <= 1.65e-32) 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, -3.2e-6], N[(y + x), $MachinePrecision], If[LessEqual[z, 1.65e-32], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{-6}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{-32}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -3.1999999999999999e-6 or 1.65000000000000013e-32 < z Initial program 82.6%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6477.2
Simplified77.2%
if -3.1999999999999999e-6 < z < 1.65000000000000013e-32Initial program 93.7%
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
--lowering--.f6495.4
Applied egg-rr95.4%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f6475.9
Simplified75.9%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.1e+173) (fma y (- 1.0 (/ t z)) x) (fma (/ y (- z a)) (- z t) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.1e+173) {
tmp = fma(y, (1.0 - (t / z)), x);
} else {
tmp = fma((y / (z - a)), (z - t), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.1e+173) tmp = fma(y, Float64(1.0 - Float64(t / z)), x); else tmp = fma(Float64(y / Float64(z - a)), Float64(z - t), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.1e+173], N[(y * N[(1.0 - N[(t / z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+173}:\\
\;\;\;\;\mathsf{fma}\left(y, 1 - \frac{t}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z - a}, z - t, x\right)\\
\end{array}
\end{array}
if z < -1.1e173Initial program 80.9%
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-/.f64100.0
Simplified100.0%
if -1.1e173 < z Initial program 89.2%
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
--lowering--.f6496.1
Applied egg-rr96.1%
(FPCore (x y z t a) :precision binary64 (if (<= a -3.5e+124) x (if (<= a 4e+101) (+ y x) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -3.5e+124) {
tmp = x;
} else if (a <= 4e+101) {
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 <= (-3.5d+124)) then
tmp = x
else if (a <= 4d+101) 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 <= -3.5e+124) {
tmp = x;
} else if (a <= 4e+101) {
tmp = y + x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a <= -3.5e+124: tmp = x elif a <= 4e+101: tmp = y + x else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a <= -3.5e+124) tmp = x; elseif (a <= 4e+101) 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 <= -3.5e+124) tmp = x; elseif (a <= 4e+101) tmp = y + x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -3.5e+124], x, If[LessEqual[a, 4e+101], N[(y + x), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.5 \cdot 10^{+124}:\\
\;\;\;\;x\\
\mathbf{elif}\;a \leq 4 \cdot 10^{+101}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if a < -3.5000000000000001e124 or 3.9999999999999999e101 < a Initial program 84.2%
Taylor expanded in x around inf
Simplified73.6%
if -3.5000000000000001e124 < a < 3.9999999999999999e101Initial program 90.7%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6467.4
Simplified67.4%
(FPCore (x y z t a) :precision binary64 (if (<= y 1.25e+105) x y))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 1.25e+105) {
tmp = x;
} else {
tmp = y;
}
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 (y <= 1.25d+105) then
tmp = x
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 1.25e+105) {
tmp = x;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= 1.25e+105: tmp = x else: tmp = y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= 1.25e+105) tmp = x; else tmp = y; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= 1.25e+105) tmp = x; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, 1.25e+105], x, y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{+105}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 1.25000000000000011e105Initial program 90.8%
Taylor expanded in x around inf
Simplified62.2%
if 1.25000000000000011e105 < y Initial program 71.8%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6442.7
Simplified42.7%
Taylor expanded in y around inf
Simplified39.5%
(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 88.6%
Taylor expanded in x around inf
Simplified56.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 2024198
(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))))