
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / 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) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{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) 1.0) a))))
double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / 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) + 1.0d0) / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\end{array}
(FPCore (x y z t a) :precision binary64 (fma (/ (- y z) (- -1.0 (- t z))) a x))
double code(double x, double y, double z, double t, double a) {
return fma(((y - z) / (-1.0 - (t - z))), a, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(y - z) / Float64(-1.0 - Float64(t - z))), a, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(y - z), $MachinePrecision] / N[(-1.0 - N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y - z}{-1 - \left(t - z\right)}, a, x\right)
\end{array}
Initial program 97.9%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
distribute-lft-neg-inN/A
distribute-frac-neg2N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6499.9
Applied rewrites99.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- x (* (/ a t) (- y z)))))
(if (<= t -4.8e+22)
t_1
(if (<= t 95000000000000.0) (fma (/ (- y z) (- z 1.0)) a x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x - ((a / t) * (y - z));
double tmp;
if (t <= -4.8e+22) {
tmp = t_1;
} else if (t <= 95000000000000.0) {
tmp = fma(((y - z) / (z - 1.0)), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x - Float64(Float64(a / t) * Float64(y - z))) tmp = 0.0 if (t <= -4.8e+22) tmp = t_1; elseif (t <= 95000000000000.0) tmp = fma(Float64(Float64(y - z) / Float64(z - 1.0)), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x - N[(N[(a / t), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -4.8e+22], t$95$1, If[LessEqual[t, 95000000000000.0], N[(N[(N[(y - z), $MachinePrecision] / N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{a}{t} \cdot \left(y - z\right)\\
\mathbf{if}\;t \leq -4.8 \cdot 10^{+22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 95000000000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{z - 1}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.8e22 or 9.5e13 < t Initial program 98.3%
Taylor expanded in t around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6480.1
Applied rewrites80.1%
Applied rewrites88.0%
if -4.8e22 < t < 9.5e13Initial program 97.5%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
distribute-lft-neg-inN/A
distribute-frac-neg2N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in t around 0
lower--.f6499.6
Applied rewrites99.6%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma z (/ a (- (+ 1.0 t) z)) x))) (if (<= z -1.7e+18) t_1 (if (<= z 6e+37) (fma (/ y (- -1.0 t)) a x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(z, (a / ((1.0 + t) - z)), x);
double tmp;
if (z <= -1.7e+18) {
tmp = t_1;
} else if (z <= 6e+37) {
tmp = fma((y / (-1.0 - t)), a, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(z, Float64(a / Float64(Float64(1.0 + t) - z)), x) tmp = 0.0 if (z <= -1.7e+18) tmp = t_1; elseif (z <= 6e+37) tmp = fma(Float64(y / Float64(-1.0 - t)), a, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(z * N[(a / N[(N[(1.0 + t), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -1.7e+18], t$95$1, If[LessEqual[z, 6e+37], N[(N[(y / N[(-1.0 - t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{a}{\left(1 + t\right) - z}, x\right)\\
\mathbf{if}\;z \leq -1.7 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+37}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{-1 - t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.7e18 or 6.00000000000000043e37 < z Initial program 96.2%
Taylor expanded in y around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6488.8
Applied rewrites88.8%
if -1.7e18 < z < 6.00000000000000043e37Initial program 99.2%
Taylor expanded in z around 0
sub-negN/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6495.6
Applied rewrites95.6%
Final simplification92.6%
(FPCore (x y z t a) :precision binary64 (if (<= z -4.9e+89) (- x a) (if (<= z 6e+37) (fma (/ y (- -1.0 t)) a x) (fma (/ (- z) (- z 1.0)) a x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.9e+89) {
tmp = x - a;
} else if (z <= 6e+37) {
tmp = fma((y / (-1.0 - t)), a, x);
} else {
tmp = fma((-z / (z - 1.0)), a, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.9e+89) tmp = Float64(x - a); elseif (z <= 6e+37) tmp = fma(Float64(y / Float64(-1.0 - t)), a, x); else tmp = fma(Float64(Float64(-z) / Float64(z - 1.0)), a, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.9e+89], N[(x - a), $MachinePrecision], If[LessEqual[z, 6e+37], N[(N[(y / N[(-1.0 - t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(N[((-z) / N[(z - 1.0), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{+89}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+37}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{-1 - t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-z}{z - 1}, a, x\right)\\
\end{array}
\end{array}
if z < -4.89999999999999996e89Initial program 92.8%
Taylor expanded in z around inf
lower--.f6487.9
Applied rewrites87.9%
if -4.89999999999999996e89 < z < 6.00000000000000043e37Initial program 99.3%
Taylor expanded in z around 0
sub-negN/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6493.7
Applied rewrites93.7%
if 6.00000000000000043e37 < z Initial program 98.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
distribute-lft-neg-inN/A
distribute-frac-neg2N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
lower--.f6485.5
Applied rewrites85.5%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6482.0
Applied rewrites82.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -4.9e+89) (- x a) (if (<= z 6e+37) (fma (/ y (- -1.0 t)) a x) (- x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.9e+89) {
tmp = x - a;
} else if (z <= 6e+37) {
tmp = fma((y / (-1.0 - t)), a, x);
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.9e+89) tmp = Float64(x - a); elseif (z <= 6e+37) tmp = fma(Float64(y / Float64(-1.0 - t)), a, x); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.9e+89], N[(x - a), $MachinePrecision], If[LessEqual[z, 6e+37], N[(N[(y / N[(-1.0 - t), $MachinePrecision]), $MachinePrecision] * a + x), $MachinePrecision], N[(x - a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{+89}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+37}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{-1 - t}, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -4.89999999999999996e89 or 6.00000000000000043e37 < z Initial program 95.7%
Taylor expanded in z around inf
lower--.f6484.7
Applied rewrites84.7%
if -4.89999999999999996e89 < z < 6.00000000000000043e37Initial program 99.3%
Taylor expanded in z around 0
sub-negN/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6493.7
Applied rewrites93.7%
(FPCore (x y z t a)
:precision binary64
(if (<= z -2.9e+17)
(- x a)
(if (<= z -3.1e-243)
(- x (* (/ y t) a))
(if (<= z 0.96) (fma (- y) a x) (- x a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.9e+17) {
tmp = x - a;
} else if (z <= -3.1e-243) {
tmp = x - ((y / t) * a);
} else if (z <= 0.96) {
tmp = fma(-y, a, x);
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.9e+17) tmp = Float64(x - a); elseif (z <= -3.1e-243) tmp = Float64(x - Float64(Float64(y / t) * a)); elseif (z <= 0.96) tmp = fma(Float64(-y), a, x); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.9e+17], N[(x - a), $MachinePrecision], If[LessEqual[z, -3.1e-243], N[(x - N[(N[(y / t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.96], N[((-y) * a + x), $MachinePrecision], N[(x - a), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9 \cdot 10^{+17}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq -3.1 \cdot 10^{-243}:\\
\;\;\;\;x - \frac{y}{t} \cdot a\\
\mathbf{elif}\;z \leq 0.96:\\
\;\;\;\;\mathsf{fma}\left(-y, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -2.9e17 or 0.95999999999999996 < z Initial program 95.7%
Taylor expanded in z around inf
lower--.f6481.0
Applied rewrites81.0%
if -2.9e17 < z < -3.0999999999999999e-243Initial program 99.9%
Taylor expanded in t around inf
mul-1-negN/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-neg.f6476.8
Applied rewrites76.8%
Taylor expanded in y around inf
Applied rewrites77.1%
Applied rewrites77.1%
if -3.0999999999999999e-243 < z < 0.95999999999999996Initial program 99.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
distribute-lft-neg-inN/A
distribute-frac-neg2N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6497.5
Applied rewrites97.5%
Taylor expanded in t around 0
Applied rewrites83.1%
(FPCore (x y z t a) :precision binary64 (if (<= z -2.26e+18) (- x a) (if (<= z 0.96) (fma (- y) a x) (- x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.26e+18) {
tmp = x - a;
} else if (z <= 0.96) {
tmp = fma(-y, a, x);
} else {
tmp = x - a;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.26e+18) tmp = Float64(x - a); elseif (z <= 0.96) tmp = fma(Float64(-y), a, x); else tmp = Float64(x - a); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.26e+18], N[(x - a), $MachinePrecision], If[LessEqual[z, 0.96], N[((-y) * a + x), $MachinePrecision], N[(x - a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.26 \cdot 10^{+18}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 0.96:\\
\;\;\;\;\mathsf{fma}\left(-y, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -2.26e18 or 0.95999999999999996 < z Initial program 96.4%
Taylor expanded in z around inf
lower--.f6481.6
Applied rewrites81.6%
if -2.26e18 < z < 0.95999999999999996Initial program 99.2%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
distribute-lft-neg-inN/A
distribute-frac-neg2N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f6496.1
Applied rewrites96.1%
Taylor expanded in t around 0
Applied rewrites76.8%
(FPCore (x y z t a) :precision binary64 (- x a))
double code(double x, double y, double z, double t, double a) {
return x - 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 - a
end function
public static double code(double x, double y, double z, double t, double a) {
return x - a;
}
def code(x, y, z, t, a): return x - a
function code(x, y, z, t, a) return Float64(x - a) end
function tmp = code(x, y, z, t, a) tmp = x - a; end
code[x_, y_, z_, t_, a_] := N[(x - a), $MachinePrecision]
\begin{array}{l}
\\
x - a
\end{array}
Initial program 97.9%
Taylor expanded in z around inf
lower--.f6464.2
Applied rewrites64.2%
(FPCore (x y z t a) :precision binary64 (- a))
double code(double x, double y, double z, double t, double a) {
return -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 = -a
end function
public static double code(double x, double y, double z, double t, double a) {
return -a;
}
def code(x, y, z, t, a): return -a
function code(x, y, z, t, a) return Float64(-a) end
function tmp = code(x, y, z, t, a) tmp = -a; end
code[x_, y_, z_, t_, a_] := (-a)
\begin{array}{l}
\\
-a
\end{array}
Initial program 97.9%
Taylor expanded in z around inf
lower--.f6464.2
Applied rewrites64.2%
Taylor expanded in x around 0
Applied rewrites14.3%
(FPCore (x y z t a) :precision binary64 (- x (* (/ (- y z) (+ (- t z) 1.0)) a)))
double code(double x, double y, double z, double t, double a) {
return x - (((y - z) / ((t - z) + 1.0)) * 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) + 1.0d0)) * a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x - (((y - z) / ((t - z) + 1.0)) * a);
}
def code(x, y, z, t, a): return x - (((y - z) / ((t - z) + 1.0)) * a)
function code(x, y, z, t, a) return Float64(x - Float64(Float64(Float64(y - z) / Float64(Float64(t - z) + 1.0)) * a)) end
function tmp = code(x, y, z, t, a) tmp = x - (((y - z) / ((t - z) + 1.0)) * a); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(N[(y - z), $MachinePrecision] / N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y - z}{\left(t - z\right) + 1} \cdot a
\end{array}
herbie shell --seed 2024235
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (- x (* (/ (- y z) (+ (- t z) 1)) a)))
(- x (/ (- y z) (/ (+ (- t z) 1.0) a))))