
(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.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+106) (not (<= y 9e+91))) (* -4.0 (/ (- y x) z)) (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e+106) || !(y <= 9e+91)) {
tmp = -4.0 * ((y - x) / 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 <= (-3.4d+106)) .or. (.not. (y <= 9d+91))) then
tmp = (-4.0d0) * ((y - x) / 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 <= -3.4e+106) || !(y <= 9e+91)) {
tmp = -4.0 * ((y - x) / z);
} else {
tmp = 4.0 * (-0.5 + (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e+106) or not (y <= 9e+91): tmp = -4.0 * ((y - x) / z) else: tmp = 4.0 * (-0.5 + (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e+106) || !(y <= 9e+91)) tmp = Float64(-4.0 * Float64(Float64(y - x) / 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 <= -3.4e+106) || ~((y <= 9e+91))) tmp = -4.0 * ((y - x) / z); else tmp = 4.0 * (-0.5 + (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e+106], N[Not[LessEqual[y, 9e+91]], $MachinePrecision]], N[(-4.0 * N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $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^{+106} \lor \neg \left(y \leq 9 \cdot 10^{+91}\right):\\
\;\;\;\;-4 \cdot \frac{y - x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -3.39999999999999994e106 or 9e91 < 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 z around 0 87.1%
*-commutative87.1%
Simplified87.1%
if -3.39999999999999994e106 < y < 9e91Initial program 99.5%
remove-double-neg99.5%
neg-mul-199.5%
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.8%
sub-neg91.8%
+-commutative91.8%
neg-sub091.8%
associate-+l-91.8%
neg-sub091.8%
neg-mul-191.8%
associate-*r*91.8%
metadata-eval91.8%
sub-neg91.8%
metadata-eval91.8%
Simplified91.8%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -9e+123) (not (<= y 1.25e+95))) (* -4.0 (/ y z)) (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9e+123) || !(y <= 1.25e+95)) {
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 <= (-9d+123)) .or. (.not. (y <= 1.25d+95))) 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 <= -9e+123) || !(y <= 1.25e+95)) {
tmp = -4.0 * (y / z);
} else {
tmp = 4.0 * (-0.5 + (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9e+123) or not (y <= 1.25e+95): 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 <= -9e+123) || !(y <= 1.25e+95)) tmp = Float64(-4.0 * Float64(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 <= -9e+123) || ~((y <= 1.25e+95))) 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, -9e+123], N[Not[LessEqual[y, 1.25e+95]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+123} \lor \neg \left(y \leq 1.25 \cdot 10^{+95}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -8.99999999999999965e123 or 1.25000000000000006e95 < 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 75.5%
*-commutative75.5%
Simplified75.5%
if -8.99999999999999965e123 < y < 1.25000000000000006e95Initial program 99.5%
remove-double-neg99.5%
neg-mul-199.5%
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.9%
sub-neg90.9%
+-commutative90.9%
neg-sub090.9%
associate-+l-90.9%
neg-sub090.9%
neg-mul-190.9%
associate-*r*90.9%
metadata-eval90.9%
sub-neg90.9%
metadata-eval90.9%
Simplified90.9%
Final simplification86.5%
(FPCore (x y z) :precision binary64 (if (<= y -2e+106) (+ (* -4.0 (/ y z)) -2.0) (if (<= y 1.2e+92) (* 4.0 (+ -0.5 (/ x z))) (* -4.0 (/ (- y x) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+106) {
tmp = (-4.0 * (y / z)) + -2.0;
} else if (y <= 1.2e+92) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = -4.0 * ((y - 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 <= (-2d+106)) then
tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
else if (y <= 1.2d+92) then
tmp = 4.0d0 * ((-0.5d0) + (x / z))
else
tmp = (-4.0d0) * ((y - x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2e+106) {
tmp = (-4.0 * (y / z)) + -2.0;
} else if (y <= 1.2e+92) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = -4.0 * ((y - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e+106: tmp = (-4.0 * (y / z)) + -2.0 elif y <= 1.2e+92: tmp = 4.0 * (-0.5 + (x / z)) else: tmp = -4.0 * ((y - x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e+106) tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0); elseif (y <= 1.2e+92) tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z))); else tmp = Float64(-4.0 * Float64(Float64(y - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e+106) tmp = (-4.0 * (y / z)) + -2.0; elseif (y <= 1.2e+92) tmp = 4.0 * (-0.5 + (x / z)); else tmp = -4.0 * ((y - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e+106], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], If[LessEqual[y, 1.2e+92], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+106}:\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+92}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y - x}{z}\\
\end{array}
\end{array}
if y < -2.00000000000000018e106Initial 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 84.6%
+-commutative84.6%
distribute-rgt-in84.6%
metadata-eval84.6%
Simplified84.6%
if -2.00000000000000018e106 < y < 1.20000000000000002e92Initial program 99.5%
remove-double-neg99.5%
neg-mul-199.5%
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.8%
sub-neg91.8%
+-commutative91.8%
neg-sub091.8%
associate-+l-91.8%
neg-sub091.8%
neg-mul-191.8%
associate-*r*91.8%
metadata-eval91.8%
sub-neg91.8%
metadata-eval91.8%
Simplified91.8%
if 1.20000000000000002e92 < 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 z around 0 89.2%
*-commutative89.2%
Simplified89.2%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -3e+106) (not (<= y 3.6e+51))) (* -4.0 (/ y z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3e+106) || !(y <= 3.6e+51)) {
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 ((y <= (-3d+106)) .or. (.not. (y <= 3.6d+51))) 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 ((y <= -3e+106) || !(y <= 3.6e+51)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3e+106) or not (y <= 3.6e+51): tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3e+106) || !(y <= 3.6e+51)) 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 ((y <= -3e+106) || ~((y <= 3.6e+51))) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3e+106], N[Not[LessEqual[y, 3.6e+51]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+106} \lor \neg \left(y \leq 3.6 \cdot 10^{+51}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if y < -3.0000000000000001e106 or 3.60000000000000011e51 < 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 69.1%
*-commutative69.1%
Simplified69.1%
if -3.0000000000000001e106 < y < 3.60000000000000011e51Initial 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 z around inf 57.4%
Final simplification61.5%
(FPCore (x y z) :precision binary64 (if (<= z -8.5e-39) -2.0 (if (<= z 3.4e+18) (* 4.0 (/ x z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -8.5e-39) {
tmp = -2.0;
} else if (z <= 3.4e+18) {
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 (z <= (-8.5d-39)) then
tmp = -2.0d0
else if (z <= 3.4d+18) 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 (z <= -8.5e-39) {
tmp = -2.0;
} else if (z <= 3.4e+18) {
tmp = 4.0 * (x / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8.5e-39: tmp = -2.0 elif z <= 3.4e+18: tmp = 4.0 * (x / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8.5e-39) tmp = -2.0; elseif (z <= 3.4e+18) 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 (z <= -8.5e-39) tmp = -2.0; elseif (z <= 3.4e+18) tmp = 4.0 * (x / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8.5e-39], -2.0, If[LessEqual[z, 3.4e+18], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-39}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+18}:\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -8.5000000000000005e-39 or 3.4e18 < z Initial 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 z around inf 65.5%
if -8.5000000000000005e-39 < z < 3.4e18Initial 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.4%
*-commutative52.4%
Simplified52.4%
Final simplification60.3%
(FPCore (x y z) :precision binary64 (if (<= z -4.2e-39) -2.0 (if (<= z 8.2e+14) (* x (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.2e-39) {
tmp = -2.0;
} else if (z <= 8.2e+14) {
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 <= (-4.2d-39)) then
tmp = -2.0d0
else if (z <= 8.2d+14) 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 <= -4.2e-39) {
tmp = -2.0;
} else if (z <= 8.2e+14) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.2e-39: tmp = -2.0 elif z <= 8.2e+14: tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.2e-39) tmp = -2.0; elseif (z <= 8.2e+14) 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 <= -4.2e-39) tmp = -2.0; elseif (z <= 8.2e+14) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.2e-39], -2.0, If[LessEqual[z, 8.2e+14], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{-39}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 8.2 \cdot 10^{+14}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.19999999999999987e-39 or 8.2e14 < z Initial 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 z around inf 65.5%
if -4.19999999999999987e-39 < z < 8.2e14Initial 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 0 59.4%
sub-neg59.4%
+-commutative59.4%
neg-sub059.4%
associate-+l-59.4%
neg-sub059.4%
neg-mul-159.4%
associate-*r*59.4%
metadata-eval59.4%
sub-neg59.4%
metadata-eval59.4%
Simplified59.4%
Taylor expanded in x around inf 52.4%
associate-*r/52.4%
*-commutative52.4%
associate-*r/52.4%
Simplified52.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.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 43.1%
(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 2024163
(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))