
(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 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 -3.4e+102)
t_0
(if (<= y 3.1e-305)
t_1
(if (<= y 3.6e-14) -2.0 (if (<= y 4.1e+14) t_1 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 <= -3.4e+102) {
tmp = t_0;
} else if (y <= 3.1e-305) {
tmp = t_1;
} else if (y <= 3.6e-14) {
tmp = -2.0;
} else if (y <= 4.1e+14) {
tmp = t_1;
} 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 <= (-3.4d+102)) then
tmp = t_0
else if (y <= 3.1d-305) then
tmp = t_1
else if (y <= 3.6d-14) then
tmp = -2.0d0
else if (y <= 4.1d+14) then
tmp = t_1
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 <= -3.4e+102) {
tmp = t_0;
} else if (y <= 3.1e-305) {
tmp = t_1;
} else if (y <= 3.6e-14) {
tmp = -2.0;
} else if (y <= 4.1e+14) {
tmp = t_1;
} 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 <= -3.4e+102: tmp = t_0 elif y <= 3.1e-305: tmp = t_1 elif y <= 3.6e-14: tmp = -2.0 elif y <= 4.1e+14: tmp = t_1 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 <= -3.4e+102) tmp = t_0; elseif (y <= 3.1e-305) tmp = t_1; elseif (y <= 3.6e-14) tmp = -2.0; elseif (y <= 4.1e+14) tmp = t_1; 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 <= -3.4e+102) tmp = t_0; elseif (y <= 3.1e-305) tmp = t_1; elseif (y <= 3.6e-14) tmp = -2.0; elseif (y <= 4.1e+14) tmp = t_1; 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, -3.4e+102], t$95$0, If[LessEqual[y, 3.1e-305], t$95$1, If[LessEqual[y, 3.6e-14], -2.0, If[LessEqual[y, 4.1e+14], t$95$1, 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 -3.4 \cdot 10^{+102}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{-305}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-14}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+14}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.4e102 or 4.1e14 < 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 66.7%
*-commutative66.7%
Simplified66.7%
if -3.4e102 < y < 3.0999999999999998e-305 or 3.5999999999999998e-14 < y < 4.1e14Initial 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 54.8%
associate-*r/54.8%
*-commutative54.8%
Simplified54.8%
if 3.0999999999999998e-305 < y < 3.5999999999999998e-14Initial 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 58.2%
Final simplification60.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))) (t_1 (* x (/ 4.0 z))))
(if (<= y -4.8e+91)
t_0
(if (<= y 4.5e-305)
t_1
(if (<= y 2.8e-14) -2.0 (if (<= y 9e+15) t_1 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 <= -4.8e+91) {
tmp = t_0;
} else if (y <= 4.5e-305) {
tmp = t_1;
} else if (y <= 2.8e-14) {
tmp = -2.0;
} else if (y <= 9e+15) {
tmp = t_1;
} 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 <= (-4.8d+91)) then
tmp = t_0
else if (y <= 4.5d-305) then
tmp = t_1
else if (y <= 2.8d-14) then
tmp = -2.0d0
else if (y <= 9d+15) then
tmp = t_1
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 <= -4.8e+91) {
tmp = t_0;
} else if (y <= 4.5e-305) {
tmp = t_1;
} else if (y <= 2.8e-14) {
tmp = -2.0;
} else if (y <= 9e+15) {
tmp = t_1;
} 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 <= -4.8e+91: tmp = t_0 elif y <= 4.5e-305: tmp = t_1 elif y <= 2.8e-14: tmp = -2.0 elif y <= 9e+15: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) t_1 = Float64(x * Float64(4.0 / z)) tmp = 0.0 if (y <= -4.8e+91) tmp = t_0; elseif (y <= 4.5e-305) tmp = t_1; elseif (y <= 2.8e-14) tmp = -2.0; elseif (y <= 9e+15) tmp = t_1; 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 <= -4.8e+91) tmp = t_0; elseif (y <= 4.5e-305) tmp = t_1; elseif (y <= 2.8e-14) tmp = -2.0; elseif (y <= 9e+15) tmp = t_1; 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[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.8e+91], t$95$0, If[LessEqual[y, 4.5e-305], t$95$1, If[LessEqual[y, 2.8e-14], -2.0, If[LessEqual[y, 9e+15], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
t_1 := x \cdot \frac{4}{z}\\
\mathbf{if}\;y \leq -4.8 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-305}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-14}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.79999999999999966e91 or 9e15 < 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 66.7%
*-commutative66.7%
Simplified66.7%
if -4.79999999999999966e91 < y < 4.5000000000000002e-305 or 2.8000000000000001e-14 < y < 9e15Initial 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 54.8%
associate-*r/54.8%
associate-*l/54.8%
*-commutative54.8%
Simplified54.8%
if 4.5000000000000002e-305 < y < 2.8000000000000001e-14Initial 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 58.2%
Final simplification60.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -1e-26) (not (<= x 21000000000.0))) (* (- x y) (/ 4.0 z)) (+ -2.0 (* -4.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e-26) || !(x <= 21000000000.0)) {
tmp = (x - y) * (4.0 / z);
} 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 ((x <= (-1d-26)) .or. (.not. (x <= 21000000000.0d0))) then
tmp = (x - y) * (4.0d0 / z)
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 ((x <= -1e-26) || !(x <= 21000000000.0)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1e-26) or not (x <= 21000000000.0): tmp = (x - y) * (4.0 / z) else: tmp = -2.0 + (-4.0 * (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1e-26) || !(x <= 21000000000.0)) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); 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 ((x <= -1e-26) || ~((x <= 21000000000.0))) tmp = (x - y) * (4.0 / z); else tmp = -2.0 + (-4.0 * (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1e-26], N[Not[LessEqual[x, 21000000000.0]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-26} \lor \neg \left(x \leq 21000000000\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < -1e-26 or 2.1e10 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 84.7%
if -1e-26 < x < 2.1e10Initial 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.3%
+-commutative91.3%
distribute-rgt-in91.3%
metadata-eval91.3%
Simplified91.3%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (<= z -3.3e-84) (+ (/ (* x 4.0) z) -2.0) (if (<= z 8.4e-53) (/ (* -4.0 (- y x)) z) (+ -2.0 (* -4.0 (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.3e-84) {
tmp = ((x * 4.0) / z) + -2.0;
} else if (z <= 8.4e-53) {
tmp = (-4.0 * (y - x)) / z;
} 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 (z <= (-3.3d-84)) then
tmp = ((x * 4.0d0) / z) + (-2.0d0)
else if (z <= 8.4d-53) then
tmp = ((-4.0d0) * (y - x)) / z
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 (z <= -3.3e-84) {
tmp = ((x * 4.0) / z) + -2.0;
} else if (z <= 8.4e-53) {
tmp = (-4.0 * (y - x)) / z;
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.3e-84: tmp = ((x * 4.0) / z) + -2.0 elif z <= 8.4e-53: tmp = (-4.0 * (y - x)) / z else: tmp = -2.0 + (-4.0 * (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.3e-84) tmp = Float64(Float64(Float64(x * 4.0) / z) + -2.0); elseif (z <= 8.4e-53) tmp = Float64(Float64(-4.0 * Float64(y - x)) / z); 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 (z <= -3.3e-84) tmp = ((x * 4.0) / z) + -2.0; elseif (z <= 8.4e-53) tmp = (-4.0 * (y - x)) / z; else tmp = -2.0 + (-4.0 * (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.3e-84], N[(N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision], If[LessEqual[z, 8.4e-53], N[(N[(-4.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{-84}:\\
\;\;\;\;\frac{x \cdot 4}{z} + -2\\
\mathbf{elif}\;z \leq 8.4 \cdot 10^{-53}:\\
\;\;\;\;\frac{-4 \cdot \left(y - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if z < -3.29999999999999984e-84Initial 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 81.1%
sub-neg81.1%
+-commutative81.1%
distribute-rgt-in81.1%
distribute-neg-frac81.1%
neg-mul-181.1%
*-commutative81.1%
associate-/l*81.0%
metadata-eval81.0%
distribute-neg-frac81.0%
associate-*r*81.0%
distribute-frac-neg281.0%
associate-*l/81.0%
metadata-eval81.0%
distribute-neg-frac281.0%
distribute-neg-frac81.0%
metadata-eval81.0%
associate-*r/81.1%
metadata-eval81.1%
Simplified81.1%
if -3.29999999999999984e-84 < z < 8.3999999999999991e-53Initial 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 z around 0 97.2%
*-commutative97.2%
associate-*l/97.2%
Simplified97.2%
if 8.3999999999999991e-53 < 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.9%
+-commutative83.9%
distribute-rgt-in83.9%
metadata-eval83.9%
Simplified83.9%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (<= z -7.8e-84) (+ (/ (* x 4.0) z) -2.0) (if (<= z 9.2e-53) (* (- x y) (/ 4.0 z)) (+ -2.0 (* -4.0 (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.8e-84) {
tmp = ((x * 4.0) / z) + -2.0;
} else if (z <= 9.2e-53) {
tmp = (x - y) * (4.0 / z);
} 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 (z <= (-7.8d-84)) then
tmp = ((x * 4.0d0) / z) + (-2.0d0)
else if (z <= 9.2d-53) then
tmp = (x - y) * (4.0d0 / z)
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 (z <= -7.8e-84) {
tmp = ((x * 4.0) / z) + -2.0;
} else if (z <= 9.2e-53) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.8e-84: tmp = ((x * 4.0) / z) + -2.0 elif z <= 9.2e-53: tmp = (x - y) * (4.0 / z) else: tmp = -2.0 + (-4.0 * (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.8e-84) tmp = Float64(Float64(Float64(x * 4.0) / z) + -2.0); elseif (z <= 9.2e-53) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); 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 (z <= -7.8e-84) tmp = ((x * 4.0) / z) + -2.0; elseif (z <= 9.2e-53) tmp = (x - y) * (4.0 / z); else tmp = -2.0 + (-4.0 * (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.8e-84], N[(N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision], If[LessEqual[z, 9.2e-53], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{-84}:\\
\;\;\;\;\frac{x \cdot 4}{z} + -2\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{-53}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if z < -7.80000000000000045e-84Initial 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 81.1%
sub-neg81.1%
+-commutative81.1%
distribute-rgt-in81.1%
distribute-neg-frac81.1%
neg-mul-181.1%
*-commutative81.1%
associate-/l*81.0%
metadata-eval81.0%
distribute-neg-frac81.0%
associate-*r*81.0%
distribute-frac-neg281.0%
associate-*l/81.0%
metadata-eval81.0%
distribute-neg-frac281.0%
distribute-neg-frac81.0%
metadata-eval81.0%
associate-*r/81.1%
metadata-eval81.1%
Simplified81.1%
if -7.80000000000000045e-84 < z < 9.2000000000000005e-53Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 96.9%
if 9.2000000000000005e-53 < 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.9%
+-commutative83.9%
distribute-rgt-in83.9%
metadata-eval83.9%
Simplified83.9%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= z -4.9e+187) -2.0 (if (<= z 4e+120) (* (- x y) (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.9e+187) {
tmp = -2.0;
} else if (z <= 4e+120) {
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 <= (-4.9d+187)) then
tmp = -2.0d0
else if (z <= 4d+120) 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 <= -4.9e+187) {
tmp = -2.0;
} else if (z <= 4e+120) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.9e+187: tmp = -2.0 elif z <= 4e+120: tmp = (x - y) * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.9e+187) tmp = -2.0; elseif (z <= 4e+120) 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 <= -4.9e+187) tmp = -2.0; elseif (z <= 4e+120) tmp = (x - y) * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.9e+187], -2.0, If[LessEqual[z, 4e+120], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.9 \cdot 10^{+187}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+120}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.9000000000000003e187 or 3.9999999999999999e120 < 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.2%
if -4.9000000000000003e187 < z < 3.9999999999999999e120Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 81.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -28000000.0) (not (<= x 3.1e-22))) (* x (/ 4.0 z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -28000000.0) || !(x <= 3.1e-22)) {
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 ((x <= (-28000000.0d0)) .or. (.not. (x <= 3.1d-22))) 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 ((x <= -28000000.0) || !(x <= 3.1e-22)) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -28000000.0) or not (x <= 3.1e-22): tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -28000000.0) || !(x <= 3.1e-22)) 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 ((x <= -28000000.0) || ~((x <= 3.1e-22))) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -28000000.0], N[Not[LessEqual[x, 3.1e-22]], $MachinePrecision]], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -28000000 \lor \neg \left(x \leq 3.1 \cdot 10^{-22}\right):\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -2.8e7 or 3.10000000000000013e-22 < 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 x around inf 59.3%
associate-*r/59.3%
associate-*l/59.2%
*-commutative59.2%
Simplified59.2%
if -2.8e7 < x < 3.10000000000000013e-22Initial 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 z around inf 50.9%
Final simplification55.1%
(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.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 2024166
(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))