
(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 (<= y -3.5e+25)
t_0
(if (<= y -2.45e-91)
-2.0
(if (<= y -2.5e-212) (/ (* x 4.0) z) (if (<= y 1.45e+49) -2.0 t_0))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (y <= -3.5e+25) {
tmp = t_0;
} else if (y <= -2.45e-91) {
tmp = -2.0;
} else if (y <= -2.5e-212) {
tmp = (x * 4.0) / z;
} else if (y <= 1.45e+49) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) * (y / z)
if (y <= (-3.5d+25)) then
tmp = t_0
else if (y <= (-2.45d-91)) then
tmp = -2.0d0
else if (y <= (-2.5d-212)) then
tmp = (x * 4.0d0) / z
else if (y <= 1.45d+49) then
tmp = -2.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (y <= -3.5e+25) {
tmp = t_0;
} else if (y <= -2.45e-91) {
tmp = -2.0;
} else if (y <= -2.5e-212) {
tmp = (x * 4.0) / z;
} else if (y <= 1.45e+49) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) tmp = 0 if y <= -3.5e+25: tmp = t_0 elif y <= -2.45e-91: tmp = -2.0 elif y <= -2.5e-212: tmp = (x * 4.0) / z elif y <= 1.45e+49: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (y <= -3.5e+25) tmp = t_0; elseif (y <= -2.45e-91) tmp = -2.0; elseif (y <= -2.5e-212) tmp = Float64(Float64(x * 4.0) / z); elseif (y <= 1.45e+49) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); tmp = 0.0; if (y <= -3.5e+25) tmp = t_0; elseif (y <= -2.45e-91) tmp = -2.0; elseif (y <= -2.5e-212) tmp = (x * 4.0) / z; elseif (y <= 1.45e+49) tmp = -2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.5e+25], t$95$0, If[LessEqual[y, -2.45e-91], -2.0, If[LessEqual[y, -2.5e-212], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 1.45e+49], -2.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -3.5 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -2.45 \cdot 10^{-91}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq -2.5 \cdot 10^{-212}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+49}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.49999999999999999e25 or 1.45e49 < 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 y around inf 67.7%
*-commutative67.7%
Simplified67.7%
if -3.49999999999999999e25 < y < -2.4499999999999999e-91 or -2.50000000000000022e-212 < y < 1.45e49Initial 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 55.7%
if -2.4499999999999999e-91 < y < -2.50000000000000022e-212Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 74.7%
associate-*r/74.7%
*-commutative74.7%
Simplified74.7%
Final simplification63.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -9e+91) (not (<= x 6.5e+43))) (/ (* -4.0 (- y x)) z) (+ (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9e+91) || !(x <= 6.5e+43)) {
tmp = (-4.0 * (y - x)) / z;
} else {
tmp = (-4.0 * (y / z)) + -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 <= (-9d+91)) .or. (.not. (x <= 6.5d+43))) then
tmp = ((-4.0d0) * (y - x)) / z
else
tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -9e+91) || !(x <= 6.5e+43)) {
tmp = (-4.0 * (y - x)) / z;
} else {
tmp = (-4.0 * (y / z)) + -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9e+91) or not (x <= 6.5e+43): tmp = (-4.0 * (y - x)) / z else: tmp = (-4.0 * (y / z)) + -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9e+91) || !(x <= 6.5e+43)) tmp = Float64(Float64(-4.0 * Float64(y - x)) / z); else tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9e+91) || ~((x <= 6.5e+43))) tmp = (-4.0 * (y - x)) / z; else tmp = (-4.0 * (y / z)) + -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9e+91], N[Not[LessEqual[x, 6.5e+43]], $MachinePrecision]], N[(N[(-4.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+91} \lor \neg \left(x \leq 6.5 \cdot 10^{+43}\right):\\
\;\;\;\;\frac{-4 \cdot \left(y - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\
\end{array}
\end{array}
if x < -9e91 or 6.4999999999999998e43 < x Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around 0 88.6%
*-commutative88.6%
associate-*l/88.6%
Simplified88.6%
if -9e91 < x < 6.4999999999999998e43Initial 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 91.7%
+-commutative91.7%
distribute-rgt-in91.7%
metadata-eval91.7%
Simplified91.7%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -5e+91) (not (<= x 7.2e+62))) (* (- x y) (/ 4.0 z)) (+ (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+91) || !(x <= 7.2e+62)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = (-4.0 * (y / z)) + -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 <= (-5d+91)) .or. (.not. (x <= 7.2d+62))) then
tmp = (x - y) * (4.0d0 / z)
else
tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+91) || !(x <= 7.2e+62)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = (-4.0 * (y / z)) + -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5e+91) or not (x <= 7.2e+62): tmp = (x - y) * (4.0 / z) else: tmp = (-4.0 * (y / z)) + -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5e+91) || !(x <= 7.2e+62)) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); else tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5e+91) || ~((x <= 7.2e+62))) tmp = (x - y) * (4.0 / z); else tmp = (-4.0 * (y / z)) + -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5e+91], N[Not[LessEqual[x, 7.2e+62]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+91} \lor \neg \left(x \leq 7.2 \cdot 10^{+62}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\
\end{array}
\end{array}
if x < -5.0000000000000002e91 or 7.2e62 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 88.4%
if -5.0000000000000002e91 < x < 7.2e62Initial 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 91.7%
+-commutative91.7%
distribute-rgt-in91.7%
metadata-eval91.7%
Simplified91.7%
Final simplification90.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.1e+82) -2.0 (if (<= z 1.85e+168) (* (- x y) (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+82) {
tmp = -2.0;
} else if (z <= 1.85e+168) {
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 <= (-1.1d+82)) then
tmp = -2.0d0
else if (z <= 1.85d+168) 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 <= -1.1e+82) {
tmp = -2.0;
} else if (z <= 1.85e+168) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.1e+82: tmp = -2.0 elif z <= 1.85e+168: tmp = (x - y) * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.1e+82) tmp = -2.0; elseif (z <= 1.85e+168) 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 <= -1.1e+82) tmp = -2.0; elseif (z <= 1.85e+168) tmp = (x - y) * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.1e+82], -2.0, If[LessEqual[z, 1.85e+168], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+82}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.85 \cdot 10^{+168}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.1000000000000001e82 or 1.85000000000000005e168 < 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 77.4%
if -1.1000000000000001e82 < z < 1.85000000000000005e168Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 86.7%
(FPCore (x y z) :precision binary64 (if (<= z -4.5e+81) -2.0 (if (<= z 1.72e+115) (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.5e+81) {
tmp = -2.0;
} else if (z <= 1.72e+115) {
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.5d+81)) then
tmp = -2.0d0
else if (z <= 1.72d+115) 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.5e+81) {
tmp = -2.0;
} else if (z <= 1.72e+115) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.5e+81: tmp = -2.0 elif z <= 1.72e+115: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.5e+81) tmp = -2.0; elseif (z <= 1.72e+115) 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.5e+81) tmp = -2.0; elseif (z <= 1.72e+115) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.5e+81], -2.0, If[LessEqual[z, 1.72e+115], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+81}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.72 \cdot 10^{+115}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.50000000000000017e81 or 1.72e115 < 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 72.8%
if -4.50000000000000017e81 < z < 1.72e115Initial 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 50.0%
*-commutative50.0%
Simplified50.0%
Final simplification57.8%
(FPCore (x y z) :precision binary64 (if (<= z -7.6e+81) -2.0 (if (<= z 1.42e+115) (* y (/ -4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.6e+81) {
tmp = -2.0;
} else if (z <= 1.42e+115) {
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 <= (-7.6d+81)) then
tmp = -2.0d0
else if (z <= 1.42d+115) 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 <= -7.6e+81) {
tmp = -2.0;
} else if (z <= 1.42e+115) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.6e+81: tmp = -2.0 elif z <= 1.42e+115: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.6e+81) tmp = -2.0; elseif (z <= 1.42e+115) 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 <= -7.6e+81) tmp = -2.0; elseif (z <= 1.42e+115) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.6e+81], -2.0, If[LessEqual[z, 1.42e+115], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.6 \cdot 10^{+81}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{+115}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -7.599999999999999e81 or 1.42e115 < 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 72.8%
if -7.599999999999999e81 < z < 1.42e115Initial 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 0 89.0%
*-commutative89.0%
associate-*l/89.0%
Simplified89.0%
Taylor expanded in y around inf 50.0%
associate-/l*49.9%
*-commutative49.9%
Applied egg-rr49.9%
Final simplification57.8%
(FPCore (x y z) :precision binary64 -2.0)
double code(double x, double y, double z) {
return -2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -2.0d0
end function
public static double code(double x, double y, double z) {
return -2.0;
}
def code(x, y, z): return -2.0
function code(x, y, z) return -2.0 end
function tmp = code(x, y, z) tmp = -2.0; end
code[x_, y_, z_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 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 33.8%
(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 2024172
(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))