
(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.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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (* -4.0 (/ y z))))
(if (<= x -3.1e+48)
t_0
(if (<= x -3.8e-164)
t_1
(if (<= x 1.15e-266) -2.0 (if (<= x 1.25e+34) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -3.1e+48) {
tmp = t_0;
} else if (x <= -3.8e-164) {
tmp = t_1;
} else if (x <= 1.15e-266) {
tmp = -2.0;
} else if (x <= 1.25e+34) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / z)
t_1 = (-4.0d0) * (y / z)
if (x <= (-3.1d+48)) then
tmp = t_0
else if (x <= (-3.8d-164)) then
tmp = t_1
else if (x <= 1.15d-266) then
tmp = -2.0d0
else if (x <= 1.25d+34) then
tmp = t_1
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 * (x / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -3.1e+48) {
tmp = t_0;
} else if (x <= -3.8e-164) {
tmp = t_1;
} else if (x <= 1.15e-266) {
tmp = -2.0;
} else if (x <= 1.25e+34) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = -4.0 * (y / z) tmp = 0 if x <= -3.1e+48: tmp = t_0 elif x <= -3.8e-164: tmp = t_1 elif x <= 1.15e-266: tmp = -2.0 elif x <= 1.25e+34: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (x <= -3.1e+48) tmp = t_0; elseif (x <= -3.8e-164) tmp = t_1; elseif (x <= 1.15e-266) tmp = -2.0; elseif (x <= 1.25e+34) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); t_1 = -4.0 * (y / z); tmp = 0.0; if (x <= -3.1e+48) tmp = t_0; elseif (x <= -3.8e-164) tmp = t_1; elseif (x <= 1.15e-266) tmp = -2.0; elseif (x <= 1.25e+34) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.1e+48], t$95$0, If[LessEqual[x, -3.8e-164], t$95$1, If[LessEqual[x, 1.15e-266], -2.0, If[LessEqual[x, 1.25e+34], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -3.1 \cdot 10^{+48}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -3.8 \cdot 10^{-164}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-266}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+34}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.10000000000000005e48 or 1.25e34 < x Initial program 99.2%
*-commutative99.2%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 71.3%
if -3.10000000000000005e48 < x < -3.79999999999999989e-164 or 1.14999999999999998e-266 < x < 1.25e34Initial program 99.0%
*-commutative99.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in y around inf 59.2%
*-commutative59.2%
Simplified59.2%
if -3.79999999999999989e-164 < x < 1.14999999999999998e-266Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 66.8%
Final simplification65.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (* y (/ -4.0 z))))
(if (<= x -6.8e+48)
t_0
(if (<= x -6e-165)
t_1
(if (<= x 3.2e-272) -2.0 (if (<= x 3.45e+34) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = y * (-4.0 / z);
double tmp;
if (x <= -6.8e+48) {
tmp = t_0;
} else if (x <= -6e-165) {
tmp = t_1;
} else if (x <= 3.2e-272) {
tmp = -2.0;
} else if (x <= 3.45e+34) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / z)
t_1 = y * ((-4.0d0) / z)
if (x <= (-6.8d+48)) then
tmp = t_0
else if (x <= (-6d-165)) then
tmp = t_1
else if (x <= 3.2d-272) then
tmp = -2.0d0
else if (x <= 3.45d+34) then
tmp = t_1
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 * (x / z);
double t_1 = y * (-4.0 / z);
double tmp;
if (x <= -6.8e+48) {
tmp = t_0;
} else if (x <= -6e-165) {
tmp = t_1;
} else if (x <= 3.2e-272) {
tmp = -2.0;
} else if (x <= 3.45e+34) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = y * (-4.0 / z) tmp = 0 if x <= -6.8e+48: tmp = t_0 elif x <= -6e-165: tmp = t_1 elif x <= 3.2e-272: tmp = -2.0 elif x <= 3.45e+34: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) t_1 = Float64(y * Float64(-4.0 / z)) tmp = 0.0 if (x <= -6.8e+48) tmp = t_0; elseif (x <= -6e-165) tmp = t_1; elseif (x <= 3.2e-272) tmp = -2.0; elseif (x <= 3.45e+34) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); t_1 = y * (-4.0 / z); tmp = 0.0; if (x <= -6.8e+48) tmp = t_0; elseif (x <= -6e-165) tmp = t_1; elseif (x <= 3.2e-272) tmp = -2.0; elseif (x <= 3.45e+34) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.8e+48], t$95$0, If[LessEqual[x, -6e-165], t$95$1, If[LessEqual[x, 3.2e-272], -2.0, If[LessEqual[x, 3.45e+34], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := y \cdot \frac{-4}{z}\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{+48}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-165}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-272}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 3.45 \cdot 10^{+34}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -6.8000000000000006e48 or 3.45000000000000019e34 < x Initial program 99.2%
*-commutative99.2%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 71.3%
if -6.8000000000000006e48 < x < -5.99999999999999958e-165 or 3.2e-272 < x < 3.45000000000000019e34Initial program 99.0%
*-commutative99.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in y around inf 59.2%
associate-*r/58.3%
*-commutative58.3%
associate-*r/59.0%
Simplified59.0%
if -5.99999999999999958e-165 < x < 3.2e-272Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 66.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (+ -0.5 (/ x z)) (- -4.0))))
(if (<= x -1.05e+48)
t_0
(if (<= x -6e-79)
(* 4.0 (/ (- x y) z))
(if (<= x 3.5e+35) (* 4.0 (- -0.5 (/ y z))) t_0)))))
double code(double x, double y, double z) {
double t_0 = (-0.5 + (x / z)) * -(-4.0);
double tmp;
if (x <= -1.05e+48) {
tmp = t_0;
} else if (x <= -6e-79) {
tmp = 4.0 * ((x - y) / z);
} else if (x <= 3.5e+35) {
tmp = 4.0 * (-0.5 - (y / 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 = ((-0.5d0) + (x / z)) * -(-4.0d0)
if (x <= (-1.05d+48)) then
tmp = t_0
else if (x <= (-6d-79)) then
tmp = 4.0d0 * ((x - y) / z)
else if (x <= 3.5d+35) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (-0.5 + (x / z)) * -(-4.0);
double tmp;
if (x <= -1.05e+48) {
tmp = t_0;
} else if (x <= -6e-79) {
tmp = 4.0 * ((x - y) / z);
} else if (x <= 3.5e+35) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (-0.5 + (x / z)) * -(-4.0) tmp = 0 if x <= -1.05e+48: tmp = t_0 elif x <= -6e-79: tmp = 4.0 * ((x - y) / z) elif x <= 3.5e+35: tmp = 4.0 * (-0.5 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-0.5 + Float64(x / z)) * Float64(-(-4.0))) tmp = 0.0 if (x <= -1.05e+48) tmp = t_0; elseif (x <= -6e-79) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); elseif (x <= 3.5e+35) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (-0.5 + (x / z)) * -(-4.0); tmp = 0.0; if (x <= -1.05e+48) tmp = t_0; elseif (x <= -6e-79) tmp = 4.0 * ((x - y) / z); elseif (x <= 3.5e+35) tmp = 4.0 * (-0.5 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision] * (--4.0)), $MachinePrecision]}, If[LessEqual[x, -1.05e+48], t$95$0, If[LessEqual[x, -6e-79], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.5e+35], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-0.5 + \frac{x}{z}\right) \cdot \left(--4\right)\\
\mathbf{if}\;x \leq -1.05 \cdot 10^{+48}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-79}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+35}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.0499999999999999e48 or 3.5000000000000001e35 < x 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 90.1%
neg-mul-190.1%
distribute-neg-frac90.1%
Simplified90.1%
if -1.0499999999999999e48 < x < -5.99999999999999999e-79Initial program 94.4%
*-commutative94.4%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 84.2%
if -5.99999999999999999e-79 < x < 3.5000000000000001e35Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around 0 94.0%
associate-*r/94.0%
metadata-eval94.0%
+-commutative94.0%
*-commutative94.0%
fma-undefine94.0%
associate-*r*94.0%
neg-mul-194.0%
associate-/l*94.0%
fma-undefine94.0%
*-commutative94.0%
distribute-neg-in94.0%
sub-neg94.0%
div-sub94.0%
distribute-neg-frac94.0%
associate-/l*94.0%
*-inverses94.0%
metadata-eval94.0%
metadata-eval94.0%
Simplified94.0%
Final simplification91.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.26e-79) (not (<= x 2.3e+32))) (* 4.0 (/ (- x y) z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.26e-79) || !(x <= 2.3e+32)) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = 4.0 * (-0.5 - (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.26d-79)) .or. (.not. (x <= 2.3d+32))) then
tmp = 4.0d0 * ((x - y) / z)
else
tmp = 4.0d0 * ((-0.5d0) - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.26e-79) || !(x <= 2.3e+32)) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.26e-79) or not (x <= 2.3e+32): tmp = 4.0 * ((x - y) / z) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.26e-79) || !(x <= 2.3e+32)) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); else tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.26e-79) || ~((x <= 2.3e+32))) tmp = 4.0 * ((x - y) / z); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.26e-79], N[Not[LessEqual[x, 2.3e+32]], $MachinePrecision]], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.26 \cdot 10^{-79} \lor \neg \left(x \leq 2.3 \cdot 10^{+32}\right):\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -1.25999999999999993e-79 or 2.3e32 < x Initial program 98.5%
*-commutative98.5%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 81.7%
if -1.25999999999999993e-79 < x < 2.3e32Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around 0 93.9%
associate-*r/93.9%
metadata-eval93.9%
+-commutative93.9%
*-commutative93.9%
fma-undefine93.9%
associate-*r*93.9%
neg-mul-193.9%
associate-/l*93.9%
fma-undefine93.9%
*-commutative93.9%
distribute-neg-in93.9%
sub-neg93.9%
div-sub94.0%
distribute-neg-frac94.0%
associate-/l*94.0%
*-inverses94.0%
metadata-eval94.0%
metadata-eval94.0%
Simplified94.0%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.1e+63) (not (<= x 9.8e+35))) (* 4.0 (/ x z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.1e+63) || !(x <= 9.8e+35)) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (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 <= (-3.1d+63)) .or. (.not. (x <= 9.8d+35))) then
tmp = 4.0d0 * (x / z)
else
tmp = 4.0d0 * ((-0.5d0) - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.1e+63) || !(x <= 9.8e+35)) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.1e+63) or not (x <= 9.8e+35): tmp = 4.0 * (x / z) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.1e+63) || !(x <= 9.8e+35)) tmp = Float64(4.0 * Float64(x / z)); else tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.1e+63) || ~((x <= 9.8e+35))) tmp = 4.0 * (x / z); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.1e+63], N[Not[LessEqual[x, 9.8e+35]], $MachinePrecision]], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{+63} \lor \neg \left(x \leq 9.8 \cdot 10^{+35}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -3.1000000000000001e63 or 9.8000000000000005e35 < x Initial program 99.1%
*-commutative99.1%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 72.6%
if -3.1000000000000001e63 < x < 9.8000000000000005e35Initial program 99.3%
*-commutative99.3%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around 0 88.7%
associate-*r/88.0%
metadata-eval88.0%
+-commutative88.0%
*-commutative88.0%
fma-undefine88.0%
associate-*r*88.0%
neg-mul-188.0%
associate-/l*88.7%
fma-undefine88.7%
*-commutative88.7%
distribute-neg-in88.7%
sub-neg88.7%
div-sub88.7%
distribute-neg-frac88.7%
associate-/l*88.7%
*-inverses88.7%
metadata-eval88.7%
metadata-eval88.7%
Simplified88.7%
Final simplification81.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.2e-84) (not (<= x 2.4e+23))) (* 4.0 (/ x z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.2e-84) || !(x <= 2.4e+23)) {
tmp = 4.0 * (x / 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 <= (-2.2d-84)) .or. (.not. (x <= 2.4d+23))) then
tmp = 4.0d0 * (x / 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 <= -2.2e-84) || !(x <= 2.4e+23)) {
tmp = 4.0 * (x / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.2e-84) or not (x <= 2.4e+23): tmp = 4.0 * (x / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.2e-84) || !(x <= 2.4e+23)) tmp = Float64(4.0 * Float64(x / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.2e-84) || ~((x <= 2.4e+23))) tmp = 4.0 * (x / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.2e-84], N[Not[LessEqual[x, 2.4e+23]], $MachinePrecision]], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{-84} \lor \neg \left(x \leq 2.4 \cdot 10^{+23}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -2.1999999999999999e-84 or 2.4e23 < x Initial program 98.5%
*-commutative98.5%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 65.1%
if -2.1999999999999999e-84 < x < 2.4e23Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in z around inf 42.6%
Final simplification54.4%
(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.2%
*-commutative99.2%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 30.4%
(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 2024085
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))