
(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 9 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.6%
remove-double-neg99.6%
neg-mul-199.6%
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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* -4.0 y) z)))
(if (<= z -5.2e-42)
-2.0
(if (<= z 5.8e-171)
t_0
(if (<= z 1.85e-53) (/ (* x 4.0) z) (if (<= z 5.5e+20) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = (-4.0 * y) / z;
double tmp;
if (z <= -5.2e-42) {
tmp = -2.0;
} else if (z <= 5.8e-171) {
tmp = t_0;
} else if (z <= 1.85e-53) {
tmp = (x * 4.0) / z;
} else if (z <= 5.5e+20) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = ((-4.0d0) * y) / z
if (z <= (-5.2d-42)) then
tmp = -2.0d0
else if (z <= 5.8d-171) then
tmp = t_0
else if (z <= 1.85d-53) then
tmp = (x * 4.0d0) / z
else if (z <= 5.5d+20) then
tmp = t_0
else
tmp = -2.0d0
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 (z <= -5.2e-42) {
tmp = -2.0;
} else if (z <= 5.8e-171) {
tmp = t_0;
} else if (z <= 1.85e-53) {
tmp = (x * 4.0) / z;
} else if (z <= 5.5e+20) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = (-4.0 * y) / z tmp = 0 if z <= -5.2e-42: tmp = -2.0 elif z <= 5.8e-171: tmp = t_0 elif z <= 1.85e-53: tmp = (x * 4.0) / z elif z <= 5.5e+20: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-4.0 * y) / z) tmp = 0.0 if (z <= -5.2e-42) tmp = -2.0; elseif (z <= 5.8e-171) tmp = t_0; elseif (z <= 1.85e-53) tmp = Float64(Float64(x * 4.0) / z); elseif (z <= 5.5e+20) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (-4.0 * y) / z; tmp = 0.0; if (z <= -5.2e-42) tmp = -2.0; elseif (z <= 5.8e-171) tmp = t_0; elseif (z <= 1.85e-53) tmp = (x * 4.0) / z; elseif (z <= 5.5e+20) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -5.2e-42], -2.0, If[LessEqual[z, 5.8e-171], t$95$0, If[LessEqual[z, 1.85e-53], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 5.5e+20], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-4 \cdot y}{z}\\
\mathbf{if}\;z \leq -5.2 \cdot 10^{-42}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-171}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.85 \cdot 10^{-53}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{+20}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -5.2e-42 or 5.5e20 < z Initial program 99.2%
remove-double-neg99.2%
neg-mul-199.2%
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 66.0%
if -5.2e-42 < z < 5.7999999999999997e-171 or 1.84999999999999991e-53 < z < 5.5e20Initial program 100.0%
Taylor expanded in y around inf 67.0%
*-commutative67.0%
Simplified67.0%
if 5.7999999999999997e-171 < z < 1.84999999999999991e-53Initial program 99.8%
Taylor expanded in x around inf 62.2%
*-commutative62.2%
Simplified62.2%
Final simplification66.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ -4.0 (/ z y))))
(if (<= z -4.7e-42)
-2.0
(if (<= z 1.26e-170)
t_0
(if (<= z 3.3e-53) (/ (* x 4.0) z) (if (<= z 1.8e+20) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = -4.0 / (z / y);
double tmp;
if (z <= -4.7e-42) {
tmp = -2.0;
} else if (z <= 1.26e-170) {
tmp = t_0;
} else if (z <= 3.3e-53) {
tmp = (x * 4.0) / z;
} else if (z <= 1.8e+20) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) / (z / y)
if (z <= (-4.7d-42)) then
tmp = -2.0d0
else if (z <= 1.26d-170) then
tmp = t_0
else if (z <= 3.3d-53) then
tmp = (x * 4.0d0) / z
else if (z <= 1.8d+20) then
tmp = t_0
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 / (z / y);
double tmp;
if (z <= -4.7e-42) {
tmp = -2.0;
} else if (z <= 1.26e-170) {
tmp = t_0;
} else if (z <= 3.3e-53) {
tmp = (x * 4.0) / z;
} else if (z <= 1.8e+20) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 / (z / y) tmp = 0 if z <= -4.7e-42: tmp = -2.0 elif z <= 1.26e-170: tmp = t_0 elif z <= 3.3e-53: tmp = (x * 4.0) / z elif z <= 1.8e+20: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 / Float64(z / y)) tmp = 0.0 if (z <= -4.7e-42) tmp = -2.0; elseif (z <= 1.26e-170) tmp = t_0; elseif (z <= 3.3e-53) tmp = Float64(Float64(x * 4.0) / z); elseif (z <= 1.8e+20) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 / (z / y); tmp = 0.0; if (z <= -4.7e-42) tmp = -2.0; elseif (z <= 1.26e-170) tmp = t_0; elseif (z <= 3.3e-53) tmp = (x * 4.0) / z; elseif (z <= 1.8e+20) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 / N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.7e-42], -2.0, If[LessEqual[z, 1.26e-170], t$95$0, If[LessEqual[z, 3.3e-53], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.8e+20], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-4}{\frac{z}{y}}\\
\mathbf{if}\;z \leq -4.7 \cdot 10^{-42}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.26 \cdot 10^{-170}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{-53}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+20}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.7000000000000001e-42 or 1.8e20 < z Initial program 99.2%
remove-double-neg99.2%
neg-mul-199.2%
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 66.0%
if -4.7000000000000001e-42 < z < 1.26e-170 or 3.30000000000000004e-53 < z < 1.8e20Initial program 100.0%
Taylor expanded in y around inf 67.0%
*-commutative67.0%
Simplified67.0%
Taylor expanded in y around 0 67.0%
associate-*r/67.0%
associate-*l/66.8%
associate-/r/66.8%
Simplified66.8%
if 1.26e-170 < z < 3.30000000000000004e-53Initial program 99.8%
Taylor expanded in x around inf 62.2%
*-commutative62.2%
Simplified62.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ -4.0 (/ z y))))
(if (<= z -5.6e-42)
-2.0
(if (<= z 6.4e-174)
t_0
(if (<= z 1.3e-53) (* x (/ 4.0 z)) (if (<= z 6.5e+20) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = -4.0 / (z / y);
double tmp;
if (z <= -5.6e-42) {
tmp = -2.0;
} else if (z <= 6.4e-174) {
tmp = t_0;
} else if (z <= 1.3e-53) {
tmp = x * (4.0 / z);
} else if (z <= 6.5e+20) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) / (z / y)
if (z <= (-5.6d-42)) then
tmp = -2.0d0
else if (z <= 6.4d-174) then
tmp = t_0
else if (z <= 1.3d-53) then
tmp = x * (4.0d0 / z)
else if (z <= 6.5d+20) then
tmp = t_0
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 / (z / y);
double tmp;
if (z <= -5.6e-42) {
tmp = -2.0;
} else if (z <= 6.4e-174) {
tmp = t_0;
} else if (z <= 1.3e-53) {
tmp = x * (4.0 / z);
} else if (z <= 6.5e+20) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 / (z / y) tmp = 0 if z <= -5.6e-42: tmp = -2.0 elif z <= 6.4e-174: tmp = t_0 elif z <= 1.3e-53: tmp = x * (4.0 / z) elif z <= 6.5e+20: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 / Float64(z / y)) tmp = 0.0 if (z <= -5.6e-42) tmp = -2.0; elseif (z <= 6.4e-174) tmp = t_0; elseif (z <= 1.3e-53) tmp = Float64(x * Float64(4.0 / z)); elseif (z <= 6.5e+20) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 / (z / y); tmp = 0.0; if (z <= -5.6e-42) tmp = -2.0; elseif (z <= 6.4e-174) tmp = t_0; elseif (z <= 1.3e-53) tmp = x * (4.0 / z); elseif (z <= 6.5e+20) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 / N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.6e-42], -2.0, If[LessEqual[z, 6.4e-174], t$95$0, If[LessEqual[z, 1.3e-53], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e+20], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-4}{\frac{z}{y}}\\
\mathbf{if}\;z \leq -5.6 \cdot 10^{-42}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 6.4 \cdot 10^{-174}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-53}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+20}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -5.59999999999999996e-42 or 6.5e20 < z Initial program 99.2%
remove-double-neg99.2%
neg-mul-199.2%
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 66.0%
if -5.59999999999999996e-42 < z < 6.4e-174 or 1.29999999999999998e-53 < z < 6.5e20Initial program 100.0%
Taylor expanded in y around inf 67.0%
*-commutative67.0%
Simplified67.0%
Taylor expanded in y around 0 67.0%
associate-*r/67.0%
associate-*l/66.8%
associate-/r/66.8%
Simplified66.8%
if 6.4e-174 < z < 1.29999999999999998e-53Initial program 99.8%
remove-double-neg99.8%
neg-mul-199.8%
times-frac99.8%
metadata-eval99.8%
div-sub99.9%
distribute-frac-neg299.9%
distribute-frac-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
*-commutative99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 62.2%
associate-*r/62.2%
associate-*l/62.0%
*-commutative62.0%
Simplified62.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.5e+112) (not (<= x 3.1e+49))) (+ (* x (/ 4.0 z)) -2.0) (+ -2.0 (* -4.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.5e+112) || !(x <= 3.1e+49)) {
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 <= (-2.5d+112)) .or. (.not. (x <= 3.1d+49))) 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 <= -2.5e+112) || !(x <= 3.1e+49)) {
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 <= -2.5e+112) or not (x <= 3.1e+49): 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 <= -2.5e+112) || !(x <= 3.1e+49)) tmp = Float64(Float64(x * Float64(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 <= -2.5e+112) || ~((x <= 3.1e+49))) 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, -2.5e+112], N[Not[LessEqual[x, 3.1e+49]], $MachinePrecision]], N[(N[(x * N[(4.0 / z), $MachinePrecision]), $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 -2.5 \cdot 10^{+112} \lor \neg \left(x \leq 3.1 \cdot 10^{+49}\right):\\
\;\;\;\;x \cdot \frac{4}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < -2.5e112 or 3.09999999999999992e49 < x Initial program 98.9%
remove-double-neg98.9%
neg-mul-198.9%
times-frac99.9%
metadata-eval99.9%
div-sub99.9%
distribute-frac-neg299.9%
distribute-frac-neg99.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
*-commutative99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 91.2%
sub-neg91.2%
+-commutative91.2%
distribute-lft-in91.2%
metadata-eval91.2%
distribute-neg-frac291.2%
times-frac91.2%
neg-mul-191.2%
remove-double-neg91.2%
associate-*l/91.1%
*-commutative91.1%
metadata-eval91.1%
Simplified91.1%
if -2.5e112 < x < 3.09999999999999992e49Initial 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 0 90.3%
+-commutative90.3%
distribute-rgt-in90.3%
metadata-eval90.3%
Simplified90.3%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.6e-42) (not (<= z 2.7e+20))) (+ (* x (/ 4.0 z)) -2.0) (* (/ 4.0 z) (- x y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.6e-42) || !(z <= 2.7e+20)) {
tmp = (x * (4.0 / z)) + -2.0;
} else {
tmp = (4.0 / z) * (x - y);
}
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 ((z <= (-5.6d-42)) .or. (.not. (z <= 2.7d+20))) then
tmp = (x * (4.0d0 / z)) + (-2.0d0)
else
tmp = (4.0d0 / z) * (x - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.6e-42) || !(z <= 2.7e+20)) {
tmp = (x * (4.0 / z)) + -2.0;
} else {
tmp = (4.0 / z) * (x - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.6e-42) or not (z <= 2.7e+20): tmp = (x * (4.0 / z)) + -2.0 else: tmp = (4.0 / z) * (x - y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.6e-42) || !(z <= 2.7e+20)) tmp = Float64(Float64(x * Float64(4.0 / z)) + -2.0); else tmp = Float64(Float64(4.0 / z) * Float64(x - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.6e-42) || ~((z <= 2.7e+20))) tmp = (x * (4.0 / z)) + -2.0; else tmp = (4.0 / z) * (x - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.6e-42], N[Not[LessEqual[z, 2.7e+20]], $MachinePrecision]], N[(N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], N[(N[(4.0 / z), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{-42} \lor \neg \left(z \leq 2.7 \cdot 10^{+20}\right):\\
\;\;\;\;x \cdot \frac{4}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;\frac{4}{z} \cdot \left(x - y\right)\\
\end{array}
\end{array}
if z < -5.59999999999999996e-42 or 2.7e20 < z Initial program 99.2%
remove-double-neg99.2%
neg-mul-199.2%
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 83.2%
sub-neg83.2%
+-commutative83.2%
distribute-lft-in83.2%
metadata-eval83.2%
distribute-neg-frac283.2%
times-frac83.2%
neg-mul-183.2%
remove-double-neg83.2%
associate-*l/83.1%
*-commutative83.1%
metadata-eval83.1%
Simplified83.1%
if -5.59999999999999996e-42 < z < 2.7e20Initial program 99.9%
*-commutative99.9%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 94.2%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.1e+179) -2.0 (if (<= z 2.7e+122) (* (/ 4.0 z) (- x y)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+179) {
tmp = -2.0;
} else if (z <= 2.7e+122) {
tmp = (4.0 / z) * (x - y);
} 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 (z <= (-1.1d+179)) then
tmp = -2.0d0
else if (z <= 2.7d+122) then
tmp = (4.0d0 / z) * (x - y)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+179) {
tmp = -2.0;
} else if (z <= 2.7e+122) {
tmp = (4.0 / z) * (x - y);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.1e+179: tmp = -2.0 elif z <= 2.7e+122: tmp = (4.0 / z) * (x - y) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.1e+179) tmp = -2.0; elseif (z <= 2.7e+122) tmp = Float64(Float64(4.0 / z) * Float64(x - y)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.1e+179) tmp = -2.0; elseif (z <= 2.7e+122) tmp = (4.0 / z) * (x - y); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.1e+179], -2.0, If[LessEqual[z, 2.7e+122], N[(N[(4.0 / z), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+179}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{+122}:\\
\;\;\;\;\frac{4}{z} \cdot \left(x - y\right)\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.1e179 or 2.6999999999999998e122 < z Initial program 98.6%
remove-double-neg98.6%
neg-mul-198.6%
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 85.1%
if -1.1e179 < z < 2.6999999999999998e122Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 84.5%
Final simplification84.7%
(FPCore (x y z) :precision binary64 (if (<= z -6.5e-45) -2.0 (if (<= z 1.45e+110) (* x (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.5e-45) {
tmp = -2.0;
} else if (z <= 1.45e+110) {
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 (z <= (-6.5d-45)) then
tmp = -2.0d0
else if (z <= 1.45d+110) 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 (z <= -6.5e-45) {
tmp = -2.0;
} else if (z <= 1.45e+110) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.5e-45: tmp = -2.0 elif z <= 1.45e+110: tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.5e-45) tmp = -2.0; elseif (z <= 1.45e+110) 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 (z <= -6.5e-45) tmp = -2.0; elseif (z <= 1.45e+110) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.5e-45], -2.0, If[LessEqual[z, 1.45e+110], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{-45}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+110}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -6.4999999999999995e-45 or 1.45e110 < z Initial program 99.1%
remove-double-neg99.1%
neg-mul-199.1%
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 68.3%
if -6.4999999999999995e-45 < z < 1.45e110Initial 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 42.0%
associate-*r/42.0%
associate-*l/41.9%
*-commutative41.9%
Simplified41.9%
(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.6%
remove-double-neg99.6%
neg-mul-199.6%
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 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 2024132
(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))