
(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 10 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 (* (sqrt (* x 9.0)) (+ (+ y (/ 1.0 (* x 9.0))) -1.0)))
double code(double x, double y) {
return sqrt((x * 9.0)) * ((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 = sqrt((x * 9.0d0)) * ((y + (1.0d0 / (x * 9.0d0))) + (-1.0d0))
end function
public static double code(double x, double y) {
return Math.sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0);
}
def code(x, y): return math.sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0)
function code(x, y) return Float64(sqrt(Float64(x * 9.0)) * Float64(Float64(y + Float64(1.0 / Float64(x * 9.0))) + -1.0)) end
function tmp = code(x, y) tmp = sqrt((x * 9.0)) * ((y + (1.0 / (x * 9.0))) + -1.0); end
code[x_, y_] := N[(N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision] * N[(N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x \cdot 9} \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) + -1\right)
\end{array}
Initial program 99.4%
expm1-log1p-u96.5%
expm1-udef53.3%
*-commutative53.3%
metadata-eval53.3%
sqrt-prod53.3%
Applied egg-rr53.3%
expm1-def96.6%
expm1-log1p99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (sqrt (* x 9.0))))
(if (<= x 1.75e-16)
(* t_0 (+ (/ 0.1111111111111111 x) -1.0))
(* t_0 (- y 1.0)))))
double code(double x, double y) {
double t_0 = sqrt((x * 9.0));
double tmp;
if (x <= 1.75e-16) {
tmp = t_0 * ((0.1111111111111111 / x) + -1.0);
} else {
tmp = t_0 * (y - 1.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 = sqrt((x * 9.0d0))
if (x <= 1.75d-16) then
tmp = t_0 * ((0.1111111111111111d0 / x) + (-1.0d0))
else
tmp = t_0 * (y - 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt((x * 9.0));
double tmp;
if (x <= 1.75e-16) {
tmp = t_0 * ((0.1111111111111111 / x) + -1.0);
} else {
tmp = t_0 * (y - 1.0);
}
return tmp;
}
def code(x, y): t_0 = math.sqrt((x * 9.0)) tmp = 0 if x <= 1.75e-16: tmp = t_0 * ((0.1111111111111111 / x) + -1.0) else: tmp = t_0 * (y - 1.0) return tmp
function code(x, y) t_0 = sqrt(Float64(x * 9.0)) tmp = 0.0 if (x <= 1.75e-16) tmp = Float64(t_0 * Float64(Float64(0.1111111111111111 / x) + -1.0)); else tmp = Float64(t_0 * Float64(y - 1.0)); end return tmp end
function tmp_2 = code(x, y) t_0 = sqrt((x * 9.0)); tmp = 0.0; if (x <= 1.75e-16) tmp = t_0 * ((0.1111111111111111 / x) + -1.0); else tmp = t_0 * (y - 1.0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.75e-16], N[(t$95$0 * N[(N[(0.1111111111111111 / x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x \cdot 9}\\
\mathbf{if}\;x \leq 1.75 \cdot 10^{-16}:\\
\;\;\;\;t_0 \cdot \left(\frac{0.1111111111111111}{x} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(y - 1\right)\\
\end{array}
\end{array}
if x < 1.75000000000000009e-16Initial program 99.3%
+-commutative99.3%
associate--l+99.3%
distribute-rgt-in99.3%
remove-double-neg99.3%
distribute-lft-neg-in99.3%
distribute-rgt-neg-in99.3%
mul-1-neg99.3%
metadata-eval99.3%
*-commutative99.3%
associate-/r*99.3%
distribute-neg-frac99.3%
*-commutative99.3%
associate-/r/99.3%
associate-/l/99.3%
associate-/r/99.3%
Simplified99.3%
expm1-log1p-u99.3%
expm1-udef6.2%
*-commutative6.2%
metadata-eval6.2%
sqrt-prod6.2%
Applied egg-rr6.2%
expm1-def99.4%
expm1-log1p99.4%
Simplified99.4%
Taylor expanded in y around 0 81.3%
sub-neg81.3%
associate-*r/81.3%
metadata-eval81.3%
metadata-eval81.3%
Simplified81.3%
if 1.75000000000000009e-16 < 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%
expm1-log1p-u94.2%
expm1-udef93.6%
*-commutative93.6%
metadata-eval93.6%
sqrt-prod93.6%
Applied egg-rr93.6%
expm1-def94.2%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in x around inf 97.1%
Final simplification89.9%
(FPCore (x y) :precision binary64 (* (sqrt (* x 9.0)) (+ (/ 0.1111111111111111 x) (- y 1.0))))
double code(double x, double y) {
return sqrt((x * 9.0)) * ((0.1111111111111111 / x) + (y - 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt((x * 9.0d0)) * ((0.1111111111111111d0 / x) + (y - 1.0d0))
end function
public static double code(double x, double y) {
return Math.sqrt((x * 9.0)) * ((0.1111111111111111 / x) + (y - 1.0));
}
def code(x, y): return math.sqrt((x * 9.0)) * ((0.1111111111111111 / x) + (y - 1.0))
function code(x, y) return Float64(sqrt(Float64(x * 9.0)) * Float64(Float64(0.1111111111111111 / x) + Float64(y - 1.0))) end
function tmp = code(x, y) tmp = sqrt((x * 9.0)) * ((0.1111111111111111 / x) + (y - 1.0)); end
code[x_, y_] := N[(N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision] * N[(N[(0.1111111111111111 / x), $MachinePrecision] + N[(y - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x \cdot 9} \cdot \left(\frac{0.1111111111111111}{x} + \left(y - 1\right)\right)
\end{array}
Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-rgt-in99.4%
remove-double-neg99.4%
distribute-lft-neg-in99.4%
distribute-rgt-neg-in99.4%
mul-1-neg99.4%
metadata-eval99.4%
*-commutative99.4%
associate-/r*99.4%
distribute-neg-frac99.4%
*-commutative99.4%
associate-/r/99.4%
associate-/l/99.4%
associate-/r/99.4%
Simplified99.5%
expm1-log1p-u96.5%
expm1-udef53.3%
*-commutative53.3%
metadata-eval53.3%
sqrt-prod53.3%
Applied egg-rr53.3%
expm1-def96.6%
expm1-log1p99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (or (<= y -1750.0) (not (<= y 7e-5))) (* 3.0 (* y (sqrt x))) (* (sqrt x) -3.0)))
double code(double x, double y) {
double tmp;
if ((y <= -1750.0) || !(y <= 7e-5)) {
tmp = 3.0 * (y * sqrt(x));
} 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 <= (-1750.0d0)) .or. (.not. (y <= 7d-5))) then
tmp = 3.0d0 * (y * sqrt(x))
else
tmp = sqrt(x) * (-3.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1750.0) || !(y <= 7e-5)) {
tmp = 3.0 * (y * Math.sqrt(x));
} else {
tmp = Math.sqrt(x) * -3.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1750.0) or not (y <= 7e-5): tmp = 3.0 * (y * math.sqrt(x)) else: tmp = math.sqrt(x) * -3.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -1750.0) || !(y <= 7e-5)) tmp = Float64(3.0 * Float64(y * sqrt(x))); else tmp = Float64(sqrt(x) * -3.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1750.0) || ~((y <= 7e-5))) tmp = 3.0 * (y * sqrt(x)); else tmp = sqrt(x) * -3.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1750.0], N[Not[LessEqual[y, 7e-5]], $MachinePrecision]], N[(3.0 * N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1750 \lor \neg \left(y \leq 7 \cdot 10^{-5}\right):\\
\;\;\;\;3 \cdot \left(y \cdot \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot -3\\
\end{array}
\end{array}
if y < -1750 or 6.9999999999999994e-5 < y Initial program 99.5%
+-commutative99.5%
associate--l+99.5%
distribute-lft-in99.5%
+-commutative99.5%
*-commutative99.5%
associate-*r*99.5%
cancel-sign-sub99.5%
*-commutative99.5%
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.4%
Simplified99.5%
Taylor expanded in y around inf 68.7%
if -1750 < y < 6.9999999999999994e-5Initial program 99.4%
associate--l+99.4%
associate-/r*99.5%
Simplified99.5%
Taylor expanded in x around inf 53.1%
Taylor expanded in y around 0 52.7%
*-commutative52.7%
Simplified52.7%
Final simplification60.5%
(FPCore (x y) :precision binary64 (if (<= y -1750.0) (* 3.0 (* y (sqrt x))) (if (<= y 7e-5) (* (sqrt x) -3.0) (* (sqrt (* x 9.0)) y))))
double code(double x, double y) {
double tmp;
if (y <= -1750.0) {
tmp = 3.0 * (y * sqrt(x));
} else if (y <= 7e-5) {
tmp = sqrt(x) * -3.0;
} else {
tmp = sqrt((x * 9.0)) * y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1750.0d0)) then
tmp = 3.0d0 * (y * sqrt(x))
else if (y <= 7d-5) then
tmp = sqrt(x) * (-3.0d0)
else
tmp = sqrt((x * 9.0d0)) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1750.0) {
tmp = 3.0 * (y * Math.sqrt(x));
} else if (y <= 7e-5) {
tmp = Math.sqrt(x) * -3.0;
} else {
tmp = Math.sqrt((x * 9.0)) * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1750.0: tmp = 3.0 * (y * math.sqrt(x)) elif y <= 7e-5: tmp = math.sqrt(x) * -3.0 else: tmp = math.sqrt((x * 9.0)) * y return tmp
function code(x, y) tmp = 0.0 if (y <= -1750.0) tmp = Float64(3.0 * Float64(y * sqrt(x))); elseif (y <= 7e-5) tmp = Float64(sqrt(x) * -3.0); else tmp = Float64(sqrt(Float64(x * 9.0)) * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1750.0) tmp = 3.0 * (y * sqrt(x)); elseif (y <= 7e-5) tmp = sqrt(x) * -3.0; else tmp = sqrt((x * 9.0)) * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1750.0], N[(3.0 * N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e-5], N[(N[Sqrt[x], $MachinePrecision] * -3.0), $MachinePrecision], N[(N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1750:\\
\;\;\;\;3 \cdot \left(y \cdot \sqrt{x}\right)\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{x} \cdot -3\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x \cdot 9} \cdot y\\
\end{array}
\end{array}
if y < -1750Initial 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.6%
*-commutative99.6%
distribute-rgt-out--99.5%
distribute-lft-neg-in99.5%
cancel-sign-sub99.5%
+-commutative99.5%
*-commutative99.5%
distribute-rgt-in99.5%
Simplified99.6%
Taylor expanded in y around inf 68.5%
if -1750 < y < 6.9999999999999994e-5Initial program 99.4%
associate--l+99.4%
associate-/r*99.5%
Simplified99.5%
Taylor expanded in x around inf 53.1%
Taylor expanded in y around 0 52.7%
*-commutative52.7%
Simplified52.7%
if 6.9999999999999994e-5 < y Initial program 99.4%
+-commutative99.4%
associate--l+99.4%
distribute-rgt-in99.4%
remove-double-neg99.4%
distribute-lft-neg-in99.4%
distribute-rgt-neg-in99.4%
mul-1-neg99.4%
metadata-eval99.4%
*-commutative99.4%
associate-/r*99.4%
distribute-neg-frac99.4%
*-commutative99.4%
associate-/r/99.4%
associate-/l/99.4%
associate-/r/99.4%
Simplified99.5%
expm1-log1p-u97.2%
expm1-udef44.6%
*-commutative44.6%
metadata-eval44.6%
sqrt-prod44.6%
Applied egg-rr44.6%
expm1-def97.2%
expm1-log1p99.5%
Simplified99.6%
Taylor expanded in y around inf 68.9%
Final simplification60.5%
(FPCore (x y) :precision binary64 (if (<= x 2.35e-16) (* (sqrt x) (+ (/ 0.3333333333333333 x) -3.0)) (* 3.0 (* (- y 1.0) (sqrt x)))))
double code(double x, double y) {
double tmp;
if (x <= 2.35e-16) {
tmp = sqrt(x) * ((0.3333333333333333 / x) + -3.0);
} else {
tmp = 3.0 * ((y - 1.0) * sqrt(x));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2.35d-16) then
tmp = sqrt(x) * ((0.3333333333333333d0 / x) + (-3.0d0))
else
tmp = 3.0d0 * ((y - 1.0d0) * sqrt(x))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2.35e-16) {
tmp = Math.sqrt(x) * ((0.3333333333333333 / x) + -3.0);
} else {
tmp = 3.0 * ((y - 1.0) * Math.sqrt(x));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.35e-16: tmp = math.sqrt(x) * ((0.3333333333333333 / x) + -3.0) else: tmp = 3.0 * ((y - 1.0) * math.sqrt(x)) return tmp
function code(x, y) tmp = 0.0 if (x <= 2.35e-16) tmp = Float64(sqrt(x) * Float64(Float64(0.3333333333333333 / x) + -3.0)); else tmp = Float64(3.0 * Float64(Float64(y - 1.0) * sqrt(x))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.35e-16) tmp = sqrt(x) * ((0.3333333333333333 / x) + -3.0); else tmp = 3.0 * ((y - 1.0) * sqrt(x)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 2.35e-16], N[(N[Sqrt[x], $MachinePrecision] * N[(N[(0.3333333333333333 / x), $MachinePrecision] + -3.0), $MachinePrecision]), $MachinePrecision], N[(3.0 * N[(N[(y - 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.35 \cdot 10^{-16}:\\
\;\;\;\;\sqrt{x} \cdot \left(\frac{0.3333333333333333}{x} + -3\right)\\
\mathbf{else}:\\
\;\;\;\;3 \cdot \left(\left(y - 1\right) \cdot \sqrt{x}\right)\\
\end{array}
\end{array}
if x < 2.35000000000000022e-16Initial 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.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.3%
Taylor expanded in y around 0 81.2%
*-commutative81.2%
sub-neg81.2%
associate-*r/81.2%
metadata-eval81.2%
metadata-eval81.2%
Simplified81.2%
if 2.35000000000000022e-16 < x Initial program 99.6%
associate--l+99.6%
associate-/r*99.6%
Simplified99.6%
Taylor expanded in x around inf 97.0%
Taylor expanded in y around 0 97.1%
*-commutative97.1%
associate-*l*97.0%
*-commutative97.0%
metadata-eval97.0%
associate-*r*97.0%
distribute-rgt-in97.0%
associate-*l*97.1%
Simplified97.1%
Final simplification89.8%
(FPCore (x y) :precision binary64 (if (<= x 1.26e-15) (* (sqrt x) (+ (/ 0.3333333333333333 x) -3.0)) (* (sqrt (* x 9.0)) (- y 1.0))))
double code(double x, double y) {
double tmp;
if (x <= 1.26e-15) {
tmp = sqrt(x) * ((0.3333333333333333 / x) + -3.0);
} else {
tmp = sqrt((x * 9.0)) * (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 <= 1.26d-15) then
tmp = sqrt(x) * ((0.3333333333333333d0 / x) + (-3.0d0))
else
tmp = sqrt((x * 9.0d0)) * (y - 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.26e-15) {
tmp = Math.sqrt(x) * ((0.3333333333333333 / x) + -3.0);
} else {
tmp = Math.sqrt((x * 9.0)) * (y - 1.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.26e-15: tmp = math.sqrt(x) * ((0.3333333333333333 / x) + -3.0) else: tmp = math.sqrt((x * 9.0)) * (y - 1.0) return tmp
function code(x, y) tmp = 0.0 if (x <= 1.26e-15) tmp = Float64(sqrt(x) * Float64(Float64(0.3333333333333333 / x) + -3.0)); else tmp = Float64(sqrt(Float64(x * 9.0)) * Float64(y - 1.0)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.26e-15) tmp = sqrt(x) * ((0.3333333333333333 / x) + -3.0); else tmp = sqrt((x * 9.0)) * (y - 1.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.26e-15], N[(N[Sqrt[x], $MachinePrecision] * N[(N[(0.3333333333333333 / x), $MachinePrecision] + -3.0), $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision] * N[(y - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.26 \cdot 10^{-15}:\\
\;\;\;\;\sqrt{x} \cdot \left(\frac{0.3333333333333333}{x} + -3\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x \cdot 9} \cdot \left(y - 1\right)\\
\end{array}
\end{array}
if x < 1.26e-15Initial 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.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.3%
Taylor expanded in y around 0 81.2%
*-commutative81.2%
sub-neg81.2%
associate-*r/81.2%
metadata-eval81.2%
metadata-eval81.2%
Simplified81.2%
if 1.26e-15 < 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%
expm1-log1p-u94.2%
expm1-udef93.6%
*-commutative93.6%
metadata-eval93.6%
sqrt-prod93.6%
Applied egg-rr93.6%
expm1-def94.2%
expm1-log1p99.7%
Simplified99.7%
Taylor expanded in x around inf 97.1%
Final simplification89.8%
(FPCore (x y) :precision binary64 (* 3.0 (* (- y 1.0) (sqrt x))))
double code(double x, double y) {
return 3.0 * ((y - 1.0) * sqrt(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 3.0d0 * ((y - 1.0d0) * sqrt(x))
end function
public static double code(double x, double y) {
return 3.0 * ((y - 1.0) * Math.sqrt(x));
}
def code(x, y): return 3.0 * ((y - 1.0) * math.sqrt(x))
function code(x, y) return Float64(3.0 * Float64(Float64(y - 1.0) * sqrt(x))) end
function tmp = code(x, y) tmp = 3.0 * ((y - 1.0) * sqrt(x)); end
code[x_, y_] := N[(3.0 * N[(N[(y - 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(\left(y - 1\right) \cdot \sqrt{x}\right)
\end{array}
Initial program 99.4%
associate--l+99.4%
associate-/r*99.5%
Simplified99.5%
Taylor expanded in x around inf 61.0%
Taylor expanded in y around 0 61.1%
*-commutative61.1%
associate-*l*61.0%
*-commutative61.0%
metadata-eval61.0%
associate-*r*61.0%
distribute-rgt-in61.0%
associate-*l*61.1%
Simplified61.1%
Final simplification61.1%
(FPCore (x y) :precision binary64 (sqrt (* x 9.0)))
double code(double x, double y) {
return sqrt((x * 9.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt((x * 9.0d0))
end function
public static double code(double x, double y) {
return Math.sqrt((x * 9.0));
}
def code(x, y): return math.sqrt((x * 9.0))
function code(x, y) return sqrt(Float64(x * 9.0)) end
function tmp = code(x, y) tmp = sqrt((x * 9.0)); end
code[x_, y_] := N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x \cdot 9}
\end{array}
Initial program 99.4%
associate--l+99.4%
associate-/r*99.5%
Simplified99.5%
Taylor expanded in x around inf 61.0%
Taylor expanded in y around 0 28.4%
*-commutative28.4%
Simplified28.4%
add-sqr-sqrt0.0%
sqrt-unprod3.2%
pow23.2%
Applied egg-rr3.2%
unpow23.2%
swap-sqr3.2%
rem-square-sqrt3.2%
metadata-eval3.2%
*-commutative3.2%
Simplified3.2%
Final simplification3.2%
(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%
associate--l+99.4%
associate-/r*99.5%
Simplified99.5%
Taylor expanded in x around inf 61.0%
Taylor expanded in y around 0 28.4%
*-commutative28.4%
Simplified28.4%
Final simplification28.4%
(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 2023257
(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)))