
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 4.0 (/ (* 4.0 (- x z)) y)))
double code(double x, double y, double z) {
return 4.0 + ((4.0 * (x - z)) / y);
}
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 + ((4.0d0 * (x - z)) / y)
end function
public static double code(double x, double y, double z) {
return 4.0 + ((4.0 * (x - z)) / y);
}
def code(x, y, z): return 4.0 + ((4.0 * (x - z)) / y)
function code(x, y, z) return Float64(4.0 + Float64(Float64(4.0 * Float64(x - z)) / y)) end
function tmp = code(x, y, z) tmp = 4.0 + ((4.0 * (x - z)) / y); end
code[x_, y_, z_] := N[(4.0 + N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 + \frac{4 \cdot \left(x - z\right)}{y}
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-*l/99.3%
*-commutative99.3%
fma-def99.3%
+-commutative99.3%
associate--l+99.3%
+-commutative99.3%
associate-+l-99.3%
sub-neg99.3%
remove-double-neg99.3%
distribute-neg-in99.3%
+-commutative99.3%
distribute-neg-in99.3%
distribute-lft-neg-out99.3%
sub-neg99.3%
distribute-lft-neg-out99.3%
distribute-rgt-neg-in99.3%
fma-neg99.3%
metadata-eval99.3%
remove-double-neg99.3%
Simplified99.3%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* (/ z y) -4.0))) (t_1 (+ 1.0 (* x (/ 4.0 y)))))
(if (<= x -3.9e-50)
t_1
(if (<= x -3.2e-77)
t_0
(if (<= x -2.1e-162)
4.0
(if (<= x -1.4e-238)
t_0
(if (<= x 6.6e-234)
4.0
(if (<= x 2.3e-149) t_0 (if (<= x 1.05e-7) 4.0 t_1)))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((z / y) * -4.0);
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -3.9e-50) {
tmp = t_1;
} else if (x <= -3.2e-77) {
tmp = t_0;
} else if (x <= -2.1e-162) {
tmp = 4.0;
} else if (x <= -1.4e-238) {
tmp = t_0;
} else if (x <= 6.6e-234) {
tmp = 4.0;
} else if (x <= 2.3e-149) {
tmp = t_0;
} else if (x <= 1.05e-7) {
tmp = 4.0;
} else {
tmp = t_1;
}
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 = 1.0d0 + ((z / y) * (-4.0d0))
t_1 = 1.0d0 + (x * (4.0d0 / y))
if (x <= (-3.9d-50)) then
tmp = t_1
else if (x <= (-3.2d-77)) then
tmp = t_0
else if (x <= (-2.1d-162)) then
tmp = 4.0d0
else if (x <= (-1.4d-238)) then
tmp = t_0
else if (x <= 6.6d-234) then
tmp = 4.0d0
else if (x <= 2.3d-149) then
tmp = t_0
else if (x <= 1.05d-7) then
tmp = 4.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + ((z / y) * -4.0);
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -3.9e-50) {
tmp = t_1;
} else if (x <= -3.2e-77) {
tmp = t_0;
} else if (x <= -2.1e-162) {
tmp = 4.0;
} else if (x <= -1.4e-238) {
tmp = t_0;
} else if (x <= 6.6e-234) {
tmp = 4.0;
} else if (x <= 2.3e-149) {
tmp = t_0;
} else if (x <= 1.05e-7) {
tmp = 4.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z / y) * -4.0) t_1 = 1.0 + (x * (4.0 / y)) tmp = 0 if x <= -3.9e-50: tmp = t_1 elif x <= -3.2e-77: tmp = t_0 elif x <= -2.1e-162: tmp = 4.0 elif x <= -1.4e-238: tmp = t_0 elif x <= 6.6e-234: tmp = 4.0 elif x <= 2.3e-149: tmp = t_0 elif x <= 1.05e-7: tmp = 4.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(z / y) * -4.0)) t_1 = Float64(1.0 + Float64(x * Float64(4.0 / y))) tmp = 0.0 if (x <= -3.9e-50) tmp = t_1; elseif (x <= -3.2e-77) tmp = t_0; elseif (x <= -2.1e-162) tmp = 4.0; elseif (x <= -1.4e-238) tmp = t_0; elseif (x <= 6.6e-234) tmp = 4.0; elseif (x <= 2.3e-149) tmp = t_0; elseif (x <= 1.05e-7) tmp = 4.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((z / y) * -4.0); t_1 = 1.0 + (x * (4.0 / y)); tmp = 0.0; if (x <= -3.9e-50) tmp = t_1; elseif (x <= -3.2e-77) tmp = t_0; elseif (x <= -2.1e-162) tmp = 4.0; elseif (x <= -1.4e-238) tmp = t_0; elseif (x <= 6.6e-234) tmp = 4.0; elseif (x <= 2.3e-149) tmp = t_0; elseif (x <= 1.05e-7) tmp = 4.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.9e-50], t$95$1, If[LessEqual[x, -3.2e-77], t$95$0, If[LessEqual[x, -2.1e-162], 4.0, If[LessEqual[x, -1.4e-238], t$95$0, If[LessEqual[x, 6.6e-234], 4.0, If[LessEqual[x, 2.3e-149], t$95$0, If[LessEqual[x, 1.05e-7], 4.0, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z}{y} \cdot -4\\
t_1 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -3.9 \cdot 10^{-50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-77}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-162}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-238}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{-234}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-149}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-7}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -3.90000000000000021e-50 or 1.05e-7 < x Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
sub-neg99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around inf 72.3%
if -3.90000000000000021e-50 < x < -3.2e-77 or -2.1e-162 < x < -1.40000000000000002e-238 or 6.60000000000000028e-234 < x < 2.3e-149Initial program 99.9%
associate-*l/97.4%
sub-neg97.4%
sub-neg97.4%
+-commutative97.4%
fma-def97.4%
Simplified97.4%
Taylor expanded in z around inf 71.8%
*-commutative71.8%
Simplified71.8%
if -3.2e-77 < x < -2.1e-162 or -1.40000000000000002e-238 < x < 6.60000000000000028e-234 or 2.3e-149 < x < 1.05e-7Initial program 99.8%
+-commutative99.8%
associate-*l/99.7%
*-commutative99.7%
fma-def99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
associate-+l-99.7%
sub-neg99.7%
remove-double-neg99.7%
distribute-neg-in99.7%
+-commutative99.7%
distribute-neg-in99.7%
distribute-lft-neg-out99.7%
sub-neg99.7%
distribute-lft-neg-out99.7%
distribute-rgt-neg-in99.7%
fma-neg99.6%
metadata-eval99.6%
remove-double-neg99.6%
Simplified99.6%
Taylor expanded in y around inf 66.5%
Final simplification70.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* (/ z y) -4.0))) (t_1 (+ 1.0 (/ 4.0 (/ y x)))))
(if (<= x -3.9e-50)
t_1
(if (<= x -4.5e-77)
t_0
(if (<= x -3.5e-163)
4.0
(if (<= x -1.55e-238)
t_0
(if (<= x 2.25e-234)
4.0
(if (<= x 1.76e-149) t_0 (if (<= x 9.5e-8) 4.0 t_1)))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((z / y) * -4.0);
double t_1 = 1.0 + (4.0 / (y / x));
double tmp;
if (x <= -3.9e-50) {
tmp = t_1;
} else if (x <= -4.5e-77) {
tmp = t_0;
} else if (x <= -3.5e-163) {
tmp = 4.0;
} else if (x <= -1.55e-238) {
tmp = t_0;
} else if (x <= 2.25e-234) {
tmp = 4.0;
} else if (x <= 1.76e-149) {
tmp = t_0;
} else if (x <= 9.5e-8) {
tmp = 4.0;
} else {
tmp = t_1;
}
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 = 1.0d0 + ((z / y) * (-4.0d0))
t_1 = 1.0d0 + (4.0d0 / (y / x))
if (x <= (-3.9d-50)) then
tmp = t_1
else if (x <= (-4.5d-77)) then
tmp = t_0
else if (x <= (-3.5d-163)) then
tmp = 4.0d0
else if (x <= (-1.55d-238)) then
tmp = t_0
else if (x <= 2.25d-234) then
tmp = 4.0d0
else if (x <= 1.76d-149) then
tmp = t_0
else if (x <= 9.5d-8) then
tmp = 4.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + ((z / y) * -4.0);
double t_1 = 1.0 + (4.0 / (y / x));
double tmp;
if (x <= -3.9e-50) {
tmp = t_1;
} else if (x <= -4.5e-77) {
tmp = t_0;
} else if (x <= -3.5e-163) {
tmp = 4.0;
} else if (x <= -1.55e-238) {
tmp = t_0;
} else if (x <= 2.25e-234) {
tmp = 4.0;
} else if (x <= 1.76e-149) {
tmp = t_0;
} else if (x <= 9.5e-8) {
tmp = 4.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z / y) * -4.0) t_1 = 1.0 + (4.0 / (y / x)) tmp = 0 if x <= -3.9e-50: tmp = t_1 elif x <= -4.5e-77: tmp = t_0 elif x <= -3.5e-163: tmp = 4.0 elif x <= -1.55e-238: tmp = t_0 elif x <= 2.25e-234: tmp = 4.0 elif x <= 1.76e-149: tmp = t_0 elif x <= 9.5e-8: tmp = 4.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(z / y) * -4.0)) t_1 = Float64(1.0 + Float64(4.0 / Float64(y / x))) tmp = 0.0 if (x <= -3.9e-50) tmp = t_1; elseif (x <= -4.5e-77) tmp = t_0; elseif (x <= -3.5e-163) tmp = 4.0; elseif (x <= -1.55e-238) tmp = t_0; elseif (x <= 2.25e-234) tmp = 4.0; elseif (x <= 1.76e-149) tmp = t_0; elseif (x <= 9.5e-8) tmp = 4.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((z / y) * -4.0); t_1 = 1.0 + (4.0 / (y / x)); tmp = 0.0; if (x <= -3.9e-50) tmp = t_1; elseif (x <= -4.5e-77) tmp = t_0; elseif (x <= -3.5e-163) tmp = 4.0; elseif (x <= -1.55e-238) tmp = t_0; elseif (x <= 2.25e-234) tmp = 4.0; elseif (x <= 1.76e-149) tmp = t_0; elseif (x <= 9.5e-8) tmp = 4.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.9e-50], t$95$1, If[LessEqual[x, -4.5e-77], t$95$0, If[LessEqual[x, -3.5e-163], 4.0, If[LessEqual[x, -1.55e-238], t$95$0, If[LessEqual[x, 2.25e-234], 4.0, If[LessEqual[x, 1.76e-149], t$95$0, If[LessEqual[x, 9.5e-8], 4.0, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z}{y} \cdot -4\\
t_1 := 1 + \frac{4}{\frac{y}{x}}\\
\mathbf{if}\;x \leq -3.9 \cdot 10^{-50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-77}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{-163}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-238}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{-234}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 1.76 \cdot 10^{-149}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-8}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -3.90000000000000021e-50 or 9.50000000000000036e-8 < x Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
sub-neg99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around inf 72.3%
associate-*l/72.5%
associate-/l*72.4%
Applied egg-rr72.4%
if -3.90000000000000021e-50 < x < -4.5000000000000001e-77 or -3.50000000000000027e-163 < x < -1.5500000000000001e-238 or 2.25000000000000005e-234 < x < 1.7599999999999999e-149Initial program 99.9%
associate-*l/97.4%
sub-neg97.4%
sub-neg97.4%
+-commutative97.4%
fma-def97.4%
Simplified97.4%
Taylor expanded in z around inf 71.8%
*-commutative71.8%
Simplified71.8%
if -4.5000000000000001e-77 < x < -3.50000000000000027e-163 or -1.5500000000000001e-238 < x < 2.25000000000000005e-234 or 1.7599999999999999e-149 < x < 9.50000000000000036e-8Initial program 99.8%
+-commutative99.8%
associate-*l/99.7%
*-commutative99.7%
fma-def99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
associate-+l-99.7%
sub-neg99.7%
remove-double-neg99.7%
distribute-neg-in99.7%
+-commutative99.7%
distribute-neg-in99.7%
distribute-lft-neg-out99.7%
sub-neg99.7%
distribute-lft-neg-out99.7%
distribute-rgt-neg-in99.7%
fma-neg99.6%
metadata-eval99.6%
remove-double-neg99.6%
Simplified99.6%
Taylor expanded in y around inf 66.5%
Final simplification70.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* (/ z y) -4.0))) (t_1 (+ 1.0 (/ (* 4.0 x) y))))
(if (<= x -2.4e-50)
t_1
(if (<= x -3.2e-82)
t_0
(if (<= x -1.7e-157)
4.0
(if (<= x -1.9e-238)
t_0
(if (<= x 2.12e-234)
4.0
(if (<= x 9.5e-150) t_0 (if (<= x 7.5e-6) 4.0 t_1)))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((z / y) * -4.0);
double t_1 = 1.0 + ((4.0 * x) / y);
double tmp;
if (x <= -2.4e-50) {
tmp = t_1;
} else if (x <= -3.2e-82) {
tmp = t_0;
} else if (x <= -1.7e-157) {
tmp = 4.0;
} else if (x <= -1.9e-238) {
tmp = t_0;
} else if (x <= 2.12e-234) {
tmp = 4.0;
} else if (x <= 9.5e-150) {
tmp = t_0;
} else if (x <= 7.5e-6) {
tmp = 4.0;
} else {
tmp = t_1;
}
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 = 1.0d0 + ((z / y) * (-4.0d0))
t_1 = 1.0d0 + ((4.0d0 * x) / y)
if (x <= (-2.4d-50)) then
tmp = t_1
else if (x <= (-3.2d-82)) then
tmp = t_0
else if (x <= (-1.7d-157)) then
tmp = 4.0d0
else if (x <= (-1.9d-238)) then
tmp = t_0
else if (x <= 2.12d-234) then
tmp = 4.0d0
else if (x <= 9.5d-150) then
tmp = t_0
else if (x <= 7.5d-6) then
tmp = 4.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + ((z / y) * -4.0);
double t_1 = 1.0 + ((4.0 * x) / y);
double tmp;
if (x <= -2.4e-50) {
tmp = t_1;
} else if (x <= -3.2e-82) {
tmp = t_0;
} else if (x <= -1.7e-157) {
tmp = 4.0;
} else if (x <= -1.9e-238) {
tmp = t_0;
} else if (x <= 2.12e-234) {
tmp = 4.0;
} else if (x <= 9.5e-150) {
tmp = t_0;
} else if (x <= 7.5e-6) {
tmp = 4.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z / y) * -4.0) t_1 = 1.0 + ((4.0 * x) / y) tmp = 0 if x <= -2.4e-50: tmp = t_1 elif x <= -3.2e-82: tmp = t_0 elif x <= -1.7e-157: tmp = 4.0 elif x <= -1.9e-238: tmp = t_0 elif x <= 2.12e-234: tmp = 4.0 elif x <= 9.5e-150: tmp = t_0 elif x <= 7.5e-6: tmp = 4.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(z / y) * -4.0)) t_1 = Float64(1.0 + Float64(Float64(4.0 * x) / y)) tmp = 0.0 if (x <= -2.4e-50) tmp = t_1; elseif (x <= -3.2e-82) tmp = t_0; elseif (x <= -1.7e-157) tmp = 4.0; elseif (x <= -1.9e-238) tmp = t_0; elseif (x <= 2.12e-234) tmp = 4.0; elseif (x <= 9.5e-150) tmp = t_0; elseif (x <= 7.5e-6) tmp = 4.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((z / y) * -4.0); t_1 = 1.0 + ((4.0 * x) / y); tmp = 0.0; if (x <= -2.4e-50) tmp = t_1; elseif (x <= -3.2e-82) tmp = t_0; elseif (x <= -1.7e-157) tmp = 4.0; elseif (x <= -1.9e-238) tmp = t_0; elseif (x <= 2.12e-234) tmp = 4.0; elseif (x <= 9.5e-150) tmp = t_0; elseif (x <= 7.5e-6) tmp = 4.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.4e-50], t$95$1, If[LessEqual[x, -3.2e-82], t$95$0, If[LessEqual[x, -1.7e-157], 4.0, If[LessEqual[x, -1.9e-238], t$95$0, If[LessEqual[x, 2.12e-234], 4.0, If[LessEqual[x, 9.5e-150], t$95$0, If[LessEqual[x, 7.5e-6], 4.0, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z}{y} \cdot -4\\
t_1 := 1 + \frac{4 \cdot x}{y}\\
\mathbf{if}\;x \leq -2.4 \cdot 10^{-50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -3.2 \cdot 10^{-82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.7 \cdot 10^{-157}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq -1.9 \cdot 10^{-238}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.12 \cdot 10^{-234}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-6}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -2.40000000000000002e-50 or 7.50000000000000019e-6 < x Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
sub-neg99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around inf 72.5%
associate-*r/72.5%
Simplified72.5%
if -2.40000000000000002e-50 < x < -3.2000000000000001e-82 or -1.69999999999999989e-157 < x < -1.8999999999999998e-238 or 2.12000000000000008e-234 < x < 9.50000000000000013e-150Initial program 99.9%
associate-*l/97.4%
sub-neg97.4%
sub-neg97.4%
+-commutative97.4%
fma-def97.4%
Simplified97.4%
Taylor expanded in z around inf 71.8%
*-commutative71.8%
Simplified71.8%
if -3.2000000000000001e-82 < x < -1.69999999999999989e-157 or -1.8999999999999998e-238 < x < 2.12000000000000008e-234 or 9.50000000000000013e-150 < x < 7.50000000000000019e-6Initial program 99.8%
+-commutative99.8%
associate-*l/99.7%
*-commutative99.7%
fma-def99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
associate-+l-99.7%
sub-neg99.7%
remove-double-neg99.7%
distribute-neg-in99.7%
+-commutative99.7%
distribute-neg-in99.7%
distribute-lft-neg-out99.7%
sub-neg99.7%
distribute-lft-neg-out99.7%
distribute-rgt-neg-in99.7%
fma-neg99.6%
metadata-eval99.6%
remove-double-neg99.6%
Simplified99.6%
Taylor expanded in y around inf 66.5%
Final simplification70.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -29000000.0) (not (<= x 7e-6))) (+ 1.0 (* x (/ 4.0 y))) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -29000000.0) || !(x <= 7e-6)) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 4.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 <= (-29000000.0d0)) .or. (.not. (x <= 7d-6))) then
tmp = 1.0d0 + (x * (4.0d0 / y))
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -29000000.0) || !(x <= 7e-6)) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -29000000.0) or not (x <= 7e-6): tmp = 1.0 + (x * (4.0 / y)) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -29000000.0) || !(x <= 7e-6)) tmp = Float64(1.0 + Float64(x * Float64(4.0 / y))); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -29000000.0) || ~((x <= 7e-6))) tmp = 1.0 + (x * (4.0 / y)); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -29000000.0], N[Not[LessEqual[x, 7e-6]], $MachinePrecision]], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -29000000 \lor \neg \left(x \leq 7 \cdot 10^{-6}\right):\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -2.9e7 or 6.99999999999999989e-6 < x Initial program 100.0%
associate-*l/99.6%
sub-neg99.6%
sub-neg99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in x around inf 76.5%
if -2.9e7 < x < 6.99999999999999989e-6Initial program 99.8%
+-commutative99.8%
associate-*l/99.0%
*-commutative99.0%
fma-def99.0%
+-commutative99.0%
associate--l+99.0%
+-commutative99.0%
associate-+l-99.0%
sub-neg99.0%
remove-double-neg99.0%
distribute-neg-in99.0%
+-commutative99.0%
distribute-neg-in99.0%
distribute-lft-neg-out99.0%
sub-neg99.0%
distribute-lft-neg-out99.0%
distribute-rgt-neg-in99.0%
fma-neg99.0%
metadata-eval99.0%
remove-double-neg99.0%
Simplified99.0%
Taylor expanded in y around inf 53.2%
Final simplification63.8%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.0;
}
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
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-*l/99.3%
*-commutative99.3%
fma-def99.3%
+-commutative99.3%
associate--l+99.3%
+-commutative99.3%
associate-+l-99.3%
sub-neg99.3%
remove-double-neg99.3%
distribute-neg-in99.3%
+-commutative99.3%
distribute-neg-in99.3%
distribute-lft-neg-out99.3%
sub-neg99.3%
distribute-lft-neg-out99.3%
distribute-rgt-neg-in99.3%
fma-neg99.3%
metadata-eval99.3%
remove-double-neg99.3%
Simplified99.3%
Taylor expanded in y around inf 34.5%
Final simplification34.5%
herbie shell --seed 2024021
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, A"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))