
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* y y))))
double code(double x, double y) {
return x * (1.0 + (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (y * y))
end function
public static double code(double x, double y) {
return x * (1.0 + (y * y));
}
def code(x, y): return x * (1.0 + (y * y))
function code(x, y) return Float64(x * Float64(1.0 + Float64(y * y))) end
function tmp = code(x, y) tmp = x * (1.0 + (y * y)); end
code[x_, y_] := N[(x * N[(1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + y \cdot y\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* x (+ 1.0 (* y y))))
double code(double x, double y) {
return x * (1.0 + (y * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (1.0d0 + (y * y))
end function
public static double code(double x, double y) {
return x * (1.0 + (y * y));
}
def code(x, y): return x * (1.0 + (y * y))
function code(x, y) return Float64(x * Float64(1.0 + Float64(y * y))) end
function tmp = code(x, y) tmp = x * (1.0 + (y * y)); end
code[x_, y_] := N[(x * N[(1.0 + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + y \cdot y\right)
\end{array}
(FPCore (x y) :precision binary64 (if (<= (* y y) 5e+250) (+ x (* x (* y y))) (* y (* x y))))
double code(double x, double y) {
double tmp;
if ((y * y) <= 5e+250) {
tmp = x + (x * (y * y));
} else {
tmp = y * (x * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y * y) <= 5d+250) then
tmp = x + (x * (y * y))
else
tmp = y * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y * y) <= 5e+250) {
tmp = x + (x * (y * y));
} else {
tmp = y * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y * y) <= 5e+250: tmp = x + (x * (y * y)) else: tmp = y * (x * y) return tmp
function code(x, y) tmp = 0.0 if (Float64(y * y) <= 5e+250) tmp = Float64(x + Float64(x * Float64(y * y))); else tmp = Float64(y * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y * y) <= 5e+250) tmp = x + (x * (y * y)); else tmp = y * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(y * y), $MachinePrecision], 5e+250], N[(x + N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot y \leq 5 \cdot 10^{+250}:\\
\;\;\;\;x + x \cdot \left(y \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 y y) < 5.0000000000000002e250Initial program 99.9%
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6499.9%
Applied egg-rr99.9%
if 5.0000000000000002e250 < (*.f64 y y) Initial program 82.0%
Taylor expanded in y around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6482.0%
Simplified82.0%
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6499.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (* y y) 5e+250) (* x (+ (* y y) 1.0)) (* y (* x y))))
double code(double x, double y) {
double tmp;
if ((y * y) <= 5e+250) {
tmp = x * ((y * y) + 1.0);
} else {
tmp = y * (x * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y * y) <= 5d+250) then
tmp = x * ((y * y) + 1.0d0)
else
tmp = y * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y * y) <= 5e+250) {
tmp = x * ((y * y) + 1.0);
} else {
tmp = y * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y * y) <= 5e+250: tmp = x * ((y * y) + 1.0) else: tmp = y * (x * y) return tmp
function code(x, y) tmp = 0.0 if (Float64(y * y) <= 5e+250) tmp = Float64(x * Float64(Float64(y * y) + 1.0)); else tmp = Float64(y * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y * y) <= 5e+250) tmp = x * ((y * y) + 1.0); else tmp = y * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(y * y), $MachinePrecision], 5e+250], N[(x * N[(N[(y * y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot y \leq 5 \cdot 10^{+250}:\\
\;\;\;\;x \cdot \left(y \cdot y + 1\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 y y) < 5.0000000000000002e250Initial program 99.9%
if 5.0000000000000002e250 < (*.f64 y y) Initial program 82.0%
Taylor expanded in y around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6482.0%
Simplified82.0%
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6499.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (* y y) 0.4) x (* y (* x y))))
double code(double x, double y) {
double tmp;
if ((y * y) <= 0.4) {
tmp = x;
} else {
tmp = y * (x * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y * y) <= 0.4d0) then
tmp = x
else
tmp = y * (x * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y * y) <= 0.4) {
tmp = x;
} else {
tmp = y * (x * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y * y) <= 0.4: tmp = x else: tmp = y * (x * y) return tmp
function code(x, y) tmp = 0.0 if (Float64(y * y) <= 0.4) tmp = x; else tmp = Float64(y * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y * y) <= 0.4) tmp = x; else tmp = y * (x * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(y * y), $MachinePrecision], 0.4], x, N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot y \leq 0.4:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 y y) < 0.40000000000000002Initial program 100.0%
Taylor expanded in y around 0
Simplified99.1%
if 0.40000000000000002 < (*.f64 y y) Initial program 90.1%
Taylor expanded in y around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6488.3%
Simplified88.3%
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6497.9%
Applied egg-rr97.9%
Final simplification98.6%
(FPCore (x y) :precision binary64 (if (<= (* y y) 0.4) x (* x (* y y))))
double code(double x, double y) {
double tmp;
if ((y * y) <= 0.4) {
tmp = x;
} else {
tmp = x * (y * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y * y) <= 0.4d0) then
tmp = x
else
tmp = x * (y * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y * y) <= 0.4) {
tmp = x;
} else {
tmp = x * (y * y);
}
return tmp;
}
def code(x, y): tmp = 0 if (y * y) <= 0.4: tmp = x else: tmp = x * (y * y) return tmp
function code(x, y) tmp = 0.0 if (Float64(y * y) <= 0.4) tmp = x; else tmp = Float64(x * Float64(y * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y * y) <= 0.4) tmp = x; else tmp = x * (y * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(y * y), $MachinePrecision], 0.4], x, N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot y \leq 0.4:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot y\right)\\
\end{array}
\end{array}
if (*.f64 y y) < 0.40000000000000002Initial program 100.0%
Taylor expanded in y around 0
Simplified99.1%
if 0.40000000000000002 < (*.f64 y y) Initial program 90.1%
Taylor expanded in y around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6488.3%
Simplified88.3%
(FPCore (x y) :precision binary64 (if (<= y 1.0) x (* x y)))
double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = x;
} else {
tmp = x * y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.0d0) then
tmp = x
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = x;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.0: tmp = x else: tmp = x * y return tmp
function code(x, y) tmp = 0.0 if (y <= 1.0) tmp = x; else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= 1.0) tmp = x; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, 1.0], x, N[(x * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if y < 1Initial program 97.7%
Taylor expanded in y around 0
Simplified69.6%
if 1 < y Initial program 87.1%
Taylor expanded in y around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6484.4%
Simplified84.4%
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6497.2%
Applied egg-rr97.2%
Applied egg-rr31.8%
(FPCore (x y) :precision binary64 (+ x (* y (* x y))))
double code(double x, double y) {
return x + (y * (x * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + (y * (x * y))
end function
public static double code(double x, double y) {
return x + (y * (x * y));
}
def code(x, y): return x + (y * (x * y))
function code(x, y) return Float64(x + Float64(y * Float64(x * y))) end
function tmp = code(x, y) tmp = x + (y * (x * y)); end
code[x_, y_] := N[(x + N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(x \cdot y\right)
\end{array}
Initial program 95.5%
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6495.5%
Applied egg-rr95.5%
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6499.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 95.5%
Taylor expanded in y around 0
Simplified56.5%
(FPCore (x y) :precision binary64 (+ x (* (* x y) y)))
double code(double x, double y) {
return x + ((x * y) * y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((x * y) * y)
end function
public static double code(double x, double y) {
return x + ((x * y) * y);
}
def code(x, y): return x + ((x * y) * y)
function code(x, y) return Float64(x + Float64(Float64(x * y) * y)) end
function tmp = code(x, y) tmp = x + ((x * y) * y); end
code[x_, y_] := N[(x + N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(x \cdot y\right) \cdot y
\end{array}
herbie shell --seed 2024161
(FPCore (x y)
:name "Numeric.Integration.TanhSinh:everywhere from integration-0.2.1"
:precision binary64
:alt
(! :herbie-platform default (+ x (* (* x y) y)))
(* x (+ 1.0 (* y y))))