
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - 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.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - 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.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ (/ (- x z) (* y 0.25)) 2.0))
double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 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 = ((x - z) / (y * 0.25d0)) + 2.0d0
end function
public static double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 2.0;
}
def code(x, y, z): return ((x - z) / (y * 0.25)) + 2.0
function code(x, y, z) return Float64(Float64(Float64(x - z) / Float64(y * 0.25)) + 2.0) end
function tmp = code(x, y, z) tmp = ((x - z) / (y * 0.25)) + 2.0; end
code[x_, y_, z_] := N[(N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - z}{y \cdot 0.25} + 2
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.4%
associate-+l+99.4%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
(FPCore (x y z)
:precision binary64
(if (or (<= z -1.9e+172)
(and (not (<= z -4.2e+103)) (or (<= z -1.1e+68) (not (<= z 8e+106)))))
(+ 1.0 (* -4.0 (/ z y)))
(+ 2.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9e+172) || (!(z <= -4.2e+103) && ((z <= -1.1e+68) || !(z <= 8e+106)))) {
tmp = 1.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + (4.0 * (x / 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 ((z <= (-1.9d+172)) .or. (.not. (z <= (-4.2d+103))) .and. (z <= (-1.1d+68)) .or. (.not. (z <= 8d+106))) then
tmp = 1.0d0 + ((-4.0d0) * (z / y))
else
tmp = 2.0d0 + (4.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9e+172) || (!(z <= -4.2e+103) && ((z <= -1.1e+68) || !(z <= 8e+106)))) {
tmp = 1.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.9e+172) or (not (z <= -4.2e+103) and ((z <= -1.1e+68) or not (z <= 8e+106))): tmp = 1.0 + (-4.0 * (z / y)) else: tmp = 2.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.9e+172) || (!(z <= -4.2e+103) && ((z <= -1.1e+68) || !(z <= 8e+106)))) tmp = Float64(1.0 + Float64(-4.0 * Float64(z / y))); else tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.9e+172) || (~((z <= -4.2e+103)) && ((z <= -1.1e+68) || ~((z <= 8e+106))))) tmp = 1.0 + (-4.0 * (z / y)); else tmp = 2.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.9e+172], And[N[Not[LessEqual[z, -4.2e+103]], $MachinePrecision], Or[LessEqual[z, -1.1e+68], N[Not[LessEqual[z, 8e+106]], $MachinePrecision]]]], N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+172} \lor \neg \left(z \leq -4.2 \cdot 10^{+103}\right) \land \left(z \leq -1.1 \cdot 10^{+68} \lor \neg \left(z \leq 8 \cdot 10^{+106}\right)\right):\\
\;\;\;\;1 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -1.89999999999999985e172 or -4.2000000000000003e103 < z < -1.09999999999999994e68 or 8.00000000000000073e106 < z Initial program 100.0%
Taylor expanded in z around inf 80.4%
*-commutative80.4%
Simplified80.4%
if -1.89999999999999985e172 < z < -4.2000000000000003e103 or -1.09999999999999994e68 < z < 8.00000000000000073e106Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 83.3%
Final simplification82.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* x 4.0) y))) (t_1 (+ 1.0 (* -4.0 (/ z y)))))
(if (<= z -1.15e+68)
t_1
(if (<= z 1.02e-177)
t_0
(if (<= z 4.8e-138) 2.0 (if (<= z 2.6e-20) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((x * 4.0) / y);
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -1.15e+68) {
tmp = t_1;
} else if (z <= 1.02e-177) {
tmp = t_0;
} else if (z <= 4.8e-138) {
tmp = 2.0;
} else if (z <= 2.6e-20) {
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 + ((x * 4.0d0) / y)
t_1 = 1.0d0 + ((-4.0d0) * (z / y))
if (z <= (-1.15d+68)) then
tmp = t_1
else if (z <= 1.02d-177) then
tmp = t_0
else if (z <= 4.8d-138) then
tmp = 2.0d0
else if (z <= 2.6d-20) 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 + ((x * 4.0) / y);
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -1.15e+68) {
tmp = t_1;
} else if (z <= 1.02e-177) {
tmp = t_0;
} else if (z <= 4.8e-138) {
tmp = 2.0;
} else if (z <= 2.6e-20) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((x * 4.0) / y) t_1 = 1.0 + (-4.0 * (z / y)) tmp = 0 if z <= -1.15e+68: tmp = t_1 elif z <= 1.02e-177: tmp = t_0 elif z <= 4.8e-138: tmp = 2.0 elif z <= 2.6e-20: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(x * 4.0) / y)) t_1 = Float64(1.0 + Float64(-4.0 * Float64(z / y))) tmp = 0.0 if (z <= -1.15e+68) tmp = t_1; elseif (z <= 1.02e-177) tmp = t_0; elseif (z <= 4.8e-138) tmp = 2.0; elseif (z <= 2.6e-20) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((x * 4.0) / y); t_1 = 1.0 + (-4.0 * (z / y)); tmp = 0.0; if (z <= -1.15e+68) tmp = t_1; elseif (z <= 1.02e-177) tmp = t_0; elseif (z <= 4.8e-138) tmp = 2.0; elseif (z <= 2.6e-20) 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[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.15e+68], t$95$1, If[LessEqual[z, 1.02e-177], t$95$0, If[LessEqual[z, 4.8e-138], 2.0, If[LessEqual[z, 2.6e-20], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x \cdot 4}{y}\\
t_1 := 1 + -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -1.15 \cdot 10^{+68}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.02 \cdot 10^{-177}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-138}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-20}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.15e68 or 2.59999999999999995e-20 < z Initial program 100.0%
Taylor expanded in z around inf 68.4%
*-commutative68.4%
Simplified68.4%
if -1.15e68 < z < 1.01999999999999997e-177 or 4.7999999999999998e-138 < z < 2.59999999999999995e-20Initial program 100.0%
Taylor expanded in x around inf 57.0%
*-commutative57.0%
associate-*l/57.0%
Simplified57.0%
if 1.01999999999999997e-177 < z < 4.7999999999999998e-138Initial program 100.0%
Taylor expanded in y around inf 90.1%
Final simplification63.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* x (/ 4.0 y)))) (t_1 (+ 1.0 (* -4.0 (/ z y)))))
(if (<= z -9.5e+67)
t_1
(if (<= z 7.5e-178)
t_0
(if (<= z 1.95e-138) 2.0 (if (<= z 2.8e-20) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (x * (4.0 / y));
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -9.5e+67) {
tmp = t_1;
} else if (z <= 7.5e-178) {
tmp = t_0;
} else if (z <= 1.95e-138) {
tmp = 2.0;
} else if (z <= 2.8e-20) {
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 + (x * (4.0d0 / y))
t_1 = 1.0d0 + ((-4.0d0) * (z / y))
if (z <= (-9.5d+67)) then
tmp = t_1
else if (z <= 7.5d-178) then
tmp = t_0
else if (z <= 1.95d-138) then
tmp = 2.0d0
else if (z <= 2.8d-20) 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 + (x * (4.0 / y));
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -9.5e+67) {
tmp = t_1;
} else if (z <= 7.5e-178) {
tmp = t_0;
} else if (z <= 1.95e-138) {
tmp = 2.0;
} else if (z <= 2.8e-20) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (x * (4.0 / y)) t_1 = 1.0 + (-4.0 * (z / y)) tmp = 0 if z <= -9.5e+67: tmp = t_1 elif z <= 7.5e-178: tmp = t_0 elif z <= 1.95e-138: tmp = 2.0 elif z <= 2.8e-20: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(x * Float64(4.0 / y))) t_1 = Float64(1.0 + Float64(-4.0 * Float64(z / y))) tmp = 0.0 if (z <= -9.5e+67) tmp = t_1; elseif (z <= 7.5e-178) tmp = t_0; elseif (z <= 1.95e-138) tmp = 2.0; elseif (z <= 2.8e-20) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (x * (4.0 / y)); t_1 = 1.0 + (-4.0 * (z / y)); tmp = 0.0; if (z <= -9.5e+67) tmp = t_1; elseif (z <= 7.5e-178) tmp = t_0; elseif (z <= 1.95e-138) tmp = 2.0; elseif (z <= 2.8e-20) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.5e+67], t$95$1, If[LessEqual[z, 7.5e-178], t$95$0, If[LessEqual[z, 1.95e-138], 2.0, If[LessEqual[z, 2.8e-20], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + x \cdot \frac{4}{y}\\
t_1 := 1 + -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{+67}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{-178}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{-138}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-20}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -9.5000000000000002e67 or 2.8000000000000003e-20 < z Initial program 100.0%
Taylor expanded in z around inf 68.4%
*-commutative68.4%
Simplified68.4%
if -9.5000000000000002e67 < z < 7.50000000000000019e-178 or 1.95e-138 < z < 2.8000000000000003e-20Initial program 100.0%
Taylor expanded in x around inf 57.0%
associate-*r/57.0%
associate-*l/56.8%
*-commutative56.8%
Simplified56.8%
if 7.50000000000000019e-178 < z < 1.95e-138Initial program 100.0%
Taylor expanded in y around inf 90.1%
Final simplification63.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* x (/ 4.0 y)))) (t_1 (+ 1.0 (* z (/ -4.0 y)))))
(if (<= z -9.5e+67)
t_1
(if (<= z 2.9e-177)
t_0
(if (<= z 9.5e-146) 2.0 (if (<= z 1.6e-20) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (x * (4.0 / y));
double t_1 = 1.0 + (z * (-4.0 / y));
double tmp;
if (z <= -9.5e+67) {
tmp = t_1;
} else if (z <= 2.9e-177) {
tmp = t_0;
} else if (z <= 9.5e-146) {
tmp = 2.0;
} else if (z <= 1.6e-20) {
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 + (x * (4.0d0 / y))
t_1 = 1.0d0 + (z * ((-4.0d0) / y))
if (z <= (-9.5d+67)) then
tmp = t_1
else if (z <= 2.9d-177) then
tmp = t_0
else if (z <= 9.5d-146) then
tmp = 2.0d0
else if (z <= 1.6d-20) 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 + (x * (4.0 / y));
double t_1 = 1.0 + (z * (-4.0 / y));
double tmp;
if (z <= -9.5e+67) {
tmp = t_1;
} else if (z <= 2.9e-177) {
tmp = t_0;
} else if (z <= 9.5e-146) {
tmp = 2.0;
} else if (z <= 1.6e-20) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (x * (4.0 / y)) t_1 = 1.0 + (z * (-4.0 / y)) tmp = 0 if z <= -9.5e+67: tmp = t_1 elif z <= 2.9e-177: tmp = t_0 elif z <= 9.5e-146: tmp = 2.0 elif z <= 1.6e-20: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(x * Float64(4.0 / y))) t_1 = Float64(1.0 + Float64(z * Float64(-4.0 / y))) tmp = 0.0 if (z <= -9.5e+67) tmp = t_1; elseif (z <= 2.9e-177) tmp = t_0; elseif (z <= 9.5e-146) tmp = 2.0; elseif (z <= 1.6e-20) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (x * (4.0 / y)); t_1 = 1.0 + (z * (-4.0 / y)); tmp = 0.0; if (z <= -9.5e+67) tmp = t_1; elseif (z <= 2.9e-177) tmp = t_0; elseif (z <= 9.5e-146) tmp = 2.0; elseif (z <= 1.6e-20) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.5e+67], t$95$1, If[LessEqual[z, 2.9e-177], t$95$0, If[LessEqual[z, 9.5e-146], 2.0, If[LessEqual[z, 1.6e-20], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + x \cdot \frac{4}{y}\\
t_1 := 1 + z \cdot \frac{-4}{y}\\
\mathbf{if}\;z \leq -9.5 \cdot 10^{+67}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-177}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{-146}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-20}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -9.5000000000000002e67 or 1.59999999999999985e-20 < z Initial program 100.0%
Taylor expanded in z around inf 68.4%
associate-*r/68.4%
metadata-eval68.4%
associate-*r*68.4%
neg-mul-168.4%
*-commutative68.4%
associate-*r/68.1%
distribute-lft-neg-out68.1%
distribute-rgt-neg-in68.1%
distribute-neg-frac68.1%
metadata-eval68.1%
Simplified68.1%
if -9.5000000000000002e67 < z < 2.89999999999999997e-177 or 9.5000000000000005e-146 < z < 1.59999999999999985e-20Initial program 100.0%
Taylor expanded in x around inf 57.0%
associate-*r/57.0%
associate-*l/56.8%
*-commutative56.8%
Simplified56.8%
if 2.89999999999999997e-177 < z < 9.5000000000000005e-146Initial program 100.0%
Taylor expanded in y around inf 90.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.02e+68) (not (<= z 5.1e-20))) (+ 2.0 (/ (* z -4.0) y)) (+ 2.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.02e+68) || !(z <= 5.1e-20)) {
tmp = 2.0 + ((z * -4.0) / y);
} else {
tmp = 2.0 + (4.0 * (x / 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 ((z <= (-1.02d+68)) .or. (.not. (z <= 5.1d-20))) then
tmp = 2.0d0 + ((z * (-4.0d0)) / y)
else
tmp = 2.0d0 + (4.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.02e+68) || !(z <= 5.1e-20)) {
tmp = 2.0 + ((z * -4.0) / y);
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.02e+68) or not (z <= 5.1e-20): tmp = 2.0 + ((z * -4.0) / y) else: tmp = 2.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.02e+68) || !(z <= 5.1e-20)) tmp = Float64(2.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.02e+68) || ~((z <= 5.1e-20))) tmp = 2.0 + ((z * -4.0) / y); else tmp = 2.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.02e+68], N[Not[LessEqual[z, 5.1e-20]], $MachinePrecision]], N[(2.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.02 \cdot 10^{+68} \lor \neg \left(z \leq 5.1 \cdot 10^{-20}\right):\\
\;\;\;\;2 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -1.02e68 or 5.10000000000000019e-20 < z Initial program 100.0%
+-commutative100.0%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
distribute-lft-in98.8%
associate-+l+98.8%
associate-*l/99.7%
*-commutative99.7%
associate-*l*99.7%
metadata-eval99.7%
*-rgt-identity99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
clear-num99.7%
div-inv99.7%
metadata-eval99.7%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 85.6%
associate-*r/85.6%
Simplified85.6%
if -1.02e68 < z < 5.10000000000000019e-20Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.9%
associate-*l/99.9%
*-commutative99.9%
associate-*l*99.9%
metadata-eval99.9%
*-rgt-identity99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
div-inv99.9%
metadata-eval99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 89.3%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.5e+141) (not (<= x 4.5e-9))) (+ 1.0 (* x (/ 4.0 y))) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e+141) || !(x <= 4.5e-9)) {
tmp = 1.0 + (x * (4.0 / y));
} 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 <= (-9.5d+141)) .or. (.not. (x <= 4.5d-9))) then
tmp = 1.0d0 + (x * (4.0d0 / y))
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e+141) || !(x <= 4.5e-9)) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.5e+141) or not (x <= 4.5e-9): tmp = 1.0 + (x * (4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.5e+141) || !(x <= 4.5e-9)) tmp = Float64(1.0 + Float64(x * Float64(4.0 / y))); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.5e+141) || ~((x <= 4.5e-9))) tmp = 1.0 + (x * (4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.5e+141], N[Not[LessEqual[x, 4.5e-9]], $MachinePrecision]], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+141} \lor \neg \left(x \leq 4.5 \cdot 10^{-9}\right):\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if x < -9.49999999999999974e141 or 4.49999999999999976e-9 < x Initial program 100.0%
Taylor expanded in x around inf 71.1%
associate-*r/71.1%
associate-*l/70.9%
*-commutative70.9%
Simplified70.9%
if -9.49999999999999974e141 < x < 4.49999999999999976e-9Initial program 100.0%
Taylor expanded in y around inf 45.7%
Final simplification55.0%
(FPCore (x y z) :precision binary64 (+ 2.0 (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
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 + ((x - z) * (4.0d0 / y))
end function
public static double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
def code(x, y, z): return 2.0 + ((x - z) * (4.0 / y))
function code(x, y, z) return Float64(2.0 + Float64(Float64(x - z) * Float64(4.0 / y))) end
function tmp = code(x, y, z) tmp = 2.0 + ((x - z) * (4.0 / y)); end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 + \left(x - z\right) \cdot \frac{4}{y}
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.4%
associate-+l+99.4%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(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%
Taylor expanded in y around inf 33.9%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.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
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 38.8%
associate-*r/38.8%
associate-*l/38.7%
*-commutative38.7%
Simplified38.7%
Taylor expanded in x around 0 8.2%
herbie shell --seed 2024085
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))