
(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 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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))) (t_1 (/ (* x 4.0) z)))
(if (<= y -0.0022)
t_0
(if (<= y -3.9e-241)
t_1
(if (<= y 6.4e-300)
-2.0
(if (<= y 0.19) t_1 (if (<= y 4.8e+79) -2.0 t_0)))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double t_1 = (x * 4.0) / z;
double tmp;
if (y <= -0.0022) {
tmp = t_0;
} else if (y <= -3.9e-241) {
tmp = t_1;
} else if (y <= 6.4e-300) {
tmp = -2.0;
} else if (y <= 0.19) {
tmp = t_1;
} else if (y <= 4.8e+79) {
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) :: t_1
real(8) :: tmp
t_0 = (-4.0d0) * (y / z)
t_1 = (x * 4.0d0) / z
if (y <= (-0.0022d0)) then
tmp = t_0
else if (y <= (-3.9d-241)) then
tmp = t_1
else if (y <= 6.4d-300) then
tmp = -2.0d0
else if (y <= 0.19d0) then
tmp = t_1
else if (y <= 4.8d+79) 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 t_1 = (x * 4.0) / z;
double tmp;
if (y <= -0.0022) {
tmp = t_0;
} else if (y <= -3.9e-241) {
tmp = t_1;
} else if (y <= 6.4e-300) {
tmp = -2.0;
} else if (y <= 0.19) {
tmp = t_1;
} else if (y <= 4.8e+79) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) t_1 = (x * 4.0) / z tmp = 0 if y <= -0.0022: tmp = t_0 elif y <= -3.9e-241: tmp = t_1 elif y <= 6.4e-300: tmp = -2.0 elif y <= 0.19: tmp = t_1 elif y <= 4.8e+79: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) t_1 = Float64(Float64(x * 4.0) / z) tmp = 0.0 if (y <= -0.0022) tmp = t_0; elseif (y <= -3.9e-241) tmp = t_1; elseif (y <= 6.4e-300) tmp = -2.0; elseif (y <= 0.19) tmp = t_1; elseif (y <= 4.8e+79) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); t_1 = (x * 4.0) / z; tmp = 0.0; if (y <= -0.0022) tmp = t_0; elseif (y <= -3.9e-241) tmp = t_1; elseif (y <= 6.4e-300) tmp = -2.0; elseif (y <= 0.19) tmp = t_1; elseif (y <= 4.8e+79) 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]}, Block[{t$95$1 = N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -0.0022], t$95$0, If[LessEqual[y, -3.9e-241], t$95$1, If[LessEqual[y, 6.4e-300], -2.0, If[LessEqual[y, 0.19], t$95$1, If[LessEqual[y, 4.8e+79], -2.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
t_1 := \frac{x \cdot 4}{z}\\
\mathbf{if}\;y \leq -0.0022:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -3.9 \cdot 10^{-241}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 6.4 \cdot 10^{-300}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 0.19:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+79}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.00220000000000000013 or 4.79999999999999971e79 < y Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in y around inf 68.4%
*-commutative68.4%
Simplified68.4%
if -0.00220000000000000013 < y < -3.8999999999999999e-241 or 6.40000000000000043e-300 < y < 0.19Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 52.0%
associate-*r/52.0%
*-commutative52.0%
Simplified52.0%
if -3.8999999999999999e-241 < y < 6.40000000000000043e-300 or 0.19 < y < 4.79999999999999971e79Initial program 100.0%
*-commutative100.0%
associate-/l*99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in z around inf 69.5%
Final simplification62.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.5e+118) (not (<= z 1.22e+54))) (* -4.0 (- (/ y z) -0.5)) (/ (* 4.0 (- x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+118) || !(z <= 1.22e+54)) {
tmp = -4.0 * ((y / z) - -0.5);
} else {
tmp = (4.0 * (x - 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 ((z <= (-6.5d+118)) .or. (.not. (z <= 1.22d+54))) then
tmp = (-4.0d0) * ((y / z) - (-0.5d0))
else
tmp = (4.0d0 * (x - y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+118) || !(z <= 1.22e+54)) {
tmp = -4.0 * ((y / z) - -0.5);
} else {
tmp = (4.0 * (x - y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.5e+118) or not (z <= 1.22e+54): tmp = -4.0 * ((y / z) - -0.5) else: tmp = (4.0 * (x - y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.5e+118) || !(z <= 1.22e+54)) tmp = Float64(-4.0 * Float64(Float64(y / z) - -0.5)); else tmp = Float64(Float64(4.0 * Float64(x - y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.5e+118) || ~((z <= 1.22e+54))) tmp = -4.0 * ((y / z) - -0.5); else tmp = (4.0 * (x - y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.5e+118], N[Not[LessEqual[z, 1.22e+54]], $MachinePrecision]], N[(-4.0 * N[(N[(y / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(4.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+118} \lor \neg \left(z \leq 1.22 \cdot 10^{+54}\right):\\
\;\;\;\;-4 \cdot \left(\frac{y}{z} - -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{4 \cdot \left(x - y\right)}{z}\\
\end{array}
\end{array}
if z < -6.5e118 or 1.22e54 < z 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 inf 90.9%
if -6.5e118 < z < 1.22e54Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 87.8%
associate-*r/87.8%
Simplified87.8%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.5e+118) (not (<= z 3.8e+52))) (* -4.0 (- (/ y z) -0.5)) (* (- x y) (/ 4.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+118) || !(z <= 3.8e+52)) {
tmp = -4.0 * ((y / z) - -0.5);
} else {
tmp = (x - y) * (4.0 / 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 ((z <= (-6.5d+118)) .or. (.not. (z <= 3.8d+52))) then
tmp = (-4.0d0) * ((y / z) - (-0.5d0))
else
tmp = (x - y) * (4.0d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+118) || !(z <= 3.8e+52)) {
tmp = -4.0 * ((y / z) - -0.5);
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.5e+118) or not (z <= 3.8e+52): tmp = -4.0 * ((y / z) - -0.5) else: tmp = (x - y) * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.5e+118) || !(z <= 3.8e+52)) tmp = Float64(-4.0 * Float64(Float64(y / z) - -0.5)); else tmp = Float64(Float64(x - y) * Float64(4.0 / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.5e+118) || ~((z <= 3.8e+52))) tmp = -4.0 * ((y / z) - -0.5); else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.5e+118], N[Not[LessEqual[z, 3.8e+52]], $MachinePrecision]], N[(-4.0 * N[(N[(y / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+118} \lor \neg \left(z \leq 3.8 \cdot 10^{+52}\right):\\
\;\;\;\;-4 \cdot \left(\frac{y}{z} - -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if z < -6.5e118 or 3.8e52 < z 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 inf 90.9%
if -6.5e118 < z < 3.8e52Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 87.5%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -9e+88) (not (<= x 5e+142))) (/ (* x 4.0) z) (* -4.0 (- (/ y z) -0.5))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9e+88) || !(x <= 5e+142)) {
tmp = (x * 4.0) / z;
} else {
tmp = -4.0 * ((y / z) - -0.5);
}
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 <= (-9d+88)) .or. (.not. (x <= 5d+142))) then
tmp = (x * 4.0d0) / z
else
tmp = (-4.0d0) * ((y / z) - (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -9e+88) || !(x <= 5e+142)) {
tmp = (x * 4.0) / z;
} else {
tmp = -4.0 * ((y / z) - -0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9e+88) or not (x <= 5e+142): tmp = (x * 4.0) / z else: tmp = -4.0 * ((y / z) - -0.5) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9e+88) || !(x <= 5e+142)) tmp = Float64(Float64(x * 4.0) / z); else tmp = Float64(-4.0 * Float64(Float64(y / z) - -0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9e+88) || ~((x <= 5e+142))) tmp = (x * 4.0) / z; else tmp = -4.0 * ((y / z) - -0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9e+88], N[Not[LessEqual[x, 5e+142]], $MachinePrecision]], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], N[(-4.0 * N[(N[(y / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+88} \lor \neg \left(x \leq 5 \cdot 10^{+142}\right):\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(\frac{y}{z} - -0.5\right)\\
\end{array}
\end{array}
if x < -9e88 or 5.0000000000000001e142 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 75.6%
associate-*r/75.6%
*-commutative75.6%
Simplified75.6%
if -9e88 < x < 5.0000000000000001e142Initial 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 inf 83.7%
Final simplification81.7%
(FPCore (x y z) :precision binary64 (if (<= z -1.3e+46) -2.0 (if (<= z 2.2e+102) (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.3e+46) {
tmp = -2.0;
} else if (z <= 2.2e+102) {
tmp = -4.0 * (y / 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 <= (-1.3d+46)) then
tmp = -2.0d0
else if (z <= 2.2d+102) then
tmp = (-4.0d0) * (y / 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 <= -1.3e+46) {
tmp = -2.0;
} else if (z <= 2.2e+102) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.3e+46: tmp = -2.0 elif z <= 2.2e+102: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.3e+46) tmp = -2.0; elseif (z <= 2.2e+102) tmp = Float64(-4.0 * Float64(y / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.3e+46) tmp = -2.0; elseif (z <= 2.2e+102) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.3e+46], -2.0, If[LessEqual[z, 2.2e+102], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+46}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{+102}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.30000000000000007e46 or 2.20000000000000007e102 < z Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 69.2%
if -1.30000000000000007e46 < z < 2.20000000000000007e102Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in y around inf 51.1%
*-commutative51.1%
Simplified51.1%
Final simplification57.9%
(FPCore (x y z) :precision binary64 (if (<= z -5.8e+45) -2.0 (if (<= z 8.8e+104) (* y (/ -4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.8e+45) {
tmp = -2.0;
} else if (z <= 8.8e+104) {
tmp = y * (-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 <= (-5.8d+45)) then
tmp = -2.0d0
else if (z <= 8.8d+104) then
tmp = y * ((-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 <= -5.8e+45) {
tmp = -2.0;
} else if (z <= 8.8e+104) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.8e+45: tmp = -2.0 elif z <= 8.8e+104: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.8e+45) tmp = -2.0; elseif (z <= 8.8e+104) tmp = Float64(y * Float64(-4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.8e+45) tmp = -2.0; elseif (z <= 8.8e+104) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.8e+45], -2.0, If[LessEqual[z, 8.8e+104], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+45}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{+104}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -5.7999999999999994e45 or 8.80000000000000002e104 < z Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 69.2%
if -5.7999999999999994e45 < z < 8.80000000000000002e104Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in y around inf 51.1%
metadata-eval51.1%
distribute-lft-neg-in51.1%
*-lft-identity51.1%
associate-*l/50.9%
associate-*l*50.9%
associate-*r/50.9%
metadata-eval50.9%
*-commutative50.9%
distribute-rgt-neg-in50.9%
distribute-neg-frac50.9%
metadata-eval50.9%
Simplified50.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 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 33.7%
(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 2024089
(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))