
(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 8 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 a (/ (- z y) (+ (- t z) 1.0)) x))
double code(double x, double y, double z, double t, double a) {
return fma(a, ((z - y) / ((t - z) + 1.0)), x);
}
function code(x, y, z, t, a) return fma(a, Float64(Float64(z - y) / Float64(Float64(t - z) + 1.0)), x) end
code[x_, y_, z_, t_, a_] := N[(a * N[(N[(z - y), $MachinePrecision] / N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a, \frac{z - y}{\left(t - z\right) + 1}, x\right)
\end{array}
Initial program 93.9%
sub-neg93.9%
+-commutative93.9%
associate-/r/99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
fma-def99.9%
div-sub99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
div-sub99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- x (* a y))))
(if (<= z -3.2e+69)
(- x a)
(if (<= z -3.8e-137)
t_1
(if (<= z -2.8e-179)
(- x (/ a (/ t y)))
(if (<= z 7.6e+39) t_1 (- x a)))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x - (a * y);
double tmp;
if (z <= -3.2e+69) {
tmp = x - a;
} else if (z <= -3.8e-137) {
tmp = t_1;
} else if (z <= -2.8e-179) {
tmp = x - (a / (t / y));
} else if (z <= 7.6e+39) {
tmp = t_1;
} else {
tmp = x - 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) :: t_1
real(8) :: tmp
t_1 = x - (a * y)
if (z <= (-3.2d+69)) then
tmp = x - a
else if (z <= (-3.8d-137)) then
tmp = t_1
else if (z <= (-2.8d-179)) then
tmp = x - (a / (t / y))
else if (z <= 7.6d+39) then
tmp = t_1
else
tmp = x - a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x - (a * y);
double tmp;
if (z <= -3.2e+69) {
tmp = x - a;
} else if (z <= -3.8e-137) {
tmp = t_1;
} else if (z <= -2.8e-179) {
tmp = x - (a / (t / y));
} else if (z <= 7.6e+39) {
tmp = t_1;
} else {
tmp = x - a;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = x - (a * y) tmp = 0 if z <= -3.2e+69: tmp = x - a elif z <= -3.8e-137: tmp = t_1 elif z <= -2.8e-179: tmp = x - (a / (t / y)) elif z <= 7.6e+39: tmp = t_1 else: tmp = x - a return tmp
function code(x, y, z, t, a) t_1 = Float64(x - Float64(a * y)) tmp = 0.0 if (z <= -3.2e+69) tmp = Float64(x - a); elseif (z <= -3.8e-137) tmp = t_1; elseif (z <= -2.8e-179) tmp = Float64(x - Float64(a / Float64(t / y))); elseif (z <= 7.6e+39) tmp = t_1; else tmp = Float64(x - a); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = x - (a * y); tmp = 0.0; if (z <= -3.2e+69) tmp = x - a; elseif (z <= -3.8e-137) tmp = t_1; elseif (z <= -2.8e-179) tmp = x - (a / (t / y)); elseif (z <= 7.6e+39) tmp = t_1; else tmp = x - a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x - N[(a * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.2e+69], N[(x - a), $MachinePrecision], If[LessEqual[z, -3.8e-137], t$95$1, If[LessEqual[z, -2.8e-179], N[(x - N[(a / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.6e+39], t$95$1, N[(x - a), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - a \cdot y\\
\mathbf{if}\;z \leq -3.2 \cdot 10^{+69}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq -3.8 \cdot 10^{-137}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{-179}:\\
\;\;\;\;x - \frac{a}{\frac{t}{y}}\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{+39}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -3.19999999999999985e69 or 7.5999999999999996e39 < z Initial program 87.3%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around inf 82.7%
if -3.19999999999999985e69 < z < -3.79999999999999999e-137 or -2.8000000000000001e-179 < z < 7.5999999999999996e39Initial program 98.5%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around 0 84.9%
associate-/l*88.1%
Simplified88.1%
Taylor expanded in t around 0 77.1%
if -3.79999999999999999e-137 < z < -2.8000000000000001e-179Initial program 99.8%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in z around 0 88.0%
associate-/l*88.2%
Simplified88.2%
Taylor expanded in t around inf 88.4%
*-commutative88.4%
associate-/l*88.6%
Simplified88.6%
Final simplification79.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.26e+48) (not (<= z 8.2e+40))) (- x a) (- x (* a (/ y (+ t 1.0))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.26e+48) || !(z <= 8.2e+40)) {
tmp = x - a;
} else {
tmp = x - (a * (y / (t + 1.0)));
}
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 <= (-1.26d+48)) .or. (.not. (z <= 8.2d+40))) then
tmp = x - a
else
tmp = x - (a * (y / (t + 1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.26e+48) || !(z <= 8.2e+40)) {
tmp = x - a;
} else {
tmp = x - (a * (y / (t + 1.0)));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.26e+48) or not (z <= 8.2e+40): tmp = x - a else: tmp = x - (a * (y / (t + 1.0))) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.26e+48) || !(z <= 8.2e+40)) tmp = Float64(x - a); else tmp = Float64(x - Float64(a * Float64(y / Float64(t + 1.0)))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.26e+48) || ~((z <= 8.2e+40))) tmp = x - a; else tmp = x - (a * (y / (t + 1.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.26e+48], N[Not[LessEqual[z, 8.2e+40]], $MachinePrecision]], N[(x - a), $MachinePrecision], N[(x - N[(a * N[(y / N[(t + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.26 \cdot 10^{+48} \lor \neg \left(z \leq 8.2 \cdot 10^{+40}\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x - a \cdot \frac{y}{t + 1}\\
\end{array}
\end{array}
if z < -1.26000000000000001e48 or 8.2000000000000003e40 < z Initial program 87.7%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around inf 82.3%
if -1.26000000000000001e48 < z < 8.2000000000000003e40Initial program 98.6%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around 0 89.2%
Final simplification86.3%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.3e+47) (not (<= z 4.2e+40))) (- x a) (- x (/ a (/ (+ t 1.0) y)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.3e+47) || !(z <= 4.2e+40)) {
tmp = x - a;
} else {
tmp = x - (a / ((t + 1.0) / 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 ((z <= (-2.3d+47)) .or. (.not. (z <= 4.2d+40))) then
tmp = x - a
else
tmp = x - (a / ((t + 1.0d0) / y))
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.3e+47) || !(z <= 4.2e+40)) {
tmp = x - a;
} else {
tmp = x - (a / ((t + 1.0) / y));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -2.3e+47) or not (z <= 4.2e+40): tmp = x - a else: tmp = x - (a / ((t + 1.0) / y)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.3e+47) || !(z <= 4.2e+40)) tmp = Float64(x - a); else tmp = Float64(x - Float64(a / Float64(Float64(t + 1.0) / y))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -2.3e+47) || ~((z <= 4.2e+40))) tmp = x - a; else tmp = x - (a / ((t + 1.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.3e+47], N[Not[LessEqual[z, 4.2e+40]], $MachinePrecision]], N[(x - a), $MachinePrecision], N[(x - N[(a / N[(N[(t + 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+47} \lor \neg \left(z \leq 4.2 \cdot 10^{+40}\right):\\
\;\;\;\;x - a\\
\mathbf{else}:\\
\;\;\;\;x - \frac{a}{\frac{t + 1}{y}}\\
\end{array}
\end{array}
if z < -2.2999999999999999e47 or 4.2000000000000002e40 < z Initial program 87.7%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around inf 82.3%
if -2.2999999999999999e47 < z < 4.2000000000000002e40Initial program 98.6%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around 0 86.1%
associate-/l*89.2%
Simplified89.2%
Final simplification86.3%
(FPCore (x y z t a) :precision binary64 (+ x (* a (/ (- z y) (+ (- t z) 1.0)))))
double code(double x, double y, double z, double t, double a) {
return x + (a * ((z - y) / ((t - z) + 1.0)));
}
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 * ((z - y) / ((t - z) + 1.0d0)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (a * ((z - y) / ((t - z) + 1.0)));
}
def code(x, y, z, t, a): return x + (a * ((z - y) / ((t - z) + 1.0)))
function code(x, y, z, t, a) return Float64(x + Float64(a * Float64(Float64(z - y) / Float64(Float64(t - z) + 1.0)))) end
function tmp = code(x, y, z, t, a) tmp = x + (a * ((z - y) / ((t - z) + 1.0))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(a * N[(N[(z - y), $MachinePrecision] / N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + a \cdot \frac{z - y}{\left(t - z\right) + 1}
\end{array}
Initial program 93.9%
associate-/r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.2e+69) (- x a) (if (<= z 7.6e+39) (- x (* a y)) (- x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.2e+69) {
tmp = x - a;
} else if (z <= 7.6e+39) {
tmp = x - (a * y);
} else {
tmp = x - 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 (z <= (-3.2d+69)) then
tmp = x - a
else if (z <= 7.6d+39) then
tmp = x - (a * y)
else
tmp = x - a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.2e+69) {
tmp = x - a;
} else if (z <= 7.6e+39) {
tmp = x - (a * y);
} else {
tmp = x - a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -3.2e+69: tmp = x - a elif z <= 7.6e+39: tmp = x - (a * y) else: tmp = x - a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.2e+69) tmp = Float64(x - a); elseif (z <= 7.6e+39) tmp = Float64(x - Float64(a * y)); else tmp = Float64(x - a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -3.2e+69) tmp = x - a; elseif (z <= 7.6e+39) tmp = x - (a * y); else tmp = x - a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.2e+69], N[(x - a), $MachinePrecision], If[LessEqual[z, 7.6e+39], N[(x - N[(a * y), $MachinePrecision]), $MachinePrecision], N[(x - a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{+69}:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{+39}:\\
\;\;\;\;x - a \cdot y\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -3.19999999999999985e69 or 7.5999999999999996e39 < z Initial program 87.3%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around inf 82.7%
if -3.19999999999999985e69 < z < 7.5999999999999996e39Initial program 98.6%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around 0 85.0%
associate-/l*88.1%
Simplified88.1%
Taylor expanded in t around 0 74.4%
Final simplification77.9%
(FPCore (x y z t a) :precision binary64 (if (<= z -290.0) (- x a) (if (<= z 3.7e-22) x (- x a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -290.0) {
tmp = x - a;
} else if (z <= 3.7e-22) {
tmp = x;
} else {
tmp = x - 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 (z <= (-290.0d0)) then
tmp = x - a
else if (z <= 3.7d-22) then
tmp = x
else
tmp = x - a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -290.0) {
tmp = x - a;
} else if (z <= 3.7e-22) {
tmp = x;
} else {
tmp = x - a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -290.0: tmp = x - a elif z <= 3.7e-22: tmp = x else: tmp = x - a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -290.0) tmp = Float64(x - a); elseif (z <= 3.7e-22) tmp = x; else tmp = Float64(x - a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -290.0) tmp = x - a; elseif (z <= 3.7e-22) tmp = x; else tmp = x - a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -290.0], N[(x - a), $MachinePrecision], If[LessEqual[z, 3.7e-22], x, N[(x - a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -290:\\
\;\;\;\;x - a\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{-22}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - a\\
\end{array}
\end{array}
if z < -290 or 3.7e-22 < z Initial program 88.6%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around inf 79.1%
if -290 < z < 3.7e-22Initial program 99.1%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around inf 51.7%
Final simplification65.3%
(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 93.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around inf 51.1%
Final simplification51.1%
(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 2023238
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
:precision binary64
:herbie-target
(- x (* (/ (- y z) (+ (- t z) 1.0)) a))
(- x (/ (- y z) (/ (+ (- t z) 1.0) a))))