
(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 (+ 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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))) (t_1 (* z (/ -4.0 y))))
(if (<= y -1.8e-15)
2.0
(if (<= y -7e-172)
t_1
(if (<= y -1.1e-219)
t_0
(if (<= y -7.1e-245) t_1 (if (<= y 9.5e+46) t_0 2.0)))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = z * (-4.0 / y);
double tmp;
if (y <= -1.8e-15) {
tmp = 2.0;
} else if (y <= -7e-172) {
tmp = t_1;
} else if (y <= -1.1e-219) {
tmp = t_0;
} else if (y <= -7.1e-245) {
tmp = t_1;
} else if (y <= 9.5e+46) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / y)
t_1 = z * ((-4.0d0) / y)
if (y <= (-1.8d-15)) then
tmp = 2.0d0
else if (y <= (-7d-172)) then
tmp = t_1
else if (y <= (-1.1d-219)) then
tmp = t_0
else if (y <= (-7.1d-245)) then
tmp = t_1
else if (y <= 9.5d+46) then
tmp = t_0
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = z * (-4.0 / y);
double tmp;
if (y <= -1.8e-15) {
tmp = 2.0;
} else if (y <= -7e-172) {
tmp = t_1;
} else if (y <= -1.1e-219) {
tmp = t_0;
} else if (y <= -7.1e-245) {
tmp = t_1;
} else if (y <= 9.5e+46) {
tmp = t_0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) t_1 = z * (-4.0 / y) tmp = 0 if y <= -1.8e-15: tmp = 2.0 elif y <= -7e-172: tmp = t_1 elif y <= -1.1e-219: tmp = t_0 elif y <= -7.1e-245: tmp = t_1 elif y <= 9.5e+46: tmp = t_0 else: tmp = 2.0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) t_1 = Float64(z * Float64(-4.0 / y)) tmp = 0.0 if (y <= -1.8e-15) tmp = 2.0; elseif (y <= -7e-172) tmp = t_1; elseif (y <= -1.1e-219) tmp = t_0; elseif (y <= -7.1e-245) tmp = t_1; elseif (y <= 9.5e+46) tmp = t_0; else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); t_1 = z * (-4.0 / y); tmp = 0.0; if (y <= -1.8e-15) tmp = 2.0; elseif (y <= -7e-172) tmp = t_1; elseif (y <= -1.1e-219) tmp = t_0; elseif (y <= -7.1e-245) tmp = t_1; elseif (y <= 9.5e+46) tmp = t_0; else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.8e-15], 2.0, If[LessEqual[y, -7e-172], t$95$1, If[LessEqual[y, -1.1e-219], t$95$0, If[LessEqual[y, -7.1e-245], t$95$1, If[LessEqual[y, 9.5e+46], t$95$0, 2.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
t_1 := z \cdot \frac{-4}{y}\\
\mathbf{if}\;y \leq -1.8 \cdot 10^{-15}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-172}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.1 \cdot 10^{-219}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -7.1 \cdot 10^{-245}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+46}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.8000000000000001e-15 or 9.5000000000000008e46 < y Initial program 100.0%
Taylor expanded in y around inf 65.1%
if -1.8000000000000001e-15 < y < -7.00000000000000057e-172 or -1.1e-219 < y < -7.10000000000000016e-245Initial program 100.0%
Taylor expanded in z around inf 71.2%
associate-*r/71.2%
metadata-eval71.2%
associate-*r*71.2%
neg-mul-171.2%
associate-*l/71.1%
distribute-rgt-neg-out71.1%
metadata-eval71.1%
associate-*r/71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
associate-*r/71.1%
metadata-eval71.1%
distribute-neg-frac71.1%
metadata-eval71.1%
Simplified71.1%
if -7.00000000000000057e-172 < y < -1.1e-219 or -7.10000000000000016e-245 < y < 9.5000000000000008e46Initial program 100.0%
Taylor expanded in x around inf 63.5%
Final simplification65.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))))
(if (<= y -5.5e-15)
2.0
(if (<= y -2.6e-175)
(* (/ z y) -4.0)
(if (<= y -1.5e-219)
t_0
(if (<= y -4.2e-244) (* z (/ -4.0 y)) (if (<= y 2e+51) t_0 2.0)))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double tmp;
if (y <= -5.5e-15) {
tmp = 2.0;
} else if (y <= -2.6e-175) {
tmp = (z / y) * -4.0;
} else if (y <= -1.5e-219) {
tmp = t_0;
} else if (y <= -4.2e-244) {
tmp = z * (-4.0 / y);
} else if (y <= 2e+51) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = 4.0d0 * (x / y)
if (y <= (-5.5d-15)) then
tmp = 2.0d0
else if (y <= (-2.6d-175)) then
tmp = (z / y) * (-4.0d0)
else if (y <= (-1.5d-219)) then
tmp = t_0
else if (y <= (-4.2d-244)) then
tmp = z * ((-4.0d0) / y)
else if (y <= 2d+51) then
tmp = t_0
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double tmp;
if (y <= -5.5e-15) {
tmp = 2.0;
} else if (y <= -2.6e-175) {
tmp = (z / y) * -4.0;
} else if (y <= -1.5e-219) {
tmp = t_0;
} else if (y <= -4.2e-244) {
tmp = z * (-4.0 / y);
} else if (y <= 2e+51) {
tmp = t_0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) tmp = 0 if y <= -5.5e-15: tmp = 2.0 elif y <= -2.6e-175: tmp = (z / y) * -4.0 elif y <= -1.5e-219: tmp = t_0 elif y <= -4.2e-244: tmp = z * (-4.0 / y) elif y <= 2e+51: tmp = t_0 else: tmp = 2.0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (y <= -5.5e-15) tmp = 2.0; elseif (y <= -2.6e-175) tmp = Float64(Float64(z / y) * -4.0); elseif (y <= -1.5e-219) tmp = t_0; elseif (y <= -4.2e-244) tmp = Float64(z * Float64(-4.0 / y)); elseif (y <= 2e+51) tmp = t_0; else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); tmp = 0.0; if (y <= -5.5e-15) tmp = 2.0; elseif (y <= -2.6e-175) tmp = (z / y) * -4.0; elseif (y <= -1.5e-219) tmp = t_0; elseif (y <= -4.2e-244) tmp = z * (-4.0 / y); elseif (y <= 2e+51) tmp = t_0; else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.5e-15], 2.0, If[LessEqual[y, -2.6e-175], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], If[LessEqual[y, -1.5e-219], t$95$0, If[LessEqual[y, -4.2e-244], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2e+51], t$95$0, 2.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{-15}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq -2.6 \cdot 10^{-175}:\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{-219}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.2 \cdot 10^{-244}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+51}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -5.5000000000000002e-15 or 2e51 < y Initial program 100.0%
Taylor expanded in y around inf 65.1%
if -5.5000000000000002e-15 < y < -2.6e-175Initial program 100.0%
Taylor expanded in z around inf 66.7%
*-commutative66.7%
Simplified66.7%
if -2.6e-175 < y < -1.5e-219 or -4.20000000000000003e-244 < y < 2e51Initial program 100.0%
Taylor expanded in x around inf 63.5%
if -1.5e-219 < y < -4.20000000000000003e-244Initial program 100.0%
Taylor expanded in z around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
associate-*r*100.0%
neg-mul-1100.0%
associate-*l/100.0%
distribute-rgt-neg-out100.0%
metadata-eval100.0%
associate-*r/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification65.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.05e-13) (not (<= y 7.8e+28))) (+ 2.0 (* (/ z y) -4.0)) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.05e-13) || !(y <= 7.8e+28)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = 4.0 * ((x - z) / 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.05d-13)) .or. (.not. (y <= 7.8d+28))) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
else
tmp = 4.0d0 * ((x - z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.05e-13) || !(y <= 7.8e+28)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.05e-13) or not (y <= 7.8e+28): tmp = 2.0 + ((z / y) * -4.0) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.05e-13) || !(y <= 7.8e+28)) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); else tmp = Float64(4.0 * Float64(Float64(x - z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.05e-13) || ~((y <= 7.8e+28))) tmp = 2.0 + ((z / y) * -4.0); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.05e-13], N[Not[LessEqual[y, 7.8e+28]], $MachinePrecision]], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{-13} \lor \neg \left(y \leq 7.8 \cdot 10^{+28}\right):\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -1.04999999999999994e-13 or 7.7999999999999997e28 < y Initial 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%
Taylor expanded in x around 0 82.5%
*-commutative82.5%
Simplified82.5%
if -1.04999999999999994e-13 < y < 7.7999999999999997e28Initial program 100.0%
Taylor expanded in y around 0 94.3%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e+175) 2.0 (if (<= y 7.1e+46) (* 4.0 (/ (- x z) y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+175) {
tmp = 2.0;
} else if (y <= 7.1e+46) {
tmp = 4.0 * ((x - z) / 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 (y <= (-2.7d+175)) then
tmp = 2.0d0
else if (y <= 7.1d+46) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+175) {
tmp = 2.0;
} else if (y <= 7.1e+46) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+175: tmp = 2.0 elif y <= 7.1e+46: tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+175) tmp = 2.0; elseif (y <= 7.1e+46) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.7e+175) tmp = 2.0; elseif (y <= 7.1e+46) tmp = 4.0 * ((x - z) / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+175], 2.0, If[LessEqual[y, 7.1e+46], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+175}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 7.1 \cdot 10^{+46}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -2.7000000000000001e175 or 7.1e46 < y Initial program 100.0%
Taylor expanded in y around inf 77.4%
if -2.7000000000000001e175 < y < 7.1e46Initial program 100.0%
Taylor expanded in y around 0 85.2%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.85e-12) (+ 2.0 (* 4.0 (/ x y))) (if (<= y 1.72e+28) (* 4.0 (/ (- x z) y)) (+ 2.0 (* (/ z y) -4.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.85e-12) {
tmp = 2.0 + (4.0 * (x / y));
} else if (y <= 1.72e+28) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0 + ((z / y) * -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 <= (-1.85d-12)) then
tmp = 2.0d0 + (4.0d0 * (x / y))
else if (y <= 1.72d+28) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 2.0d0 + ((z / y) * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.85e-12) {
tmp = 2.0 + (4.0 * (x / y));
} else if (y <= 1.72e+28) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.85e-12: tmp = 2.0 + (4.0 * (x / y)) elif y <= 1.72e+28: tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.85e-12) tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); elseif (y <= 1.72e+28) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.85e-12) tmp = 2.0 + (4.0 * (x / y)); elseif (y <= 1.72e+28) tmp = 4.0 * ((x - z) / y); else tmp = 2.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.85e-12], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.72e+28], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{-12}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 1.72 \cdot 10^{+28}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if y < -1.84999999999999999e-12Initial 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%
Taylor expanded in z around 0 84.3%
+-commutative84.3%
Simplified84.3%
if -1.84999999999999999e-12 < y < 1.72000000000000003e28Initial program 100.0%
Taylor expanded in y around 0 94.3%
if 1.72000000000000003e28 < y Initial 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%
Taylor expanded in x around 0 88.9%
*-commutative88.9%
Simplified88.9%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (<= y -9e-13) 2.0 (if (<= y 1.6e+49) (* 4.0 (/ x y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -9e-13) {
tmp = 2.0;
} else if (y <= 1.6e+49) {
tmp = 4.0 * (x / 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 (y <= (-9d-13)) then
tmp = 2.0d0
else if (y <= 1.6d+49) then
tmp = 4.0d0 * (x / y)
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -9e-13) {
tmp = 2.0;
} else if (y <= 1.6e+49) {
tmp = 4.0 * (x / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9e-13: tmp = 2.0 elif y <= 1.6e+49: tmp = 4.0 * (x / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9e-13) tmp = 2.0; elseif (y <= 1.6e+49) tmp = Float64(4.0 * Float64(x / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9e-13) tmp = 2.0; elseif (y <= 1.6e+49) tmp = 4.0 * (x / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9e-13], 2.0, If[LessEqual[y, 1.6e+49], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{-13}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+49}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -9e-13 or 1.60000000000000007e49 < y Initial program 100.0%
Taylor expanded in y around inf 65.6%
if -9e-13 < y < 1.60000000000000007e49Initial program 100.0%
Taylor expanded in x around inf 55.3%
Final simplification59.9%
(FPCore (x y z) :precision binary64 (+ (/ 1.0 (/ y (* 4.0 (- x z)))) 2.0))
double code(double x, double y, double z) {
return (1.0 / (y / (4.0 * (x - z)))) + 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 = (1.0d0 / (y / (4.0d0 * (x - z)))) + 2.0d0
end function
public static double code(double x, double y, double z) {
return (1.0 / (y / (4.0 * (x - z)))) + 2.0;
}
def code(x, y, z): return (1.0 / (y / (4.0 * (x - z)))) + 2.0
function code(x, y, z) return Float64(Float64(1.0 / Float64(y / Float64(4.0 * Float64(x - z)))) + 2.0) end
function tmp = code(x, y, z) tmp = (1.0 / (y / (4.0 * (x - z)))) + 2.0; end
code[x_, y_, z_] := N[(N[(1.0 / N[(y / N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{y}{4 \cdot \left(x - z\right)}} + 2
\end{array}
Initial 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%
associate-*l/100.0%
clear-num99.8%
Applied egg-rr99.8%
Final simplification99.8%
(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.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%
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.5%
Final simplification33.5%
herbie shell --seed 2024082
(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)))