
(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))))
(if (<= z -1.5e-39)
-2.0
(if (<= z -1.12e-138)
t_0
(if (<= z 3.5e-301) (/ (* x 4.0) z) (if (<= z 9e+52) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (z <= -1.5e-39) {
tmp = -2.0;
} else if (z <= -1.12e-138) {
tmp = t_0;
} else if (z <= 3.5e-301) {
tmp = (x * 4.0) / z;
} else if (z <= 9e+52) {
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 <= (-1.5d-39)) then
tmp = -2.0d0
else if (z <= (-1.12d-138)) then
tmp = t_0
else if (z <= 3.5d-301) then
tmp = (x * 4.0d0) / z
else if (z <= 9d+52) 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 <= -1.5e-39) {
tmp = -2.0;
} else if (z <= -1.12e-138) {
tmp = t_0;
} else if (z <= 3.5e-301) {
tmp = (x * 4.0) / z;
} else if (z <= 9e+52) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) tmp = 0 if z <= -1.5e-39: tmp = -2.0 elif z <= -1.12e-138: tmp = t_0 elif z <= 3.5e-301: tmp = (x * 4.0) / z elif z <= 9e+52: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (z <= -1.5e-39) tmp = -2.0; elseif (z <= -1.12e-138) tmp = t_0; elseif (z <= 3.5e-301) tmp = Float64(Float64(x * 4.0) / z); elseif (z <= 9e+52) 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 <= -1.5e-39) tmp = -2.0; elseif (z <= -1.12e-138) tmp = t_0; elseif (z <= 3.5e-301) tmp = (x * 4.0) / z; elseif (z <= 9e+52) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.5e-39], -2.0, If[LessEqual[z, -1.12e-138], t$95$0, If[LessEqual[z, 3.5e-301], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 9e+52], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -1.5 \cdot 10^{-39}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -1.12 \cdot 10^{-138}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-301}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+52}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.50000000000000014e-39 or 8.9999999999999999e52 < 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 z around inf 66.7%
if -1.50000000000000014e-39 < z < -1.1199999999999999e-138 or 3.49999999999999992e-301 < z < 8.9999999999999999e52Initial 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 58.9%
*-commutative58.9%
Simplified58.9%
if -1.1199999999999999e-138 < z < 3.49999999999999992e-301Initial 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.8%
associate-*r/63.8%
*-commutative63.8%
Simplified63.8%
Final simplification63.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -240000.0) (not (<= z 6.8e+75))) (+ -2.0 (* -4.0 (/ y z))) (* (- x y) (/ 4.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -240000.0) || !(z <= 6.8e+75)) {
tmp = -2.0 + (-4.0 * (y / z));
} 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 <= (-240000.0d0)) .or. (.not. (z <= 6.8d+75))) then
tmp = (-2.0d0) + ((-4.0d0) * (y / z))
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 <= -240000.0) || !(z <= 6.8e+75)) {
tmp = -2.0 + (-4.0 * (y / z));
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -240000.0) or not (z <= 6.8e+75): tmp = -2.0 + (-4.0 * (y / z)) else: tmp = (x - y) * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -240000.0) || !(z <= 6.8e+75)) tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z))); 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 <= -240000.0) || ~((z <= 6.8e+75))) tmp = -2.0 + (-4.0 * (y / z)); else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -240000.0], N[Not[LessEqual[z, 6.8e+75]], $MachinePrecision]], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -240000 \lor \neg \left(z \leq 6.8 \cdot 10^{+75}\right):\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if z < -2.4e5 or 6.80000000000000022e75 < 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 x around 0 83.4%
+-commutative83.4%
distribute-rgt-in83.4%
metadata-eval83.4%
Simplified83.4%
if -2.4e5 < z < 6.80000000000000022e75Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 88.9%
Final simplification86.6%
(FPCore (x y z) :precision binary64 (if (<= y -1.7e+49) (* (- x y) (/ 4.0 z)) (if (<= y 3.8e+40) (+ (/ (* x 4.0) z) -2.0) (+ -2.0 (* -4.0 (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+49) {
tmp = (x - y) * (4.0 / z);
} else if (y <= 3.8e+40) {
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 (y <= (-1.7d+49)) then
tmp = (x - y) * (4.0d0 / z)
else if (y <= 3.8d+40) 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 (y <= -1.7e+49) {
tmp = (x - y) * (4.0 / z);
} else if (y <= 3.8e+40) {
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 y <= -1.7e+49: tmp = (x - y) * (4.0 / z) elif y <= 3.8e+40: 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 (y <= -1.7e+49) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); elseif (y <= 3.8e+40) 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 (y <= -1.7e+49) tmp = (x - y) * (4.0 / z); elseif (y <= 3.8e+40) 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[LessEqual[y, -1.7e+49], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.8e+40], 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}\;y \leq -1.7 \cdot 10^{+49}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+40}:\\
\;\;\;\;\frac{x \cdot 4}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -1.7e49Initial program 100.0%
*-commutative100.0%
associate-/l*99.9%
associate--l-99.9%
Simplified99.9%
Taylor expanded in z around 0 85.2%
if -1.7e49 < y < 3.80000000000000004e40Initial 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 0 91.9%
sub-neg91.9%
+-commutative91.9%
distribute-rgt-in91.9%
distribute-neg-frac91.9%
neg-mul-191.9%
*-commutative91.9%
associate-/l*91.8%
metadata-eval91.8%
distribute-neg-frac91.8%
associate-*r*91.8%
distribute-frac-neg291.8%
associate-*l/91.8%
metadata-eval91.8%
distribute-neg-frac291.8%
distribute-neg-frac91.8%
metadata-eval91.8%
associate-*r/91.9%
metadata-eval91.9%
Simplified91.9%
if 3.80000000000000004e40 < y 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 0 94.4%
+-commutative94.4%
distribute-rgt-in94.4%
metadata-eval94.4%
Simplified94.4%
Final simplification90.9%
(FPCore (x y z) :precision binary64 (if (<= z -2.2e+177) -2.0 (if (<= z 2.25e+77) (* (- x y) (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.2e+177) {
tmp = -2.0;
} else if (z <= 2.25e+77) {
tmp = (x - 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 <= (-2.2d+177)) then
tmp = -2.0d0
else if (z <= 2.25d+77) then
tmp = (x - 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 <= -2.2e+177) {
tmp = -2.0;
} else if (z <= 2.25e+77) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.2e+177: tmp = -2.0 elif z <= 2.25e+77: tmp = (x - y) * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.2e+177) tmp = -2.0; elseif (z <= 2.25e+77) tmp = Float64(Float64(x - 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 <= -2.2e+177) tmp = -2.0; elseif (z <= 2.25e+77) tmp = (x - y) * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.2e+177], -2.0, If[LessEqual[z, 2.25e+77], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{+177}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 2.25 \cdot 10^{+77}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.1999999999999998e177 or 2.25000000000000012e77 < 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 z around inf 80.9%
if -2.1999999999999998e177 < z < 2.25000000000000012e77Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 83.4%
(FPCore (x y z) :precision binary64 (if (<= z -4.6e-40) -2.0 (if (<= z 2.05e+58) (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.6e-40) {
tmp = -2.0;
} else if (z <= 2.05e+58) {
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 <= (-4.6d-40)) then
tmp = -2.0d0
else if (z <= 2.05d+58) 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 <= -4.6e-40) {
tmp = -2.0;
} else if (z <= 2.05e+58) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.6e-40: tmp = -2.0 elif z <= 2.05e+58: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.6e-40) tmp = -2.0; elseif (z <= 2.05e+58) 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 <= -4.6e-40) tmp = -2.0; elseif (z <= 2.05e+58) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.6e-40], -2.0, If[LessEqual[z, 2.05e+58], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{-40}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 2.05 \cdot 10^{+58}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.6e-40 or 2.05e58 < 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 z around inf 66.7%
if -4.6e-40 < z < 2.05e58Initial 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 53.6%
*-commutative53.6%
Simplified53.6%
Final simplification59.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.12e-40) -2.0 (if (<= z 1.2e+54) (* y (/ -4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.12e-40) {
tmp = -2.0;
} else if (z <= 1.2e+54) {
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 <= (-1.12d-40)) then
tmp = -2.0d0
else if (z <= 1.2d+54) 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 <= -1.12e-40) {
tmp = -2.0;
} else if (z <= 1.2e+54) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.12e-40: tmp = -2.0 elif z <= 1.2e+54: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.12e-40) tmp = -2.0; elseif (z <= 1.2e+54) 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 <= -1.12e-40) tmp = -2.0; elseif (z <= 1.2e+54) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.12e-40], -2.0, If[LessEqual[z, 1.2e+54], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.12 \cdot 10^{-40}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{+54}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.1200000000000001e-40 or 1.19999999999999999e54 < 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 z around inf 66.7%
if -1.1200000000000001e-40 < z < 1.19999999999999999e54Initial 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%
add-cube-cbrt98.9%
pow398.9%
sub-neg98.9%
metadata-eval98.9%
distribute-lft-in98.9%
metadata-eval98.9%
Applied egg-rr98.9%
Taylor expanded in y around inf 53.6%
associate-*r/53.6%
Simplified53.6%
*-commutative53.6%
associate-/l*53.5%
Applied egg-rr53.5%
(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%
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 35.6%
(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 2024159
(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))