
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (* -4.0 (- (/ (- y x) z) -0.5)))
double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-4.0d0) * (((y - x) / z) - (-0.5d0))
end function
public static double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
def code(x, y, z): return -4.0 * (((y - x) / z) - -0.5)
function code(x, y, z) return Float64(-4.0 * Float64(Float64(Float64(y - x) / z) - -0.5)) end
function tmp = code(x, y, z) tmp = -4.0 * (((y - x) / z) - -0.5); end
code[x_, y_, z_] := N[(-4.0 * N[(N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \left(\frac{y - x}{z} - -0.5\right)
\end{array}
Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (/ (* x 4.0) z) -2.0)))
(if (<= x -1.25e+98)
t_0
(if (<= x 3.7e-21)
(+ -2.0 (* -4.0 (/ y z)))
(if (<= x 7.3e+78) (/ (* -4.0 (- y x)) z) t_0)))))
double code(double x, double y, double z) {
double t_0 = ((x * 4.0) / z) + -2.0;
double tmp;
if (x <= -1.25e+98) {
tmp = t_0;
} else if (x <= 3.7e-21) {
tmp = -2.0 + (-4.0 * (y / z));
} else if (x <= 7.3e+78) {
tmp = (-4.0 * (y - x)) / z;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((x * 4.0d0) / z) + (-2.0d0)
if (x <= (-1.25d+98)) then
tmp = t_0
else if (x <= 3.7d-21) then
tmp = (-2.0d0) + ((-4.0d0) * (y / z))
else if (x <= 7.3d+78) then
tmp = ((-4.0d0) * (y - x)) / z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((x * 4.0) / z) + -2.0;
double tmp;
if (x <= -1.25e+98) {
tmp = t_0;
} else if (x <= 3.7e-21) {
tmp = -2.0 + (-4.0 * (y / z));
} else if (x <= 7.3e+78) {
tmp = (-4.0 * (y - x)) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((x * 4.0) / z) + -2.0 tmp = 0 if x <= -1.25e+98: tmp = t_0 elif x <= 3.7e-21: tmp = -2.0 + (-4.0 * (y / z)) elif x <= 7.3e+78: tmp = (-4.0 * (y - x)) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(x * 4.0) / z) + -2.0) tmp = 0.0 if (x <= -1.25e+98) tmp = t_0; elseif (x <= 3.7e-21) tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z))); elseif (x <= 7.3e+78) tmp = Float64(Float64(-4.0 * Float64(y - x)) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((x * 4.0) / z) + -2.0; tmp = 0.0; if (x <= -1.25e+98) tmp = t_0; elseif (x <= 3.7e-21) tmp = -2.0 + (-4.0 * (y / z)); elseif (x <= 7.3e+78) tmp = (-4.0 * (y - x)) / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision]}, If[LessEqual[x, -1.25e+98], t$95$0, If[LessEqual[x, 3.7e-21], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.3e+78], N[(N[(-4.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z} + -2\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{+98}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-21}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\mathbf{elif}\;x \leq 7.3 \cdot 10^{+78}:\\
\;\;\;\;\frac{-4 \cdot \left(y - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.25e98 or 7.3e78 < x Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 90.1%
sub-neg90.1%
+-commutative90.1%
distribute-rgt-in90.1%
distribute-neg-frac90.1%
neg-mul-190.1%
*-commutative90.1%
associate-/l*89.9%
metadata-eval89.9%
distribute-neg-frac89.9%
associate-*r*89.9%
distribute-frac-neg289.9%
associate-*l/89.9%
metadata-eval89.9%
distribute-neg-frac289.9%
distribute-neg-frac89.9%
metadata-eval89.9%
associate-*r/90.1%
metadata-eval90.1%
Simplified90.1%
if -1.25e98 < x < 3.7000000000000002e-21Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 90.3%
+-commutative90.3%
distribute-rgt-in90.3%
metadata-eval90.3%
Simplified90.3%
if 3.7000000000000002e-21 < x < 7.3e78Initial program 99.8%
remove-double-neg99.8%
neg-mul-199.8%
times-frac99.8%
metadata-eval99.8%
div-sub99.8%
distribute-frac-neg299.8%
distribute-frac-neg99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
*-commutative99.8%
neg-mul-199.8%
times-frac99.8%
metadata-eval99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 94.0%
*-commutative94.0%
associate-*l/94.0%
Simplified94.0%
Final simplification90.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))))
(if (<= y -2e+18)
t_0
(if (<= y 3.2e-210) (/ (* x 4.0) z) (if (<= y 1.7e-56) -2.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (y <= -2e+18) {
tmp = t_0;
} else if (y <= 3.2e-210) {
tmp = (x * 4.0) / z;
} else if (y <= 1.7e-56) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) * (y / z)
if (y <= (-2d+18)) then
tmp = t_0
else if (y <= 3.2d-210) then
tmp = (x * 4.0d0) / z
else if (y <= 1.7d-56) then
tmp = -2.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (y <= -2e+18) {
tmp = t_0;
} else if (y <= 3.2e-210) {
tmp = (x * 4.0) / z;
} else if (y <= 1.7e-56) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) tmp = 0 if y <= -2e+18: tmp = t_0 elif y <= 3.2e-210: tmp = (x * 4.0) / z elif y <= 1.7e-56: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (y <= -2e+18) tmp = t_0; elseif (y <= 3.2e-210) tmp = Float64(Float64(x * 4.0) / z); elseif (y <= 1.7e-56) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); tmp = 0.0; if (y <= -2e+18) tmp = t_0; elseif (y <= 3.2e-210) tmp = (x * 4.0) / z; elseif (y <= 1.7e-56) tmp = -2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2e+18], t$95$0, If[LessEqual[y, 3.2e-210], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 1.7e-56], -2.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -2 \cdot 10^{+18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-210}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-56}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2e18 or 1.69999999999999991e-56 < y Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 59.3%
*-commutative59.3%
Simplified59.3%
if -2e18 < y < 3.20000000000000028e-210Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 53.6%
associate-*r/53.6%
*-commutative53.6%
Simplified53.6%
if 3.20000000000000028e-210 < y < 1.69999999999999991e-56Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 65.8%
Final simplification58.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))))
(if (<= y -6.5e+17)
t_0
(if (<= y 4.5e-212) (* x (/ 4.0 z)) (if (<= y 1.2e-56) -2.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (y <= -6.5e+17) {
tmp = t_0;
} else if (y <= 4.5e-212) {
tmp = x * (4.0 / z);
} else if (y <= 1.2e-56) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) * (y / z)
if (y <= (-6.5d+17)) then
tmp = t_0
else if (y <= 4.5d-212) then
tmp = x * (4.0d0 / z)
else if (y <= 1.2d-56) then
tmp = -2.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (y <= -6.5e+17) {
tmp = t_0;
} else if (y <= 4.5e-212) {
tmp = x * (4.0 / z);
} else if (y <= 1.2e-56) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) tmp = 0 if y <= -6.5e+17: tmp = t_0 elif y <= 4.5e-212: tmp = x * (4.0 / z) elif y <= 1.2e-56: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (y <= -6.5e+17) tmp = t_0; elseif (y <= 4.5e-212) tmp = Float64(x * Float64(4.0 / z)); elseif (y <= 1.2e-56) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); tmp = 0.0; if (y <= -6.5e+17) tmp = t_0; elseif (y <= 4.5e-212) tmp = x * (4.0 / z); elseif (y <= 1.2e-56) tmp = -2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.5e+17], t$95$0, If[LessEqual[y, 4.5e-212], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.2e-56], -2.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -6.5 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-212}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-56}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -6.5e17 or 1.2e-56 < y Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 59.3%
*-commutative59.3%
Simplified59.3%
if -6.5e17 < y < 4.4999999999999999e-212Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 53.6%
associate-*r/53.6%
associate-*l/53.5%
*-commutative53.5%
Simplified53.5%
if 4.4999999999999999e-212 < y < 1.2e-56Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 65.8%
Final simplification58.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.25e+98) (not (<= x 3.5e+127))) (+ (/ (* x 4.0) z) -2.0) (+ -2.0 (* -4.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.25e+98) || !(x <= 3.5e+127)) {
tmp = ((x * 4.0) / z) + -2.0;
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.25d+98)) .or. (.not. (x <= 3.5d+127))) then
tmp = ((x * 4.0d0) / z) + (-2.0d0)
else
tmp = (-2.0d0) + ((-4.0d0) * (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.25e+98) || !(x <= 3.5e+127)) {
tmp = ((x * 4.0) / z) + -2.0;
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.25e+98) or not (x <= 3.5e+127): tmp = ((x * 4.0) / z) + -2.0 else: tmp = -2.0 + (-4.0 * (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.25e+98) || !(x <= 3.5e+127)) tmp = Float64(Float64(Float64(x * 4.0) / z) + -2.0); else tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.25e+98) || ~((x <= 3.5e+127))) tmp = ((x * 4.0) / z) + -2.0; else tmp = -2.0 + (-4.0 * (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.25e+98], N[Not[LessEqual[x, 3.5e+127]], $MachinePrecision]], N[(N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+98} \lor \neg \left(x \leq 3.5 \cdot 10^{+127}\right):\\
\;\;\;\;\frac{x \cdot 4}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < -1.25e98 or 3.49999999999999978e127 < x Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 92.2%
sub-neg92.2%
+-commutative92.2%
distribute-rgt-in92.2%
distribute-neg-frac92.2%
neg-mul-192.2%
*-commutative92.2%
associate-/l*91.9%
metadata-eval91.9%
distribute-neg-frac91.9%
associate-*r*91.9%
distribute-frac-neg291.9%
associate-*l/91.9%
metadata-eval91.9%
distribute-neg-frac291.9%
distribute-neg-frac91.9%
metadata-eval91.9%
associate-*r/92.2%
metadata-eval92.2%
Simplified92.2%
if -1.25e98 < x < 3.49999999999999978e127Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 86.4%
+-commutative86.4%
distribute-rgt-in86.4%
metadata-eval86.4%
Simplified86.4%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.35e+154) (not (<= x 1.4e+132))) (/ (* x 4.0) z) (+ -2.0 (* -4.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.35e+154) || !(x <= 1.4e+132)) {
tmp = (x * 4.0) / z;
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-2.35d+154)) .or. (.not. (x <= 1.4d+132))) then
tmp = (x * 4.0d0) / z
else
tmp = (-2.0d0) + ((-4.0d0) * (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.35e+154) || !(x <= 1.4e+132)) {
tmp = (x * 4.0) / z;
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.35e+154) or not (x <= 1.4e+132): tmp = (x * 4.0) / z else: tmp = -2.0 + (-4.0 * (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.35e+154) || !(x <= 1.4e+132)) tmp = Float64(Float64(x * 4.0) / z); else tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.35e+154) || ~((x <= 1.4e+132))) tmp = (x * 4.0) / z; else tmp = -2.0 + (-4.0 * (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.35e+154], N[Not[LessEqual[x, 1.4e+132]], $MachinePrecision]], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.35 \cdot 10^{+154} \lor \neg \left(x \leq 1.4 \cdot 10^{+132}\right):\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < -2.34999999999999992e154 or 1.4e132 < x Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 79.6%
associate-*r/79.6%
*-commutative79.6%
Simplified79.6%
if -2.34999999999999992e154 < x < 1.4e132Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 84.3%
+-commutative84.3%
distribute-rgt-in84.3%
metadata-eval84.3%
Simplified84.3%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -3e+98) (not (<= x 8.2e-20))) (* x (/ 4.0 z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3e+98) || !(x <= 8.2e-20)) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-3d+98)) .or. (.not. (x <= 8.2d-20))) then
tmp = x * (4.0d0 / z)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3e+98) || !(x <= 8.2e-20)) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3e+98) or not (x <= 8.2e-20): tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3e+98) || !(x <= 8.2e-20)) tmp = Float64(x * Float64(4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3e+98) || ~((x <= 8.2e-20))) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3e+98], N[Not[LessEqual[x, 8.2e-20]], $MachinePrecision]], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+98} \lor \neg \left(x \leq 8.2 \cdot 10^{-20}\right):\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -3.0000000000000001e98 or 8.2000000000000002e-20 < x Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 63.1%
associate-*r/63.1%
associate-*l/62.9%
*-commutative62.9%
Simplified62.9%
if -3.0000000000000001e98 < x < 8.2000000000000002e-20Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 46.4%
Final simplification53.8%
(FPCore (x y z) :precision binary64 -2.0)
double code(double x, double y, double z) {
return -2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -2.0d0
end function
public static double code(double x, double y, double z) {
return -2.0;
}
def code(x, y, z): return -2.0
function code(x, y, z) return -2.0 end
function tmp = code(x, y, z) tmp = -2.0; end
code[x_, y_, z_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 34.9%
(FPCore (x y z) :precision binary64 (- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z)))))
double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * (x / z)) - (2.0d0 + (4.0d0 * (y / z)))
end function
public static double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
def code(x, y, z): return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)))
function code(x, y, z) return Float64(Float64(4.0 * Float64(x / z)) - Float64(2.0 + Float64(4.0 * Float64(y / z)))) end
function tmp = code(x, y, z) tmp = (4.0 * (x / z)) - (2.0 + (4.0 * (y / z))); end
code[x_, y_, z_] := N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(2.0 + N[(4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right)
\end{array}
herbie shell --seed 2024181
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(! :herbie-platform default (- (* 4 (/ x z)) (+ 2 (* 4 (/ y z)))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))