
(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 9 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 (+ 1.0 (+ (/ (* 4.0 (- x z)) y) 3.0)))
double code(double x, double y, double z) {
return 1.0 + (((4.0 * (x - z)) / y) + 3.0);
}
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 - z)) / y) + 3.0d0)
end function
public static double code(double x, double y, double z) {
return 1.0 + (((4.0 * (x - z)) / y) + 3.0);
}
def code(x, y, z): return 1.0 + (((4.0 * (x - z)) / y) + 3.0)
function code(x, y, z) return Float64(1.0 + Float64(Float64(Float64(4.0 * Float64(x - z)) / y) + 3.0)) end
function tmp = code(x, y, z) tmp = 1.0 + (((4.0 * (x - z)) / y) + 3.0); end
code[x_, y_, z_] := N[(1.0 + N[(N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(\frac{4 \cdot \left(x - z\right)}{y} + 3\right)
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z (/ -4.0 y)))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
(if (<= x -2.7e+49)
t_1
(if (<= x -1.12e-57)
4.0
(if (<= x 1.05e-79)
t_0
(if (<= x 7200000000000.0) 4.0 (if (<= x 8.2e+65) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (-4.0 / y));
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -2.7e+49) {
tmp = t_1;
} else if (x <= -1.12e-57) {
tmp = 4.0;
} else if (x <= 1.05e-79) {
tmp = t_0;
} else if (x <= 7200000000000.0) {
tmp = 4.0;
} else if (x <= 8.2e+65) {
tmp = t_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 * ((-4.0d0) / y))
t_1 = 1.0d0 + (4.0d0 * (x / y))
if (x <= (-2.7d+49)) then
tmp = t_1
else if (x <= (-1.12d-57)) then
tmp = 4.0d0
else if (x <= 1.05d-79) then
tmp = t_0
else if (x <= 7200000000000.0d0) then
tmp = 4.0d0
else if (x <= 8.2d+65) then
tmp = t_0
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 * (-4.0 / y));
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -2.7e+49) {
tmp = t_1;
} else if (x <= -1.12e-57) {
tmp = 4.0;
} else if (x <= 1.05e-79) {
tmp = t_0;
} else if (x <= 7200000000000.0) {
tmp = 4.0;
} else if (x <= 8.2e+65) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * (-4.0 / y)) t_1 = 1.0 + (4.0 * (x / y)) tmp = 0 if x <= -2.7e+49: tmp = t_1 elif x <= -1.12e-57: tmp = 4.0 elif x <= 1.05e-79: tmp = t_0 elif x <= 7200000000000.0: tmp = 4.0 elif x <= 8.2e+65: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * Float64(-4.0 / y))) t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y))) tmp = 0.0 if (x <= -2.7e+49) tmp = t_1; elseif (x <= -1.12e-57) tmp = 4.0; elseif (x <= 1.05e-79) tmp = t_0; elseif (x <= 7200000000000.0) tmp = 4.0; elseif (x <= 8.2e+65) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * (-4.0 / y)); t_1 = 1.0 + (4.0 * (x / y)); tmp = 0.0; if (x <= -2.7e+49) tmp = t_1; elseif (x <= -1.12e-57) tmp = 4.0; elseif (x <= 1.05e-79) tmp = t_0; elseif (x <= 7200000000000.0) tmp = 4.0; elseif (x <= 8.2e+65) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.7e+49], t$95$1, If[LessEqual[x, -1.12e-57], 4.0, If[LessEqual[x, 1.05e-79], t$95$0, If[LessEqual[x, 7200000000000.0], 4.0, If[LessEqual[x, 8.2e+65], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot \frac{-4}{y}\\
t_1 := 1 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{+49}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.12 \cdot 10^{-57}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-79}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7200000000000:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{+65}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.7000000000000001e49 or 8.2000000000000003e65 < x Initial program 99.9%
Taylor expanded in x around inf 75.5%
*-commutative75.5%
Simplified75.5%
if -2.7000000000000001e49 < x < -1.12e-57 or 1.05e-79 < x < 7.2e12Initial program 99.9%
Taylor expanded in y around inf 63.3%
if -1.12e-57 < x < 1.05e-79 or 7.2e12 < x < 8.2000000000000003e65Initial program 100.0%
Taylor expanded in z around inf 61.6%
metadata-eval61.6%
distribute-lft-neg-in61.6%
*-lft-identity61.6%
associate-*l/61.4%
associate-*l*61.4%
*-commutative61.4%
distribute-rgt-neg-in61.4%
associate-*r/61.4%
metadata-eval61.4%
distribute-neg-frac61.4%
metadata-eval61.4%
Simplified61.4%
Final simplification67.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* z -4.0) y))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
(if (<= x -2.7e+49)
t_1
(if (<= x -2.9e-55)
4.0
(if (<= x 2.05e-80)
t_0
(if (<= x 6000000000000.0) 4.0 (if (<= x 8.2e+65) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((z * -4.0) / y);
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -2.7e+49) {
tmp = t_1;
} else if (x <= -2.9e-55) {
tmp = 4.0;
} else if (x <= 2.05e-80) {
tmp = t_0;
} else if (x <= 6000000000000.0) {
tmp = 4.0;
} else if (x <= 8.2e+65) {
tmp = t_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 * (-4.0d0)) / y)
t_1 = 1.0d0 + (4.0d0 * (x / y))
if (x <= (-2.7d+49)) then
tmp = t_1
else if (x <= (-2.9d-55)) then
tmp = 4.0d0
else if (x <= 2.05d-80) then
tmp = t_0
else if (x <= 6000000000000.0d0) then
tmp = 4.0d0
else if (x <= 8.2d+65) then
tmp = t_0
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 * -4.0) / y);
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (x <= -2.7e+49) {
tmp = t_1;
} else if (x <= -2.9e-55) {
tmp = 4.0;
} else if (x <= 2.05e-80) {
tmp = t_0;
} else if (x <= 6000000000000.0) {
tmp = 4.0;
} else if (x <= 8.2e+65) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z * -4.0) / y) t_1 = 1.0 + (4.0 * (x / y)) tmp = 0 if x <= -2.7e+49: tmp = t_1 elif x <= -2.9e-55: tmp = 4.0 elif x <= 2.05e-80: tmp = t_0 elif x <= 6000000000000.0: tmp = 4.0 elif x <= 8.2e+65: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(z * -4.0) / y)) t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y))) tmp = 0.0 if (x <= -2.7e+49) tmp = t_1; elseif (x <= -2.9e-55) tmp = 4.0; elseif (x <= 2.05e-80) tmp = t_0; elseif (x <= 6000000000000.0) tmp = 4.0; elseif (x <= 8.2e+65) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((z * -4.0) / y); t_1 = 1.0 + (4.0 * (x / y)); tmp = 0.0; if (x <= -2.7e+49) tmp = t_1; elseif (x <= -2.9e-55) tmp = 4.0; elseif (x <= 2.05e-80) tmp = t_0; elseif (x <= 6000000000000.0) tmp = 4.0; elseif (x <= 8.2e+65) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.7e+49], t$95$1, If[LessEqual[x, -2.9e-55], 4.0, If[LessEqual[x, 2.05e-80], t$95$0, If[LessEqual[x, 6000000000000.0], 4.0, If[LessEqual[x, 8.2e+65], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z \cdot -4}{y}\\
t_1 := 1 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{+49}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-55}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{-80}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6000000000000:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{+65}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.7000000000000001e49 or 8.2000000000000003e65 < x Initial program 99.9%
Taylor expanded in x around inf 75.5%
*-commutative75.5%
Simplified75.5%
if -2.7000000000000001e49 < x < -2.9e-55 or 2.05e-80 < x < 6e12Initial program 99.9%
Taylor expanded in y around inf 63.3%
if -2.9e-55 < x < 2.05e-80 or 6e12 < x < 8.2000000000000003e65Initial program 100.0%
Taylor expanded in z around inf 61.6%
*-commutative61.6%
associate-*l/61.6%
Simplified61.6%
Final simplification67.7%
(FPCore (x y z)
:precision binary64
(if (or (<= x -5e+25)
(not
(or (<= x 5.2e-79)
(and (not (<= x 115000000000.0)) (<= x 2.2e+66)))))
(+ 1.0 (+ 3.0 (* x (/ 4.0 y))))
(+ 1.0 (+ 3.0 (* z (/ -4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+25) || !((x <= 5.2e-79) || (!(x <= 115000000000.0) && (x <= 2.2e+66)))) {
tmp = 1.0 + (3.0 + (x * (4.0 / y)));
} else {
tmp = 1.0 + (3.0 + (z * (-4.0 / y)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-5d+25)) .or. (.not. (x <= 5.2d-79) .or. (.not. (x <= 115000000000.0d0)) .and. (x <= 2.2d+66))) then
tmp = 1.0d0 + (3.0d0 + (x * (4.0d0 / y)))
else
tmp = 1.0d0 + (3.0d0 + (z * ((-4.0d0) / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+25) || !((x <= 5.2e-79) || (!(x <= 115000000000.0) && (x <= 2.2e+66)))) {
tmp = 1.0 + (3.0 + (x * (4.0 / y)));
} else {
tmp = 1.0 + (3.0 + (z * (-4.0 / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5e+25) or not ((x <= 5.2e-79) or (not (x <= 115000000000.0) and (x <= 2.2e+66))): tmp = 1.0 + (3.0 + (x * (4.0 / y))) else: tmp = 1.0 + (3.0 + (z * (-4.0 / y))) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5e+25) || !((x <= 5.2e-79) || (!(x <= 115000000000.0) && (x <= 2.2e+66)))) tmp = Float64(1.0 + Float64(3.0 + Float64(x * Float64(4.0 / y)))); else tmp = Float64(1.0 + Float64(3.0 + Float64(z * Float64(-4.0 / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5e+25) || ~(((x <= 5.2e-79) || (~((x <= 115000000000.0)) && (x <= 2.2e+66))))) tmp = 1.0 + (3.0 + (x * (4.0 / y))); else tmp = 1.0 + (3.0 + (z * (-4.0 / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5e+25], N[Not[Or[LessEqual[x, 5.2e-79], And[N[Not[LessEqual[x, 115000000000.0]], $MachinePrecision], LessEqual[x, 2.2e+66]]]], $MachinePrecision]], N[(1.0 + N[(3.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(3.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+25} \lor \neg \left(x \leq 5.2 \cdot 10^{-79} \lor \neg \left(x \leq 115000000000\right) \land x \leq 2.2 \cdot 10^{+66}\right):\\
\;\;\;\;1 + \left(3 + x \cdot \frac{4}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(3 + z \cdot \frac{-4}{y}\right)\\
\end{array}
\end{array}
if x < -5.00000000000000024e25 or 5.19999999999999987e-79 < x < 1.15e11 or 2.1999999999999998e66 < x Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 90.8%
associate-*r/90.8%
*-commutative90.8%
associate-*r/90.7%
Simplified90.7%
if -5.00000000000000024e25 < x < 5.19999999999999987e-79 or 1.15e11 < x < 2.1999999999999998e66Initial program 100.0%
Taylor expanded in x around 0 92.2%
div-sub92.2%
associate-/l*92.2%
*-inverses92.2%
metadata-eval92.2%
sub-neg92.2%
distribute-lft-in92.2%
metadata-eval92.2%
distribute-rgt-neg-in92.2%
*-lft-identity92.2%
associate-*l/92.1%
associate-*l*92.1%
*-commutative92.1%
distribute-rgt-neg-in92.1%
associate-*r/92.1%
metadata-eval92.1%
distribute-neg-frac92.1%
metadata-eval92.1%
Simplified92.1%
Final simplification91.4%
(FPCore (x y z)
:precision binary64
(if (or (<= x -5.5e+25)
(not
(or (<= x 5.2e-79) (and (not (<= x 95000000000.0)) (<= x 1.2e+67)))))
(+ 1.0 (+ 3.0 (* x (/ 4.0 y))))
(+ 1.0 (+ 3.0 (/ (* z -4.0) y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+25) || !((x <= 5.2e-79) || (!(x <= 95000000000.0) && (x <= 1.2e+67)))) {
tmp = 1.0 + (3.0 + (x * (4.0 / y)));
} else {
tmp = 1.0 + (3.0 + ((z * -4.0) / y));
}
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 <= (-5.5d+25)) .or. (.not. (x <= 5.2d-79) .or. (.not. (x <= 95000000000.0d0)) .and. (x <= 1.2d+67))) then
tmp = 1.0d0 + (3.0d0 + (x * (4.0d0 / y)))
else
tmp = 1.0d0 + (3.0d0 + ((z * (-4.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5.5e+25) || !((x <= 5.2e-79) || (!(x <= 95000000000.0) && (x <= 1.2e+67)))) {
tmp = 1.0 + (3.0 + (x * (4.0 / y)));
} else {
tmp = 1.0 + (3.0 + ((z * -4.0) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.5e+25) or not ((x <= 5.2e-79) or (not (x <= 95000000000.0) and (x <= 1.2e+67))): tmp = 1.0 + (3.0 + (x * (4.0 / y))) else: tmp = 1.0 + (3.0 + ((z * -4.0) / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.5e+25) || !((x <= 5.2e-79) || (!(x <= 95000000000.0) && (x <= 1.2e+67)))) tmp = Float64(1.0 + Float64(3.0 + Float64(x * Float64(4.0 / y)))); else tmp = Float64(1.0 + Float64(3.0 + Float64(Float64(z * -4.0) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5.5e+25) || ~(((x <= 5.2e-79) || (~((x <= 95000000000.0)) && (x <= 1.2e+67))))) tmp = 1.0 + (3.0 + (x * (4.0 / y))); else tmp = 1.0 + (3.0 + ((z * -4.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.5e+25], N[Not[Or[LessEqual[x, 5.2e-79], And[N[Not[LessEqual[x, 95000000000.0]], $MachinePrecision], LessEqual[x, 1.2e+67]]]], $MachinePrecision]], N[(1.0 + N[(3.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(3.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+25} \lor \neg \left(x \leq 5.2 \cdot 10^{-79} \lor \neg \left(x \leq 95000000000\right) \land x \leq 1.2 \cdot 10^{+67}\right):\\
\;\;\;\;1 + \left(3 + x \cdot \frac{4}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(3 + \frac{z \cdot -4}{y}\right)\\
\end{array}
\end{array}
if x < -5.50000000000000018e25 or 5.19999999999999987e-79 < x < 9.5e10 or 1.20000000000000001e67 < x Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 90.8%
associate-*r/90.8%
*-commutative90.8%
associate-*r/90.7%
Simplified90.7%
if -5.50000000000000018e25 < x < 5.19999999999999987e-79 or 9.5e10 < x < 1.20000000000000001e67Initial program 100.0%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 92.2%
associate-*r/92.2%
Simplified92.2%
Final simplification91.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.9e+49) (not (<= x 2.35e+88))) (+ 1.0 (* 4.0 (/ x y))) (+ 1.0 (+ 3.0 (* z (/ -4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.9e+49) || !(x <= 2.35e+88)) {
tmp = 1.0 + (4.0 * (x / y));
} else {
tmp = 1.0 + (3.0 + (z * (-4.0 / y)));
}
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 <= (-2.9d+49)) .or. (.not. (x <= 2.35d+88))) then
tmp = 1.0d0 + (4.0d0 * (x / y))
else
tmp = 1.0d0 + (3.0d0 + (z * ((-4.0d0) / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.9e+49) || !(x <= 2.35e+88)) {
tmp = 1.0 + (4.0 * (x / y));
} else {
tmp = 1.0 + (3.0 + (z * (-4.0 / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.9e+49) or not (x <= 2.35e+88): tmp = 1.0 + (4.0 * (x / y)) else: tmp = 1.0 + (3.0 + (z * (-4.0 / y))) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.9e+49) || !(x <= 2.35e+88)) tmp = Float64(1.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(1.0 + Float64(3.0 + Float64(z * Float64(-4.0 / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.9e+49) || ~((x <= 2.35e+88))) tmp = 1.0 + (4.0 * (x / y)); else tmp = 1.0 + (3.0 + (z * (-4.0 / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.9e+49], N[Not[LessEqual[x, 2.35e+88]], $MachinePrecision]], N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(3.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+49} \lor \neg \left(x \leq 2.35 \cdot 10^{+88}\right):\\
\;\;\;\;1 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(3 + z \cdot \frac{-4}{y}\right)\\
\end{array}
\end{array}
if x < -2.9e49 or 2.35000000000000004e88 < x Initial program 99.9%
Taylor expanded in x around inf 76.5%
*-commutative76.5%
Simplified76.5%
if -2.9e49 < x < 2.35000000000000004e88Initial program 99.9%
Taylor expanded in x around 0 87.5%
div-sub87.5%
associate-/l*87.5%
*-inverses87.5%
metadata-eval87.5%
sub-neg87.5%
distribute-lft-in87.5%
metadata-eval87.5%
distribute-rgt-neg-in87.5%
*-lft-identity87.5%
associate-*l/87.3%
associate-*l*87.3%
*-commutative87.3%
distribute-rgt-neg-in87.3%
associate-*r/87.3%
metadata-eval87.3%
distribute-neg-frac87.3%
metadata-eval87.3%
Simplified87.3%
Final simplification82.8%
(FPCore (x y z)
:precision binary64
(if (<= y -1.85e-12)
(+ 1.0 (+ 3.0 (* x (/ 4.0 y))))
(if (<= y 7.4e+28)
(+ 1.0 (/ (* 4.0 (- x z)) y))
(+ 1.0 (+ 3.0 (/ (* z -4.0) y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.85e-12) {
tmp = 1.0 + (3.0 + (x * (4.0 / y)));
} else if (y <= 7.4e+28) {
tmp = 1.0 + ((4.0 * (x - z)) / y);
} else {
tmp = 1.0 + (3.0 + ((z * -4.0) / y));
}
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-12)) then
tmp = 1.0d0 + (3.0d0 + (x * (4.0d0 / y)))
else if (y <= 7.4d+28) then
tmp = 1.0d0 + ((4.0d0 * (x - z)) / y)
else
tmp = 1.0d0 + (3.0d0 + ((z * (-4.0d0)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.85e-12) {
tmp = 1.0 + (3.0 + (x * (4.0 / y)));
} else if (y <= 7.4e+28) {
tmp = 1.0 + ((4.0 * (x - z)) / y);
} else {
tmp = 1.0 + (3.0 + ((z * -4.0) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.85e-12: tmp = 1.0 + (3.0 + (x * (4.0 / y))) elif y <= 7.4e+28: tmp = 1.0 + ((4.0 * (x - z)) / y) else: tmp = 1.0 + (3.0 + ((z * -4.0) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.85e-12) tmp = Float64(1.0 + Float64(3.0 + Float64(x * Float64(4.0 / y)))); elseif (y <= 7.4e+28) tmp = Float64(1.0 + Float64(Float64(4.0 * Float64(x - z)) / y)); else tmp = Float64(1.0 + Float64(3.0 + Float64(Float64(z * -4.0) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.85e-12) tmp = 1.0 + (3.0 + (x * (4.0 / y))); elseif (y <= 7.4e+28) tmp = 1.0 + ((4.0 * (x - z)) / y); else tmp = 1.0 + (3.0 + ((z * -4.0) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.85e-12], N[(1.0 + N[(3.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.4e+28], N[(1.0 + N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(3.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{-12}:\\
\;\;\;\;1 + \left(3 + x \cdot \frac{4}{y}\right)\\
\mathbf{elif}\;y \leq 7.4 \cdot 10^{+28}:\\
\;\;\;\;1 + \frac{4 \cdot \left(x - z\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(3 + \frac{z \cdot -4}{y}\right)\\
\end{array}
\end{array}
if y < -1.84999999999999999e-12Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 84.4%
associate-*r/84.4%
*-commutative84.4%
associate-*r/84.3%
Simplified84.3%
if -1.84999999999999999e-12 < y < 7.3999999999999998e28Initial program 100.0%
Taylor expanded in x around inf 95.1%
if 7.3999999999999998e28 < y Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 88.9%
associate-*r/88.9%
Simplified88.9%
Final simplification91.1%
(FPCore (x y z) :precision binary64 (if (<= y -5.5e-15) 4.0 (if (<= y 2.25e+44) (+ 1.0 (* z (/ -4.0 y))) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e-15) {
tmp = 4.0;
} else if (y <= 2.25e+44) {
tmp = 1.0 + (z * (-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 (y <= (-5.5d-15)) then
tmp = 4.0d0
else if (y <= 2.25d+44) then
tmp = 1.0d0 + (z * ((-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 (y <= -5.5e-15) {
tmp = 4.0;
} else if (y <= 2.25e+44) {
tmp = 1.0 + (z * (-4.0 / y));
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.5e-15: tmp = 4.0 elif y <= 2.25e+44: tmp = 1.0 + (z * (-4.0 / y)) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.5e-15) tmp = 4.0; elseif (y <= 2.25e+44) tmp = Float64(1.0 + Float64(z * Float64(-4.0 / y))); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.5e-15) tmp = 4.0; elseif (y <= 2.25e+44) tmp = 1.0 + (z * (-4.0 / y)); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.5e-15], 4.0, If[LessEqual[y, 2.25e+44], N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-15}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+44}:\\
\;\;\;\;1 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -5.5000000000000002e-15 or 2.25e44 < y Initial program 99.9%
Taylor expanded in y around inf 65.2%
if -5.5000000000000002e-15 < y < 2.25e44Initial program 100.0%
Taylor expanded in z around inf 44.3%
metadata-eval44.3%
distribute-lft-neg-in44.3%
*-lft-identity44.3%
associate-*l/44.2%
associate-*l*44.2%
*-commutative44.2%
distribute-rgt-neg-in44.2%
associate-*r/44.2%
metadata-eval44.2%
distribute-neg-frac44.2%
metadata-eval44.2%
Simplified44.2%
Final simplification53.7%
(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%
Taylor expanded in y around inf 33.6%
Final simplification33.6%
herbie shell --seed 2024082
(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)))