
(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 (if (or (<= y -3.4e+82) (not (<= y 2.8e+77))) (+ (* -4.0 (/ y z)) -2.0) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e+82) || !(y <= 2.8e+77)) {
tmp = (-4.0 * (y / z)) + -2.0;
} else {
tmp = -4.0 * (0.5 - (x / 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 <= (-3.4d+82)) .or. (.not. (y <= 2.8d+77))) then
tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e+82) || !(y <= 2.8e+77)) {
tmp = (-4.0 * (y / z)) + -2.0;
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e+82) or not (y <= 2.8e+77): tmp = (-4.0 * (y / z)) + -2.0 else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e+82) || !(y <= 2.8e+77)) tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.4e+82) || ~((y <= 2.8e+77))) tmp = (-4.0 * (y / z)) + -2.0; else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e+82], N[Not[LessEqual[y, 2.8e+77]], $MachinePrecision]], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+82} \lor \neg \left(y \leq 2.8 \cdot 10^{+77}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -3.39999999999999994e82 or 2.8e77 < 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 92.3%
+-commutative92.3%
distribute-rgt-in92.3%
metadata-eval92.3%
Simplified92.3%
if -3.39999999999999994e82 < y < 2.8e77Initial program 99.3%
remove-double-neg99.3%
neg-mul-199.3%
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.8%
*-commutative90.8%
Simplified90.8%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.2e+83) (not (<= y 1.8e+149))) (/ (* -4.0 y) z) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e+83) || !(y <= 1.8e+149)) {
tmp = (-4.0 * y) / z;
} else {
tmp = -4.0 * (0.5 - (x / 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.2d+83)) .or. (.not. (y <= 1.8d+149))) then
tmp = ((-4.0d0) * y) / z
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e+83) || !(y <= 1.8e+149)) {
tmp = (-4.0 * y) / z;
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.2e+83) or not (y <= 1.8e+149): tmp = (-4.0 * y) / z else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.2e+83) || !(y <= 1.8e+149)) tmp = Float64(Float64(-4.0 * y) / z); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.2e+83) || ~((y <= 1.8e+149))) tmp = (-4.0 * y) / z; else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.2e+83], N[Not[LessEqual[y, 1.8e+149]], $MachinePrecision]], N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+83} \lor \neg \left(y \leq 1.8 \cdot 10^{+149}\right):\\
\;\;\;\;\frac{-4 \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.19999999999999996e83 or 1.79999999999999997e149 < y Initial program 100.0%
Taylor expanded in y around inf 78.6%
*-commutative78.6%
Simplified78.6%
if -1.19999999999999996e83 < y < 1.79999999999999997e149Initial program 99.4%
remove-double-neg99.4%
neg-mul-199.4%
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 89.8%
*-commutative89.8%
Simplified89.8%
Final simplification85.8%
(FPCore (x y z) :precision binary64 (if (<= y -6.4e+52) (* (- x y) (/ 4.0 z)) (if (<= y 3.7e+155) (* -4.0 (- 0.5 (/ x z))) (/ (* -4.0 y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.4e+52) {
tmp = (x - y) * (4.0 / z);
} else if (y <= 3.7e+155) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = (-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 <= (-6.4d+52)) then
tmp = (x - y) * (4.0d0 / z)
else if (y <= 3.7d+155) then
tmp = (-4.0d0) * (0.5d0 - (x / z))
else
tmp = ((-4.0d0) * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.4e+52) {
tmp = (x - y) * (4.0 / z);
} else if (y <= 3.7e+155) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = (-4.0 * y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.4e+52: tmp = (x - y) * (4.0 / z) elif y <= 3.7e+155: tmp = -4.0 * (0.5 - (x / z)) else: tmp = (-4.0 * y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.4e+52) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); elseif (y <= 3.7e+155) tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); else tmp = Float64(Float64(-4.0 * y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.4e+52) tmp = (x - y) * (4.0 / z); elseif (y <= 3.7e+155) tmp = -4.0 * (0.5 - (x / z)); else tmp = (-4.0 * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.4e+52], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.7e+155], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{+52}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+155}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-4 \cdot y}{z}\\
\end{array}
\end{array}
if y < -6.4e52Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 84.1%
if -6.4e52 < y < 3.6999999999999998e155Initial program 99.4%
remove-double-neg99.4%
neg-mul-199.4%
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 91.3%
*-commutative91.3%
Simplified91.3%
if 3.6999999999999998e155 < y Initial program 100.0%
Taylor expanded in y around inf 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.85e+83) (not (<= y 1.6e+78))) (/ (* -4.0 y) z) (/ (* x 4.0) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.85e+83) || !(y <= 1.6e+78)) {
tmp = (-4.0 * y) / z;
} else {
tmp = (x * 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 ((y <= (-1.85d+83)) .or. (.not. (y <= 1.6d+78))) then
tmp = ((-4.0d0) * y) / z
else
tmp = (x * 4.0d0) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.85e+83) || !(y <= 1.6e+78)) {
tmp = (-4.0 * y) / z;
} else {
tmp = (x * 4.0) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.85e+83) or not (y <= 1.6e+78): tmp = (-4.0 * y) / z else: tmp = (x * 4.0) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.85e+83) || !(y <= 1.6e+78)) tmp = Float64(Float64(-4.0 * y) / z); else tmp = Float64(Float64(x * 4.0) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.85e+83) || ~((y <= 1.6e+78))) tmp = (-4.0 * y) / z; else tmp = (x * 4.0) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.85e+83], N[Not[LessEqual[y, 1.6e+78]], $MachinePrecision]], N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{+83} \lor \neg \left(y \leq 1.6 \cdot 10^{+78}\right):\\
\;\;\;\;\frac{-4 \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\end{array}
\end{array}
if y < -1.8500000000000001e83 or 1.59999999999999997e78 < y Initial program 100.0%
Taylor expanded in y around inf 74.1%
*-commutative74.1%
Simplified74.1%
if -1.8500000000000001e83 < y < 1.59999999999999997e78Initial program 99.3%
Taylor expanded in x around inf 55.0%
*-commutative55.0%
Simplified55.0%
Final simplification62.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.6e+82) (not (<= y 2.8e+75))) (* y (/ -4.0 z)) (/ (* x 4.0) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.6e+82) || !(y <= 2.8e+75)) {
tmp = y * (-4.0 / z);
} else {
tmp = (x * 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 ((y <= (-8.6d+82)) .or. (.not. (y <= 2.8d+75))) then
tmp = y * ((-4.0d0) / z)
else
tmp = (x * 4.0d0) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -8.6e+82) || !(y <= 2.8e+75)) {
tmp = y * (-4.0 / z);
} else {
tmp = (x * 4.0) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.6e+82) or not (y <= 2.8e+75): tmp = y * (-4.0 / z) else: tmp = (x * 4.0) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.6e+82) || !(y <= 2.8e+75)) tmp = Float64(y * Float64(-4.0 / z)); else tmp = Float64(Float64(x * 4.0) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.6e+82) || ~((y <= 2.8e+75))) tmp = y * (-4.0 / z); else tmp = (x * 4.0) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.6e+82], N[Not[LessEqual[y, 2.8e+75]], $MachinePrecision]], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.6 \cdot 10^{+82} \lor \neg \left(y \leq 2.8 \cdot 10^{+75}\right):\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\end{array}
\end{array}
if y < -8.60000000000000029e82 or 2.80000000000000012e75 < y Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 80.7%
Taylor expanded in x around 0 74.1%
associate-*r/74.1%
*-commutative74.1%
associate-*r/73.9%
Simplified73.9%
if -8.60000000000000029e82 < y < 2.80000000000000012e75Initial program 99.3%
Taylor expanded in x around inf 55.0%
*-commutative55.0%
Simplified55.0%
Final simplification62.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.5e+83) (not (<= y 1.3e+75))) (* y (/ -4.0 z)) (* x (/ 4.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+83) || !(y <= 1.3e+75)) {
tmp = y * (-4.0 / z);
} else {
tmp = x * (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 ((y <= (-5.5d+83)) .or. (.not. (y <= 1.3d+75))) then
tmp = y * ((-4.0d0) / z)
else
tmp = x * (4.0d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+83) || !(y <= 1.3e+75)) {
tmp = y * (-4.0 / z);
} else {
tmp = x * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.5e+83) or not (y <= 1.3e+75): tmp = y * (-4.0 / z) else: tmp = x * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.5e+83) || !(y <= 1.3e+75)) tmp = Float64(y * Float64(-4.0 / z)); else tmp = Float64(x * Float64(4.0 / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.5e+83) || ~((y <= 1.3e+75))) tmp = y * (-4.0 / z); else tmp = x * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.5e+83], N[Not[LessEqual[y, 1.3e+75]], $MachinePrecision]], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+83} \lor \neg \left(y \leq 1.3 \cdot 10^{+75}\right):\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\end{array}
\end{array}
if y < -5.4999999999999996e83 or 1.29999999999999992e75 < y Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 80.7%
Taylor expanded in x around 0 74.1%
associate-*r/74.1%
*-commutative74.1%
associate-*r/73.9%
Simplified73.9%
if -5.4999999999999996e83 < y < 1.29999999999999992e75Initial program 99.3%
remove-double-neg99.3%
neg-mul-199.3%
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 55.0%
associate-*r/55.0%
associate-*l/54.8%
*-commutative54.8%
Simplified54.8%
Final simplification62.3%
(FPCore (x y z) :precision binary64 (if (<= z -2.1e+140) -2.0 (if (<= z 5.3e+70) (* x (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e+140) {
tmp = -2.0;
} else if (z <= 5.3e+70) {
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 <= (-2.1d+140)) then
tmp = -2.0d0
else if (z <= 5.3d+70) 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 <= -2.1e+140) {
tmp = -2.0;
} else if (z <= 5.3e+70) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.1e+140: tmp = -2.0 elif z <= 5.3e+70: tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.1e+140) tmp = -2.0; elseif (z <= 5.3e+70) 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 <= -2.1e+140) tmp = -2.0; elseif (z <= 5.3e+70) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.1e+140], -2.0, If[LessEqual[z, 5.3e+70], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{+140}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 5.3 \cdot 10^{+70}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.1000000000000002e140 or 5.3e70 < z Initial program 98.6%
remove-double-neg98.6%
neg-mul-198.6%
times-frac100.0%
metadata-eval100.0%
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 z around inf 72.0%
if -2.1000000000000002e140 < z < 5.3e70Initial 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 52.1%
associate-*r/52.1%
associate-*l/51.9%
*-commutative51.9%
Simplified51.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 29.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 2024157
(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))