
(FPCore (x y) :precision binary64 (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))
double code(double x, double y) {
return (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (3.0d0 * sqrt(x)) * ((y + (1.0d0 / (x * 9.0d0))) - 1.0d0)
end function
public static double code(double x, double y) {
return (3.0 * Math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
def code(x, y): return (3.0 * math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0)
function code(x, y) return Float64(Float64(3.0 * sqrt(x)) * Float64(Float64(y + Float64(1.0 / Float64(x * 9.0))) - 1.0)) end
function tmp = code(x, y) tmp = (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0); end
code[x_, y_] := N[(N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))
double code(double x, double y) {
return (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (3.0d0 * sqrt(x)) * ((y + (1.0d0 / (x * 9.0d0))) - 1.0d0)
end function
public static double code(double x, double y) {
return (3.0 * Math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
def code(x, y): return (3.0 * math.sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0)
function code(x, y) return Float64(Float64(3.0 * sqrt(x)) * Float64(Float64(y + Float64(1.0 / Float64(x * 9.0))) - 1.0)) end
function tmp = code(x, y) tmp = (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0); end
code[x_, y_] := N[(N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\end{array}
(FPCore (x y) :precision binary64 (fma 3.0 (* (sqrt x) y) (* (sqrt x) (+ (/ 0.3333333333333333 x) -3.0))))
double code(double x, double y) {
return fma(3.0, (sqrt(x) * y), (sqrt(x) * ((0.3333333333333333 / x) + -3.0)));
}
function code(x, y) return fma(3.0, Float64(sqrt(x) * y), Float64(sqrt(x) * Float64(Float64(0.3333333333333333 / x) + -3.0))) end
code[x_, y_] := N[(3.0 * N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision] + N[(N[Sqrt[x], $MachinePrecision] * N[(N[(0.3333333333333333 / x), $MachinePrecision] + -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(3, \sqrt{x} \cdot y, \sqrt{x} \cdot \left(\frac{0.3333333333333333}{x} + -3\right)\right)
\end{array}
Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-lft-in99.4%
+-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-in99.4%
Simplified99.5%
Taylor expanded in y around 0 99.4%
fma-def99.5%
*-commutative99.5%
*-commutative99.5%
sub-neg99.5%
associate-*r/99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (* (sqrt x) (- (fma 3.0 y -3.0) (/ -0.3333333333333333 x))))
double code(double x, double y) {
return sqrt(x) * (fma(3.0, y, -3.0) - (-0.3333333333333333 / x));
}
function code(x, y) return Float64(sqrt(x) * Float64(fma(3.0, y, -3.0) - Float64(-0.3333333333333333 / x))) end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * N[(N[(3.0 * y + -3.0), $MachinePrecision] - N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot \left(\mathsf{fma}\left(3, y, -3\right) - \frac{-0.3333333333333333}{x}\right)
\end{array}
Initial program 99.4%
Simplified99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (* (sqrt x) (fma 3.0 y (+ (/ 0.3333333333333333 x) -3.0))))
double code(double x, double y) {
return sqrt(x) * fma(3.0, y, ((0.3333333333333333 / x) + -3.0));
}
function code(x, y) return Float64(sqrt(x) * fma(3.0, y, Float64(Float64(0.3333333333333333 / x) + -3.0))) end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * N[(3.0 * y + N[(N[(0.3333333333333333 / x), $MachinePrecision] + -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot \mathsf{fma}\left(3, y, \frac{0.3333333333333333}{x} + -3\right)
\end{array}
Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-lft-in99.4%
+-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-in99.4%
Simplified99.5%
Final simplification99.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* y (sqrt (* x 9.0)))))
(if (<= y -80000000.0)
t_0
(if (<= y 8.8e-149)
(* (sqrt x) -3.0)
(if (<= y 2.25e+52) (* (sqrt x) (/ 0.3333333333333333 x)) t_0)))))
double code(double x, double y) {
double t_0 = y * sqrt((x * 9.0));
double tmp;
if (y <= -80000000.0) {
tmp = t_0;
} else if (y <= 8.8e-149) {
tmp = sqrt(x) * -3.0;
} else if (y <= 2.25e+52) {
tmp = sqrt(x) * (0.3333333333333333 / x);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = y * sqrt((x * 9.0d0))
if (y <= (-80000000.0d0)) then
tmp = t_0
else if (y <= 8.8d-149) then
tmp = sqrt(x) * (-3.0d0)
else if (y <= 2.25d+52) then
tmp = sqrt(x) * (0.3333333333333333d0 / x)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * Math.sqrt((x * 9.0));
double tmp;
if (y <= -80000000.0) {
tmp = t_0;
} else if (y <= 8.8e-149) {
tmp = Math.sqrt(x) * -3.0;
} else if (y <= 2.25e+52) {
tmp = Math.sqrt(x) * (0.3333333333333333 / x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y * math.sqrt((x * 9.0)) tmp = 0 if y <= -80000000.0: tmp = t_0 elif y <= 8.8e-149: tmp = math.sqrt(x) * -3.0 elif y <= 2.25e+52: tmp = math.sqrt(x) * (0.3333333333333333 / x) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y * sqrt(Float64(x * 9.0))) tmp = 0.0 if (y <= -80000000.0) tmp = t_0; elseif (y <= 8.8e-149) tmp = Float64(sqrt(x) * -3.0); elseif (y <= 2.25e+52) tmp = Float64(sqrt(x) * Float64(0.3333333333333333 / x)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y * sqrt((x * 9.0)); tmp = 0.0; if (y <= -80000000.0) tmp = t_0; elseif (y <= 8.8e-149) tmp = sqrt(x) * -3.0; elseif (y <= 2.25e+52) tmp = sqrt(x) * (0.3333333333333333 / x); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -80000000.0], t$95$0, If[LessEqual[y, 8.8e-149], N[(N[Sqrt[x], $MachinePrecision] * -3.0), $MachinePrecision], If[LessEqual[y, 2.25e+52], N[(N[Sqrt[x], $MachinePrecision] * N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \sqrt{x \cdot 9}\\
\mathbf{if}\;y \leq -80000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{-149}:\\
\;\;\;\;\sqrt{x} \cdot -3\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+52}:\\
\;\;\;\;\sqrt{x} \cdot \frac{0.3333333333333333}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -8e7 or 2.25e52 < y Initial program 99.5%
+-commutative99.5%
associate--l+99.5%
distribute-rgt-in99.5%
remove-double-neg99.5%
distribute-lft-neg-in99.5%
distribute-rgt-neg-in99.5%
mul-1-neg99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/r*99.5%
distribute-neg-frac99.5%
*-commutative99.5%
associate-/r/99.5%
associate-/l/99.5%
associate-/r/99.5%
Simplified99.5%
add-sqr-sqrt59.6%
pow259.6%
Applied egg-rr59.6%
unpow259.6%
add-sqr-sqrt99.5%
distribute-lft-in99.5%
add-sqr-sqrt99.2%
sqrt-unprod99.5%
*-commutative99.5%
*-commutative99.5%
swap-sqr99.4%
add-sqr-sqrt99.6%
metadata-eval99.6%
Applied egg-rr98.8%
distribute-lft-out99.6%
*-commutative99.6%
+-commutative99.6%
associate-+l+99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in y around inf 75.8%
if -8e7 < y < 8.7999999999999993e-149Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-lft-in99.4%
+-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.5%
*-commutative99.5%
distribute-rgt-out--99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-in99.4%
Simplified99.5%
Taylor expanded in x around inf 59.9%
Taylor expanded in y around 0 59.5%
*-commutative59.5%
Simplified59.5%
if 8.7999999999999993e-149 < y < 2.25e52Initial program 99.3%
+-commutative99.3%
associate--l+99.3%
distribute-lft-in99.3%
+-commutative99.3%
*-commutative99.3%
associate-*r*99.2%
cancel-sign-sub99.2%
*-commutative99.2%
associate-*r*99.3%
*-commutative99.3%
distribute-rgt-out--99.2%
distribute-lft-neg-in99.2%
cancel-sign-sub99.2%
+-commutative99.2%
*-commutative99.2%
distribute-rgt-in99.2%
Simplified99.5%
Taylor expanded in x around 0 65.7%
Final simplification68.2%
(FPCore (x y) :precision binary64 (if (or (<= y -3.9e+24) (not (<= y 3.35e+52))) (* y (sqrt (* x 9.0))) (* (sqrt x) (- -3.0 (/ -0.3333333333333333 x)))))
double code(double x, double y) {
double tmp;
if ((y <= -3.9e+24) || !(y <= 3.35e+52)) {
tmp = y * sqrt((x * 9.0));
} else {
tmp = sqrt(x) * (-3.0 - (-0.3333333333333333 / x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-3.9d+24)) .or. (.not. (y <= 3.35d+52))) then
tmp = y * sqrt((x * 9.0d0))
else
tmp = sqrt(x) * ((-3.0d0) - ((-0.3333333333333333d0) / x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -3.9e+24) || !(y <= 3.35e+52)) {
tmp = y * Math.sqrt((x * 9.0));
} else {
tmp = Math.sqrt(x) * (-3.0 - (-0.3333333333333333 / x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3.9e+24) or not (y <= 3.35e+52): tmp = y * math.sqrt((x * 9.0)) else: tmp = math.sqrt(x) * (-3.0 - (-0.3333333333333333 / x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -3.9e+24) || !(y <= 3.35e+52)) tmp = Float64(y * sqrt(Float64(x * 9.0))); else tmp = Float64(sqrt(x) * Float64(-3.0 - Float64(-0.3333333333333333 / x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -3.9e+24) || ~((y <= 3.35e+52))) tmp = y * sqrt((x * 9.0)); else tmp = sqrt(x) * (-3.0 - (-0.3333333333333333 / x)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -3.9e+24], N[Not[LessEqual[y, 3.35e+52]], $MachinePrecision]], N[(y * N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * N[(-3.0 - N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{+24} \lor \neg \left(y \leq 3.35 \cdot 10^{+52}\right):\\
\;\;\;\;y \cdot \sqrt{x \cdot 9}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \left(-3 - \frac{-0.3333333333333333}{x}\right)\\
\end{array}
\end{array}
if y < -3.8999999999999998e24 or 3.34999999999999998e52 < y Initial program 99.5%
+-commutative99.5%
associate--l+99.5%
distribute-rgt-in99.5%
remove-double-neg99.5%
distribute-lft-neg-in99.5%
distribute-rgt-neg-in99.5%
mul-1-neg99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/r*99.5%
distribute-neg-frac99.5%
*-commutative99.5%
associate-/r/99.5%
associate-/l/99.5%
associate-/r/99.5%
Simplified99.5%
add-sqr-sqrt60.5%
pow260.5%
Applied egg-rr60.5%
unpow260.5%
add-sqr-sqrt99.5%
distribute-lft-in99.5%
add-sqr-sqrt99.2%
sqrt-unprod99.5%
*-commutative99.5%
*-commutative99.5%
swap-sqr99.4%
add-sqr-sqrt99.6%
metadata-eval99.6%
Applied egg-rr98.8%
distribute-lft-out99.6%
*-commutative99.6%
+-commutative99.6%
associate-+l+99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in y around inf 77.2%
if -3.8999999999999998e24 < y < 3.34999999999999998e52Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-lft-in99.4%
+-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-in99.3%
Simplified99.5%
Taylor expanded in y around 0 91.6%
*-commutative91.6%
sub-neg91.6%
associate-*r/91.6%
metadata-eval91.6%
metadata-eval91.6%
+-commutative91.6%
metadata-eval91.6%
distribute-neg-frac91.6%
unsub-neg91.6%
Simplified91.6%
Final simplification85.0%
(FPCore (x y) :precision binary64 (* (sqrt x) (+ (+ (/ 0.3333333333333333 x) -3.0) (* 3.0 y))))
double code(double x, double y) {
return sqrt(x) * (((0.3333333333333333 / x) + -3.0) + (3.0 * y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(x) * (((0.3333333333333333d0 / x) + (-3.0d0)) + (3.0d0 * y))
end function
public static double code(double x, double y) {
return Math.sqrt(x) * (((0.3333333333333333 / x) + -3.0) + (3.0 * y));
}
def code(x, y): return math.sqrt(x) * (((0.3333333333333333 / x) + -3.0) + (3.0 * y))
function code(x, y) return Float64(sqrt(x) * Float64(Float64(Float64(0.3333333333333333 / x) + -3.0) + Float64(3.0 * y))) end
function tmp = code(x, y) tmp = sqrt(x) * (((0.3333333333333333 / x) + -3.0) + (3.0 * y)); end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + -3.0), $MachinePrecision] + N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot \left(\left(\frac{0.3333333333333333}{x} + -3\right) + 3 \cdot y\right)
\end{array}
Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-lft-in99.4%
+-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-in99.4%
Simplified99.5%
fma-udef99.4%
+-commutative99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x y) :precision binary64 (if (or (<= y -80000000.0) (not (<= y 9.5e-18))) (* 3.0 (* (sqrt x) y)) (* (sqrt x) -3.0)))
double code(double x, double y) {
double tmp;
if ((y <= -80000000.0) || !(y <= 9.5e-18)) {
tmp = 3.0 * (sqrt(x) * y);
} else {
tmp = sqrt(x) * -3.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-80000000.0d0)) .or. (.not. (y <= 9.5d-18))) then
tmp = 3.0d0 * (sqrt(x) * y)
else
tmp = sqrt(x) * (-3.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -80000000.0) || !(y <= 9.5e-18)) {
tmp = 3.0 * (Math.sqrt(x) * y);
} else {
tmp = Math.sqrt(x) * -3.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -80000000.0) or not (y <= 9.5e-18): tmp = 3.0 * (math.sqrt(x) * y) else: tmp = math.sqrt(x) * -3.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -80000000.0) || !(y <= 9.5e-18)) tmp = Float64(3.0 * Float64(sqrt(x) * y)); else tmp = Float64(sqrt(x) * -3.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -80000000.0) || ~((y <= 9.5e-18))) tmp = 3.0 * (sqrt(x) * y); else tmp = sqrt(x) * -3.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -80000000.0], N[Not[LessEqual[y, 9.5e-18]], $MachinePrecision]], N[(3.0 * N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -80000000 \lor \neg \left(y \leq 9.5 \cdot 10^{-18}\right):\\
\;\;\;\;3 \cdot \left(\sqrt{x} \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot -3\\
\end{array}
\end{array}
if y < -8e7 or 9.5000000000000003e-18 < y Initial program 99.5%
+-commutative99.5%
associate--l+99.5%
distribute-lft-in99.5%
+-commutative99.5%
*-commutative99.5%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-in99.4%
Simplified99.5%
Taylor expanded in y around inf 70.2%
if -8e7 < y < 9.5000000000000003e-18Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-lft-in99.4%
+-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-in99.4%
Simplified99.5%
Taylor expanded in x around inf 54.6%
Taylor expanded in y around 0 54.2%
*-commutative54.2%
Simplified54.2%
Final simplification63.0%
(FPCore (x y) :precision binary64 (if (<= y -80000000.0) (* y (sqrt (* x 9.0))) (if (<= y 9.5e-18) (* (sqrt x) -3.0) (* 3.0 (* (sqrt x) y)))))
double code(double x, double y) {
double tmp;
if (y <= -80000000.0) {
tmp = y * sqrt((x * 9.0));
} else if (y <= 9.5e-18) {
tmp = sqrt(x) * -3.0;
} else {
tmp = 3.0 * (sqrt(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 <= (-80000000.0d0)) then
tmp = y * sqrt((x * 9.0d0))
else if (y <= 9.5d-18) then
tmp = sqrt(x) * (-3.0d0)
else
tmp = 3.0d0 * (sqrt(x) * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -80000000.0) {
tmp = y * Math.sqrt((x * 9.0));
} else if (y <= 9.5e-18) {
tmp = Math.sqrt(x) * -3.0;
} else {
tmp = 3.0 * (Math.sqrt(x) * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -80000000.0: tmp = y * math.sqrt((x * 9.0)) elif y <= 9.5e-18: tmp = math.sqrt(x) * -3.0 else: tmp = 3.0 * (math.sqrt(x) * y) return tmp
function code(x, y) tmp = 0.0 if (y <= -80000000.0) tmp = Float64(y * sqrt(Float64(x * 9.0))); elseif (y <= 9.5e-18) tmp = Float64(sqrt(x) * -3.0); else tmp = Float64(3.0 * Float64(sqrt(x) * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -80000000.0) tmp = y * sqrt((x * 9.0)); elseif (y <= 9.5e-18) tmp = sqrt(x) * -3.0; else tmp = 3.0 * (sqrt(x) * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -80000000.0], N[(y * N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.5e-18], N[(N[Sqrt[x], $MachinePrecision] * -3.0), $MachinePrecision], N[(3.0 * N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -80000000:\\
\;\;\;\;y \cdot \sqrt{x \cdot 9}\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{-18}:\\
\;\;\;\;\sqrt{x} \cdot -3\\
\mathbf{else}:\\
\;\;\;\;3 \cdot \left(\sqrt{x} \cdot y\right)\\
\end{array}
\end{array}
if y < -8e7Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-rgt-in99.5%
remove-double-neg99.5%
distribute-lft-neg-in99.5%
distribute-rgt-neg-in99.5%
mul-1-neg99.5%
metadata-eval99.5%
*-commutative99.5%
associate-/r*99.4%
distribute-neg-frac99.4%
*-commutative99.4%
associate-/r/99.5%
associate-/l/99.5%
associate-/r/99.4%
Simplified99.4%
add-sqr-sqrt23.2%
pow223.2%
Applied egg-rr23.2%
unpow223.2%
add-sqr-sqrt99.4%
distribute-lft-in99.4%
add-sqr-sqrt99.2%
sqrt-unprod99.4%
*-commutative99.4%
*-commutative99.4%
swap-sqr99.3%
add-sqr-sqrt99.5%
metadata-eval99.5%
Applied egg-rr99.5%
distribute-lft-out99.5%
*-commutative99.5%
+-commutative99.5%
associate-+l+99.5%
+-commutative99.5%
Simplified99.5%
Taylor expanded in y around inf 74.1%
if -8e7 < y < 9.5000000000000003e-18Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-lft-in99.4%
+-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-in99.4%
Simplified99.5%
Taylor expanded in x around inf 54.6%
Taylor expanded in y around 0 54.2%
*-commutative54.2%
Simplified54.2%
if 9.5000000000000003e-18 < y Initial program 99.5%
+-commutative99.5%
associate--l+99.5%
distribute-lft-in99.5%
+-commutative99.5%
*-commutative99.5%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-out--99.5%
distribute-lft-neg-in99.5%
cancel-sign-sub99.5%
+-commutative99.5%
*-commutative99.5%
distribute-rgt-in99.5%
Simplified99.5%
Taylor expanded in y around inf 67.1%
Final simplification63.0%
(FPCore (x y) :precision binary64 (if (<= x 5.7e-8) (* (sqrt x) (- -3.0 (/ -0.3333333333333333 x))) (* (sqrt x) (- (* 3.0 y) 3.0))))
double code(double x, double y) {
double tmp;
if (x <= 5.7e-8) {
tmp = sqrt(x) * (-3.0 - (-0.3333333333333333 / x));
} else {
tmp = sqrt(x) * ((3.0 * y) - 3.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 5.7d-8) then
tmp = sqrt(x) * ((-3.0d0) - ((-0.3333333333333333d0) / x))
else
tmp = sqrt(x) * ((3.0d0 * y) - 3.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 5.7e-8) {
tmp = Math.sqrt(x) * (-3.0 - (-0.3333333333333333 / x));
} else {
tmp = Math.sqrt(x) * ((3.0 * y) - 3.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.7e-8: tmp = math.sqrt(x) * (-3.0 - (-0.3333333333333333 / x)) else: tmp = math.sqrt(x) * ((3.0 * y) - 3.0) return tmp
function code(x, y) tmp = 0.0 if (x <= 5.7e-8) tmp = Float64(sqrt(x) * Float64(-3.0 - Float64(-0.3333333333333333 / x))); else tmp = Float64(sqrt(x) * Float64(Float64(3.0 * y) - 3.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 5.7e-8) tmp = sqrt(x) * (-3.0 - (-0.3333333333333333 / x)); else tmp = sqrt(x) * ((3.0 * y) - 3.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.7e-8], N[(N[Sqrt[x], $MachinePrecision] * N[(-3.0 - N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * N[(N[(3.0 * y), $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.7 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{x} \cdot \left(-3 - \frac{-0.3333333333333333}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \left(3 \cdot y - 3\right)\\
\end{array}
\end{array}
if x < 5.70000000000000009e-8Initial program 99.3%
+-commutative99.3%
associate--l+99.3%
distribute-lft-in99.3%
+-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
cancel-sign-sub99.3%
*-commutative99.3%
associate-*r*99.2%
*-commutative99.2%
distribute-rgt-out--99.2%
distribute-lft-neg-in99.2%
cancel-sign-sub99.2%
+-commutative99.2%
*-commutative99.2%
distribute-rgt-in99.2%
Simplified99.4%
Taylor expanded in y around 0 73.2%
*-commutative73.2%
sub-neg73.2%
associate-*r/73.3%
metadata-eval73.3%
metadata-eval73.3%
+-commutative73.3%
metadata-eval73.3%
distribute-neg-frac73.3%
unsub-neg73.3%
Simplified73.3%
if 5.70000000000000009e-8 < x Initial program 99.6%
+-commutative99.6%
associate--l+99.6%
distribute-lft-in99.6%
+-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
cancel-sign-sub99.6%
*-commutative99.6%
associate-*r*99.5%
*-commutative99.5%
distribute-rgt-out--99.5%
distribute-lft-neg-in99.5%
cancel-sign-sub99.5%
+-commutative99.5%
*-commutative99.5%
distribute-rgt-in99.5%
Simplified99.5%
Taylor expanded in x around inf 98.6%
Final simplification86.5%
(FPCore (x y) :precision binary64 (if (<= x 1e-5) (* (sqrt x) (- -3.0 (/ -0.3333333333333333 x))) (* (* 3.0 (sqrt x)) (+ y -1.0))))
double code(double x, double y) {
double tmp;
if (x <= 1e-5) {
tmp = sqrt(x) * (-3.0 - (-0.3333333333333333 / x));
} else {
tmp = (3.0 * sqrt(x)) * (y + -1.0);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1d-5) then
tmp = sqrt(x) * ((-3.0d0) - ((-0.3333333333333333d0) / x))
else
tmp = (3.0d0 * sqrt(x)) * (y + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1e-5) {
tmp = Math.sqrt(x) * (-3.0 - (-0.3333333333333333 / x));
} else {
tmp = (3.0 * Math.sqrt(x)) * (y + -1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1e-5: tmp = math.sqrt(x) * (-3.0 - (-0.3333333333333333 / x)) else: tmp = (3.0 * math.sqrt(x)) * (y + -1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= 1e-5) tmp = Float64(sqrt(x) * Float64(-3.0 - Float64(-0.3333333333333333 / x))); else tmp = Float64(Float64(3.0 * sqrt(x)) * Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1e-5) tmp = sqrt(x) * (-3.0 - (-0.3333333333333333 / x)); else tmp = (3.0 * sqrt(x)) * (y + -1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1e-5], N[(N[Sqrt[x], $MachinePrecision] * N[(-3.0 - N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-5}:\\
\;\;\;\;\sqrt{x} \cdot \left(-3 - \frac{-0.3333333333333333}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3 \cdot \sqrt{x}\right) \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if x < 1.00000000000000008e-5Initial program 99.3%
+-commutative99.3%
associate--l+99.3%
distribute-lft-in99.3%
+-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
cancel-sign-sub99.3%
*-commutative99.3%
associate-*r*99.2%
*-commutative99.2%
distribute-rgt-out--99.2%
distribute-lft-neg-in99.2%
cancel-sign-sub99.2%
+-commutative99.2%
*-commutative99.2%
distribute-rgt-in99.2%
Simplified99.4%
Taylor expanded in y around 0 73.2%
*-commutative73.2%
sub-neg73.2%
associate-*r/73.3%
metadata-eval73.3%
metadata-eval73.3%
+-commutative73.3%
metadata-eval73.3%
distribute-neg-frac73.3%
unsub-neg73.3%
Simplified73.3%
if 1.00000000000000008e-5 < x Initial program 99.6%
+-commutative99.6%
associate--l+99.6%
distribute-rgt-in99.6%
remove-double-neg99.6%
distribute-lft-neg-in99.6%
distribute-rgt-neg-in99.6%
mul-1-neg99.6%
metadata-eval99.6%
*-commutative99.6%
associate-/r*99.6%
distribute-neg-frac99.6%
*-commutative99.6%
associate-/r/99.6%
associate-/l/99.6%
associate-/r/99.6%
Simplified99.6%
Taylor expanded in x around inf 98.6%
Final simplification86.6%
(FPCore (x y) :precision binary64 (* (sqrt x) -3.0))
double code(double x, double y) {
return sqrt(x) * -3.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(x) * (-3.0d0)
end function
public static double code(double x, double y) {
return Math.sqrt(x) * -3.0;
}
def code(x, y): return math.sqrt(x) * -3.0
function code(x, y) return Float64(sqrt(x) * -3.0) end
function tmp = code(x, y) tmp = sqrt(x) * -3.0; end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * -3.0), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot -3
\end{array}
Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-lft-in99.4%
+-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
cancel-sign-sub99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
distribute-lft-neg-in99.4%
cancel-sign-sub99.4%
+-commutative99.4%
*-commutative99.4%
distribute-rgt-in99.4%
Simplified99.5%
Taylor expanded in x around inf 64.1%
Taylor expanded in y around 0 26.0%
*-commutative26.0%
Simplified26.0%
Final simplification26.0%
(FPCore (x y) :precision binary64 (* 3.0 (+ (* y (sqrt x)) (* (- (/ 1.0 (* x 9.0)) 1.0) (sqrt x)))))
double code(double x, double y) {
return 3.0 * ((y * sqrt(x)) + (((1.0 / (x * 9.0)) - 1.0) * sqrt(x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 3.0d0 * ((y * sqrt(x)) + (((1.0d0 / (x * 9.0d0)) - 1.0d0) * sqrt(x)))
end function
public static double code(double x, double y) {
return 3.0 * ((y * Math.sqrt(x)) + (((1.0 / (x * 9.0)) - 1.0) * Math.sqrt(x)));
}
def code(x, y): return 3.0 * ((y * math.sqrt(x)) + (((1.0 / (x * 9.0)) - 1.0) * math.sqrt(x)))
function code(x, y) return Float64(3.0 * Float64(Float64(y * sqrt(x)) + Float64(Float64(Float64(1.0 / Float64(x * 9.0)) - 1.0) * sqrt(x)))) end
function tmp = code(x, y) tmp = 3.0 * ((y * sqrt(x)) + (((1.0 / (x * 9.0)) - 1.0) * sqrt(x))); end
code[x_, y_] := N[(3.0 * N[(N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(y \cdot \sqrt{x} + \left(\frac{1}{x \cdot 9} - 1\right) \cdot \sqrt{x}\right)
\end{array}
herbie shell --seed 2023230
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(* 3.0 (+ (* y (sqrt x)) (* (- (/ 1.0 (* x 9.0)) 1.0) (sqrt x))))
(* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))