
(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 12 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%
Simplified99.5%
Taylor expanded in y around 0 99.4%
fma-def99.4%
*-commutative99.4%
*-commutative99.4%
sub-neg99.4%
associate-*r/99.5%
metadata-eval99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (* (sqrt x) (+ -3.0 (fma 3.0 y (/ 0.3333333333333333 x)))))
double code(double x, double y) {
return sqrt(x) * (-3.0 + fma(3.0, y, (0.3333333333333333 / x)));
}
function code(x, y) return Float64(sqrt(x) * Float64(-3.0 + fma(3.0, y, Float64(0.3333333333333333 / x)))) end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * N[(-3.0 + N[(3.0 * y + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot \left(-3 + \mathsf{fma}\left(3, y, \frac{0.3333333333333333}{x}\right)\right)
\end{array}
Initial program 99.4%
Simplified99.5%
Taylor expanded in y around 0 99.4%
associate-*r*99.4%
sub-neg99.4%
associate-*r/99.5%
metadata-eval99.5%
metadata-eval99.5%
+-commutative99.5%
distribute-rgt-in99.5%
distribute-lft-in99.5%
+-commutative99.5%
distribute-lft-in99.5%
metadata-eval99.5%
associate-*l*99.5%
fma-udef99.5%
metadata-eval99.5%
associate-*r/99.4%
fma-def99.4%
associate-*l*99.4%
distribute-lft-in99.4%
associate-*l*99.4%
Simplified99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (if (<= x 6.6e-6) (sqrt (+ (* 2.0 (+ y -1.0)) (* 0.1111111111111111 (/ 1.0 x)))) (* (sqrt x) (- (* 3.0 y) 3.0))))
double code(double x, double y) {
double tmp;
if (x <= 6.6e-6) {
tmp = sqrt(((2.0 * (y + -1.0)) + (0.1111111111111111 * (1.0 / 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 <= 6.6d-6) then
tmp = sqrt(((2.0d0 * (y + (-1.0d0))) + (0.1111111111111111d0 * (1.0d0 / 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 <= 6.6e-6) {
tmp = Math.sqrt(((2.0 * (y + -1.0)) + (0.1111111111111111 * (1.0 / x))));
} else {
tmp = Math.sqrt(x) * ((3.0 * y) - 3.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 6.6e-6: tmp = math.sqrt(((2.0 * (y + -1.0)) + (0.1111111111111111 * (1.0 / x)))) else: tmp = math.sqrt(x) * ((3.0 * y) - 3.0) return tmp
function code(x, y) tmp = 0.0 if (x <= 6.6e-6) tmp = sqrt(Float64(Float64(2.0 * Float64(y + -1.0)) + Float64(0.1111111111111111 * Float64(1.0 / 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 <= 6.6e-6) tmp = sqrt(((2.0 * (y + -1.0)) + (0.1111111111111111 * (1.0 / x)))); else tmp = sqrt(x) * ((3.0 * y) - 3.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 6.6e-6], N[Sqrt[N[(N[(2.0 * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] + N[(0.1111111111111111 * N[(1.0 / x), $MachinePrecision]), $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 6.6 \cdot 10^{-6}:\\
\;\;\;\;\sqrt{2 \cdot \left(y + -1\right) + 0.1111111111111111 \cdot \frac{1}{x}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \left(3 \cdot y - 3\right)\\
\end{array}
\end{array}
if x < 6.60000000000000034e-6Initial program 99.2%
+-commutative99.2%
associate--l+99.2%
distribute-rgt-in99.2%
remove-double-neg99.2%
distribute-lft-neg-in99.2%
distribute-rgt-neg-in99.2%
mul-1-neg99.2%
metadata-eval99.2%
*-commutative99.2%
associate-/r*99.3%
distribute-neg-frac99.3%
*-commutative99.3%
associate-/r/99.3%
associate-/l/99.3%
associate-/r/99.3%
Simplified99.3%
add-sqr-sqrt88.8%
pow288.8%
Applied egg-rr88.8%
unpow288.8%
sqrt-unprod84.5%
*-commutative84.5%
*-commutative84.5%
swap-sqr43.3%
pow243.3%
swap-sqr43.4%
add-sqr-sqrt43.5%
metadata-eval43.5%
Applied egg-rr43.5%
Taylor expanded in x around 0 79.6%
if 6.60000000000000034e-6 < x Initial program 99.6%
Simplified99.6%
Taylor expanded in x around inf 98.3%
Final simplification89.2%
(FPCore (x y)
:precision binary64
(if (<= x 0.0005)
(* (sqrt x) (/ 0.3333333333333333 x))
(if (or (<= x 2.1e+262) (not (<= x 2.8e+284)))
(* (sqrt x) -3.0)
(* (sqrt x) (* 3.0 y)))))
double code(double x, double y) {
double tmp;
if (x <= 0.0005) {
tmp = sqrt(x) * (0.3333333333333333 / x);
} else if ((x <= 2.1e+262) || !(x <= 2.8e+284)) {
tmp = sqrt(x) * -3.0;
} else {
tmp = sqrt(x) * (3.0 * y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 0.0005d0) then
tmp = sqrt(x) * (0.3333333333333333d0 / x)
else if ((x <= 2.1d+262) .or. (.not. (x <= 2.8d+284))) then
tmp = sqrt(x) * (-3.0d0)
else
tmp = sqrt(x) * (3.0d0 * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 0.0005) {
tmp = Math.sqrt(x) * (0.3333333333333333 / x);
} else if ((x <= 2.1e+262) || !(x <= 2.8e+284)) {
tmp = Math.sqrt(x) * -3.0;
} else {
tmp = Math.sqrt(x) * (3.0 * y);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 0.0005: tmp = math.sqrt(x) * (0.3333333333333333 / x) elif (x <= 2.1e+262) or not (x <= 2.8e+284): tmp = math.sqrt(x) * -3.0 else: tmp = math.sqrt(x) * (3.0 * y) return tmp
function code(x, y) tmp = 0.0 if (x <= 0.0005) tmp = Float64(sqrt(x) * Float64(0.3333333333333333 / x)); elseif ((x <= 2.1e+262) || !(x <= 2.8e+284)) tmp = Float64(sqrt(x) * -3.0); else tmp = Float64(sqrt(x) * Float64(3.0 * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 0.0005) tmp = sqrt(x) * (0.3333333333333333 / x); elseif ((x <= 2.1e+262) || ~((x <= 2.8e+284))) tmp = sqrt(x) * -3.0; else tmp = sqrt(x) * (3.0 * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 0.0005], N[(N[Sqrt[x], $MachinePrecision] * N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 2.1e+262], N[Not[LessEqual[x, 2.8e+284]], $MachinePrecision]], N[(N[Sqrt[x], $MachinePrecision] * -3.0), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * N[(3.0 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0005:\\
\;\;\;\;\sqrt{x} \cdot \frac{0.3333333333333333}{x}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+262} \lor \neg \left(x \leq 2.8 \cdot 10^{+284}\right):\\
\;\;\;\;\sqrt{x} \cdot -3\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \left(3 \cdot y\right)\\
\end{array}
\end{array}
if x < 5.0000000000000001e-4Initial program 99.2%
Simplified99.4%
Taylor expanded in x around 0 77.6%
if 5.0000000000000001e-4 < x < 2.09999999999999989e262 or 2.79999999999999996e284 < x Initial program 99.6%
+-commutative99.6%
associate--l+99.6%
distribute-rgt-in99.7%
remove-double-neg99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
mul-1-neg99.7%
metadata-eval99.7%
*-commutative99.7%
associate-/r*99.7%
distribute-neg-frac99.7%
*-commutative99.7%
associate-/r/99.7%
associate-/l/99.7%
associate-/r/99.7%
Simplified99.6%
Taylor expanded in x around inf 98.1%
Taylor expanded in y around 0 56.5%
*-commutative56.5%
Simplified56.5%
if 2.09999999999999989e262 < x < 2.79999999999999996e284Initial program 98.9%
Simplified99.1%
Taylor expanded in y around inf 67.8%
associate-*r*68.0%
*-commutative68.0%
Simplified68.0%
Final simplification67.5%
(FPCore (x y)
:precision binary64
(if (<= y -265000000.0)
(* 3.0 (* (sqrt x) y))
(if (<= y 3.1e+34)
(* (sqrt x) (+ (/ 0.3333333333333333 x) -3.0))
(* y (sqrt (* x 9.0))))))
double code(double x, double y) {
double tmp;
if (y <= -265000000.0) {
tmp = 3.0 * (sqrt(x) * y);
} else if (y <= 3.1e+34) {
tmp = sqrt(x) * ((0.3333333333333333 / x) + -3.0);
} else {
tmp = y * sqrt((x * 9.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-265000000.0d0)) then
tmp = 3.0d0 * (sqrt(x) * y)
else if (y <= 3.1d+34) then
tmp = sqrt(x) * ((0.3333333333333333d0 / x) + (-3.0d0))
else
tmp = y * sqrt((x * 9.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -265000000.0) {
tmp = 3.0 * (Math.sqrt(x) * y);
} else if (y <= 3.1e+34) {
tmp = Math.sqrt(x) * ((0.3333333333333333 / x) + -3.0);
} else {
tmp = y * Math.sqrt((x * 9.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -265000000.0: tmp = 3.0 * (math.sqrt(x) * y) elif y <= 3.1e+34: tmp = math.sqrt(x) * ((0.3333333333333333 / x) + -3.0) else: tmp = y * math.sqrt((x * 9.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= -265000000.0) tmp = Float64(3.0 * Float64(sqrt(x) * y)); elseif (y <= 3.1e+34) tmp = Float64(sqrt(x) * Float64(Float64(0.3333333333333333 / x) + -3.0)); else tmp = Float64(y * sqrt(Float64(x * 9.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -265000000.0) tmp = 3.0 * (sqrt(x) * y); elseif (y <= 3.1e+34) tmp = sqrt(x) * ((0.3333333333333333 / x) + -3.0); else tmp = y * sqrt((x * 9.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -265000000.0], N[(3.0 * N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.1e+34], N[(N[Sqrt[x], $MachinePrecision] * N[(N[(0.3333333333333333 / x), $MachinePrecision] + -3.0), $MachinePrecision]), $MachinePrecision], N[(y * N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -265000000:\\
\;\;\;\;3 \cdot \left(\sqrt{x} \cdot y\right)\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+34}:\\
\;\;\;\;\sqrt{x} \cdot \left(\frac{0.3333333333333333}{x} + -3\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \sqrt{x \cdot 9}\\
\end{array}
\end{array}
if y < -2.65e8Initial program 99.4%
Simplified99.6%
Taylor expanded in y around inf 72.8%
if -2.65e8 < y < 3.09999999999999977e34Initial program 99.4%
Simplified99.5%
Taylor expanded in y around 0 96.6%
*-commutative96.6%
sub-neg96.6%
associate-*r/96.7%
metadata-eval96.7%
metadata-eval96.7%
Simplified96.7%
if 3.09999999999999977e34 < y Initial program 99.5%
Simplified99.5%
Taylor expanded in y around inf 77.0%
add-sqr-sqrt76.8%
sqrt-unprod40.6%
*-commutative40.6%
*-commutative40.6%
swap-sqr40.5%
metadata-eval40.5%
swap-sqr36.9%
add-sqr-sqrt36.8%
Applied egg-rr36.8%
unpow236.8%
associate-*r*36.9%
*-commutative36.9%
unpow236.9%
Simplified36.9%
sqrt-unprod48.6%
add-sqr-sqrt48.4%
sqrt-prod76.4%
add-sqr-sqrt76.7%
associate-*l*76.7%
pow1/276.7%
sqrt-pow176.8%
metadata-eval76.8%
pow1/276.8%
sqrt-pow176.7%
metadata-eval76.7%
Applied egg-rr76.7%
associate-*r*76.7%
pow-sqr77.1%
metadata-eval77.1%
unpow1/277.1%
Simplified77.1%
Final simplification87.6%
(FPCore (x y) :precision binary64 (* (sqrt x) (+ (* 3.0 y) (+ (/ 0.3333333333333333 x) -3.0))))
double code(double x, double y) {
return sqrt(x) * ((3.0 * y) + ((0.3333333333333333 / x) + -3.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = sqrt(x) * ((3.0d0 * y) + ((0.3333333333333333d0 / x) + (-3.0d0)))
end function
public static double code(double x, double y) {
return Math.sqrt(x) * ((3.0 * y) + ((0.3333333333333333 / x) + -3.0));
}
def code(x, y): return math.sqrt(x) * ((3.0 * y) + ((0.3333333333333333 / x) + -3.0))
function code(x, y) return Float64(sqrt(x) * Float64(Float64(3.0 * y) + Float64(Float64(0.3333333333333333 / x) + -3.0))) end
function tmp = code(x, y) tmp = sqrt(x) * ((3.0 * y) + ((0.3333333333333333 / x) + -3.0)); end
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * N[(N[(3.0 * y), $MachinePrecision] + N[(N[(0.3333333333333333 / x), $MachinePrecision] + -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x} \cdot \left(3 \cdot y + \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%
fma-udef99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (* (+ y (+ (/ 0.1111111111111111 x) -1.0)) (sqrt (* x 9.0))))
double code(double x, double y) {
return (y + ((0.1111111111111111 / x) + -1.0)) * sqrt((x * 9.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y + ((0.1111111111111111d0 / x) + (-1.0d0))) * sqrt((x * 9.0d0))
end function
public static double code(double x, double y) {
return (y + ((0.1111111111111111 / x) + -1.0)) * Math.sqrt((x * 9.0));
}
def code(x, y): return (y + ((0.1111111111111111 / x) + -1.0)) * math.sqrt((x * 9.0))
function code(x, y) return Float64(Float64(y + Float64(Float64(0.1111111111111111 / x) + -1.0)) * sqrt(Float64(x * 9.0))) end
function tmp = code(x, y) tmp = (y + ((0.1111111111111111 / x) + -1.0)) * sqrt((x * 9.0)); end
code[x_, y_] := N[(N[(y + N[(N[(0.1111111111111111 / x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(x * 9.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \left(\frac{0.1111111111111111}{x} + -1\right)\right) \cdot \sqrt{x \cdot 9}
\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.4%
add-sqr-sqrt56.5%
pow256.5%
Applied egg-rr56.5%
unpow256.5%
sqrt-unprod49.1%
*-commutative49.1%
*-commutative49.1%
swap-sqr29.0%
pow229.0%
swap-sqr29.0%
add-sqr-sqrt29.0%
metadata-eval29.0%
Applied egg-rr29.0%
sqrt-prod31.6%
unpow231.6%
sqrt-prod56.5%
add-sqr-sqrt99.5%
add-sqr-sqrt99.0%
associate-*r*99.1%
pow1/299.1%
sqrt-pow199.2%
metadata-eval99.2%
pow1/299.2%
sqrt-pow199.1%
metadata-eval99.1%
Applied egg-rr99.1%
associate-*l*99.0%
pow-sqr99.5%
metadata-eval99.5%
unpow1/299.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y) :precision binary64 (if (or (<= y -1050.0) (not (<= y 1.0))) (* 3.0 (* (sqrt x) y)) (* (sqrt x) -3.0)))
double code(double x, double y) {
double tmp;
if ((y <= -1050.0) || !(y <= 1.0)) {
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 <= (-1050.0d0)) .or. (.not. (y <= 1.0d0))) 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 <= -1050.0) || !(y <= 1.0)) {
tmp = 3.0 * (Math.sqrt(x) * y);
} else {
tmp = Math.sqrt(x) * -3.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1050.0) or not (y <= 1.0): 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 <= -1050.0) || !(y <= 1.0)) 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 <= -1050.0) || ~((y <= 1.0))) tmp = 3.0 * (sqrt(x) * y); else tmp = sqrt(x) * -3.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1050.0], N[Not[LessEqual[y, 1.0]], $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 -1050 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;3 \cdot \left(\sqrt{x} \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot -3\\
\end{array}
\end{array}
if y < -1050 or 1 < y Initial program 99.4%
Simplified99.5%
Taylor expanded in y around inf 73.0%
if -1050 < y < 1Initial 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.4%
Taylor expanded in x around inf 49.7%
Taylor expanded in y around 0 48.8%
*-commutative48.8%
Simplified48.8%
Final simplification59.5%
(FPCore (x y) :precision binary64 (if (<= y -1050.0) (* 3.0 (* (sqrt x) y)) (if (<= y 1.0) (* (sqrt x) -3.0) (* (sqrt x) (* 3.0 y)))))
double code(double x, double y) {
double tmp;
if (y <= -1050.0) {
tmp = 3.0 * (sqrt(x) * y);
} else if (y <= 1.0) {
tmp = sqrt(x) * -3.0;
} else {
tmp = sqrt(x) * (3.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 <= (-1050.0d0)) then
tmp = 3.0d0 * (sqrt(x) * y)
else if (y <= 1.0d0) then
tmp = sqrt(x) * (-3.0d0)
else
tmp = sqrt(x) * (3.0d0 * y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1050.0) {
tmp = 3.0 * (Math.sqrt(x) * y);
} else if (y <= 1.0) {
tmp = Math.sqrt(x) * -3.0;
} else {
tmp = Math.sqrt(x) * (3.0 * y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1050.0: tmp = 3.0 * (math.sqrt(x) * y) elif y <= 1.0: tmp = math.sqrt(x) * -3.0 else: tmp = math.sqrt(x) * (3.0 * y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1050.0) tmp = Float64(3.0 * Float64(sqrt(x) * y)); elseif (y <= 1.0) tmp = Float64(sqrt(x) * -3.0); else tmp = Float64(sqrt(x) * Float64(3.0 * y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1050.0) tmp = 3.0 * (sqrt(x) * y); elseif (y <= 1.0) tmp = sqrt(x) * -3.0; else tmp = sqrt(x) * (3.0 * y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1050.0], N[(3.0 * N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(N[Sqrt[x], $MachinePrecision] * -3.0), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * N[(3.0 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1050:\\
\;\;\;\;3 \cdot \left(\sqrt{x} \cdot y\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\sqrt{x} \cdot -3\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \left(3 \cdot y\right)\\
\end{array}
\end{array}
if y < -1050Initial program 99.4%
Simplified99.6%
Taylor expanded in y around inf 72.8%
if -1050 < y < 1Initial 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.4%
Taylor expanded in x around inf 49.7%
Taylor expanded in y around 0 48.8%
*-commutative48.8%
Simplified48.8%
if 1 < y Initial program 99.4%
Simplified99.5%
Taylor expanded in y around inf 73.1%
associate-*r*73.2%
*-commutative73.2%
Simplified73.2%
Final simplification59.5%
(FPCore (x y) :precision binary64 (if (<= x 5.5e-5) (* (sqrt x) (+ (/ 0.3333333333333333 x) -3.0)) (* (sqrt x) (- (* 3.0 y) 3.0))))
double code(double x, double y) {
double tmp;
if (x <= 5.5e-5) {
tmp = sqrt(x) * ((0.3333333333333333 / x) + -3.0);
} 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.5d-5) then
tmp = sqrt(x) * ((0.3333333333333333d0 / x) + (-3.0d0))
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.5e-5) {
tmp = Math.sqrt(x) * ((0.3333333333333333 / x) + -3.0);
} else {
tmp = Math.sqrt(x) * ((3.0 * y) - 3.0);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 5.5e-5: tmp = math.sqrt(x) * ((0.3333333333333333 / x) + -3.0) else: tmp = math.sqrt(x) * ((3.0 * y) - 3.0) return tmp
function code(x, y) tmp = 0.0 if (x <= 5.5e-5) tmp = Float64(sqrt(x) * Float64(Float64(0.3333333333333333 / x) + -3.0)); 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.5e-5) tmp = sqrt(x) * ((0.3333333333333333 / x) + -3.0); else tmp = sqrt(x) * ((3.0 * y) - 3.0); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 5.5e-5], N[(N[Sqrt[x], $MachinePrecision] * N[(N[(0.3333333333333333 / x), $MachinePrecision] + -3.0), $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.5 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{x} \cdot \left(\frac{0.3333333333333333}{x} + -3\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \left(3 \cdot y - 3\right)\\
\end{array}
\end{array}
if x < 5.5000000000000002e-5Initial program 99.2%
Simplified99.4%
Taylor expanded in y around 0 79.1%
*-commutative79.1%
sub-neg79.1%
associate-*r/79.3%
metadata-eval79.3%
metadata-eval79.3%
Simplified79.3%
if 5.5000000000000002e-5 < x Initial program 99.6%
Simplified99.6%
Taylor expanded in x around inf 98.3%
Final simplification89.0%
(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%
+-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.4%
Taylor expanded in x around inf 60.6%
Taylor expanded in y around 0 28.4%
*-commutative28.4%
Simplified28.4%
expm1-log1p-u0.9%
expm1-udef1.2%
add-sqr-sqrt0.0%
sqrt-unprod2.5%
swap-sqr2.5%
add-sqr-sqrt2.5%
metadata-eval2.5%
Applied egg-rr2.5%
expm1-def3.3%
expm1-log1p3.3%
Simplified3.3%
Final simplification3.3%
(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-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.4%
Taylor expanded in x around inf 60.6%
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 2023200
(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)))