
(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 8 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.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%
Final simplification100.0%
(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 -7.8e+77)
t_1
(if (<= z 2.9e-208)
t_0
(if (<= z 5.3e-52) 2.0 (if (<= z 7.4e+36) 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 <= -7.8e+77) {
tmp = t_1;
} else if (z <= 2.9e-208) {
tmp = t_0;
} else if (z <= 5.3e-52) {
tmp = 2.0;
} else if (z <= 7.4e+36) {
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 <= (-7.8d+77)) then
tmp = t_1
else if (z <= 2.9d-208) then
tmp = t_0
else if (z <= 5.3d-52) then
tmp = 2.0d0
else if (z <= 7.4d+36) 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 <= -7.8e+77) {
tmp = t_1;
} else if (z <= 2.9e-208) {
tmp = t_0;
} else if (z <= 5.3e-52) {
tmp = 2.0;
} else if (z <= 7.4e+36) {
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 <= -7.8e+77: tmp = t_1 elif z <= 2.9e-208: tmp = t_0 elif z <= 5.3e-52: tmp = 2.0 elif z <= 7.4e+36: 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 <= -7.8e+77) tmp = t_1; elseif (z <= 2.9e-208) tmp = t_0; elseif (z <= 5.3e-52) tmp = 2.0; elseif (z <= 7.4e+36) 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 <= -7.8e+77) tmp = t_1; elseif (z <= 2.9e-208) tmp = t_0; elseif (z <= 5.3e-52) tmp = 2.0; elseif (z <= 7.4e+36) 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, -7.8e+77], t$95$1, If[LessEqual[z, 2.9e-208], t$95$0, If[LessEqual[z, 5.3e-52], 2.0, If[LessEqual[z, 7.4e+36], 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 -7.8 \cdot 10^{+77}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-208}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.3 \cdot 10^{-52}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{+36}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.7999999999999995e77 or 7.40000000000000058e36 < z Initial program 100.0%
Taylor expanded in z around inf 74.6%
*-commutative74.6%
Simplified74.6%
if -7.7999999999999995e77 < z < 2.8999999999999999e-208 or 5.3000000000000003e-52 < z < 7.40000000000000058e36Initial program 100.0%
Taylor expanded in x around inf 60.9%
associate-*r/60.9%
associate-*l/60.8%
*-commutative60.8%
Simplified60.8%
if 2.8999999999999999e-208 < z < 5.3000000000000003e-52Initial program 100.0%
Taylor expanded in y around inf 68.9%
Final simplification67.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (/ (* x 4.0) y) 1.0)) (t_1 (+ 1.0 (* -4.0 (/ z y)))))
(if (<= z -1.45e+80)
t_1
(if (<= z 2.95e-207)
t_0
(if (<= z 4.6e-52) 2.0 (if (<= z 1.75e+37) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = ((x * 4.0) / y) + 1.0;
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -1.45e+80) {
tmp = t_1;
} else if (z <= 2.95e-207) {
tmp = t_0;
} else if (z <= 4.6e-52) {
tmp = 2.0;
} else if (z <= 1.75e+37) {
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 = ((x * 4.0d0) / y) + 1.0d0
t_1 = 1.0d0 + ((-4.0d0) * (z / y))
if (z <= (-1.45d+80)) then
tmp = t_1
else if (z <= 2.95d-207) then
tmp = t_0
else if (z <= 4.6d-52) then
tmp = 2.0d0
else if (z <= 1.75d+37) 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 = ((x * 4.0) / y) + 1.0;
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -1.45e+80) {
tmp = t_1;
} else if (z <= 2.95e-207) {
tmp = t_0;
} else if (z <= 4.6e-52) {
tmp = 2.0;
} else if (z <= 1.75e+37) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = ((x * 4.0) / y) + 1.0 t_1 = 1.0 + (-4.0 * (z / y)) tmp = 0 if z <= -1.45e+80: tmp = t_1 elif z <= 2.95e-207: tmp = t_0 elif z <= 4.6e-52: tmp = 2.0 elif z <= 1.75e+37: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(x * 4.0) / y) + 1.0) t_1 = Float64(1.0 + Float64(-4.0 * Float64(z / y))) tmp = 0.0 if (z <= -1.45e+80) tmp = t_1; elseif (z <= 2.95e-207) tmp = t_0; elseif (z <= 4.6e-52) tmp = 2.0; elseif (z <= 1.75e+37) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((x * 4.0) / y) + 1.0; t_1 = 1.0 + (-4.0 * (z / y)); tmp = 0.0; if (z <= -1.45e+80) tmp = t_1; elseif (z <= 2.95e-207) tmp = t_0; elseif (z <= 4.6e-52) tmp = 2.0; elseif (z <= 1.75e+37) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.45e+80], t$95$1, If[LessEqual[z, 2.95e-207], t$95$0, If[LessEqual[z, 4.6e-52], 2.0, If[LessEqual[z, 1.75e+37], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{y} + 1\\
t_1 := 1 + -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -1.45 \cdot 10^{+80}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.95 \cdot 10^{-207}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{-52}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{+37}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.44999999999999993e80 or 1.75e37 < z Initial program 100.0%
Taylor expanded in z around inf 74.6%
*-commutative74.6%
Simplified74.6%
if -1.44999999999999993e80 < z < 2.94999999999999986e-207 or 4.59999999999999989e-52 < z < 1.75e37Initial program 100.0%
Taylor expanded in x around inf 60.9%
associate-*r/60.9%
Simplified60.9%
if 2.94999999999999986e-207 < z < 4.59999999999999989e-52Initial program 100.0%
Taylor expanded in y around inf 68.9%
Final simplification67.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.3e+172) (not (<= x 3.3e+223))) (+ (/ (* x 4.0) y) 1.0) (+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.3e+172) || !(x <= 3.3e+223)) {
tmp = ((x * 4.0) / y) + 1.0;
} else {
tmp = 2.0 + (-4.0 * (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 ((x <= (-1.3d+172)) .or. (.not. (x <= 3.3d+223))) then
tmp = ((x * 4.0d0) / y) + 1.0d0
else
tmp = 2.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.3e+172) || !(x <= 3.3e+223)) {
tmp = ((x * 4.0) / y) + 1.0;
} else {
tmp = 2.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.3e+172) or not (x <= 3.3e+223): tmp = ((x * 4.0) / y) + 1.0 else: tmp = 2.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.3e+172) || !(x <= 3.3e+223)) tmp = Float64(Float64(Float64(x * 4.0) / y) + 1.0); else tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.3e+172) || ~((x <= 3.3e+223))) tmp = ((x * 4.0) / y) + 1.0; else tmp = 2.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.3e+172], N[Not[LessEqual[x, 3.3e+223]], $MachinePrecision]], N[(N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision] + 1.0), $MachinePrecision], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{+172} \lor \neg \left(x \leq 3.3 \cdot 10^{+223}\right):\\
\;\;\;\;\frac{x \cdot 4}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -1.3e172 or 3.3e223 < x Initial program 100.0%
Taylor expanded in x around inf 86.4%
associate-*r/86.4%
Simplified86.4%
if -1.3e172 < x < 3.3e223Initial 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 0 80.4%
Final simplification81.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.85e+77) (not (<= z 1.08e+39))) (+ 2.0 (* -4.0 (/ z y))) (+ 2.0 (/ (* x 4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.85e+77) || !(z <= 1.08e+39)) {
tmp = 2.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + ((x * 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 ((z <= (-1.85d+77)) .or. (.not. (z <= 1.08d+39))) then
tmp = 2.0d0 + ((-4.0d0) * (z / y))
else
tmp = 2.0d0 + ((x * 4.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.85e+77) || !(z <= 1.08e+39)) {
tmp = 2.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + ((x * 4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.85e+77) or not (z <= 1.08e+39): tmp = 2.0 + (-4.0 * (z / y)) else: tmp = 2.0 + ((x * 4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.85e+77) || !(z <= 1.08e+39)) tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y))); else tmp = Float64(2.0 + Float64(Float64(x * 4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.85e+77) || ~((z <= 1.08e+39))) tmp = 2.0 + (-4.0 * (z / y)); else tmp = 2.0 + ((x * 4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.85e+77], N[Not[LessEqual[z, 1.08e+39]], $MachinePrecision]], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{+77} \lor \neg \left(z \leq 1.08 \cdot 10^{+39}\right):\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{x \cdot 4}{y}\\
\end{array}
\end{array}
if z < -1.84999999999999997e77 or 1.07999999999999998e39 < z Initial program 100.0%
+-commutative100.0%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
distribute-lft-in99.7%
associate-+l+99.7%
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 91.9%
if -1.84999999999999997e77 < z < 1.07999999999999998e39Initial 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 91.7%
associate-*r/91.7%
Simplified91.7%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (<= y -7.5e+155) 2.0 (if (<= y 3e+86) (+ 1.0 (* x (/ 4.0 y))) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.5e+155) {
tmp = 2.0;
} else if (y <= 3e+86) {
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 (y <= (-7.5d+155)) then
tmp = 2.0d0
else if (y <= 3d+86) 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 (y <= -7.5e+155) {
tmp = 2.0;
} else if (y <= 3e+86) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.5e+155: tmp = 2.0 elif y <= 3e+86: tmp = 1.0 + (x * (4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.5e+155) tmp = 2.0; elseif (y <= 3e+86) 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 (y <= -7.5e+155) tmp = 2.0; elseif (y <= 3e+86) tmp = 1.0 + (x * (4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.5e+155], 2.0, If[LessEqual[y, 3e+86], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+155}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+86}:\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -7.4999999999999999e155 or 2.99999999999999977e86 < y Initial program 100.0%
Taylor expanded in y around inf 70.2%
if -7.4999999999999999e155 < y < 2.99999999999999977e86Initial program 100.0%
Taylor expanded in x around inf 46.7%
associate-*r/46.7%
associate-*l/46.6%
*-commutative46.6%
Simplified46.6%
Final simplification53.9%
(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 34.4%
Final simplification34.4%
herbie shell --seed 2024078
(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)))