
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x / (x + 1.0d0)) - ((x + 1.0d0) / (x - 1.0d0))
end function
public static double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
def code(x): return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
function code(x) return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) end
function tmp = code(x) tmp = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0)); end
code[x_] := N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))
double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x / (x + 1.0d0)) - ((x + 1.0d0) / (x - 1.0d0))
end function
public static double code(double x) {
return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0));
}
def code(x): return (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0))
function code(x) return Float64(Float64(x / Float64(x + 1.0)) - Float64(Float64(x + 1.0) / Float64(x - 1.0))) end
function tmp = code(x) tmp = (x / (x + 1.0)) - ((x + 1.0) / (x - 1.0)); end
code[x_] := N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 1.0), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{x + 1} - \frac{x + 1}{x - 1}
\end{array}
(FPCore (x)
:precision binary64
(if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0002)
(+
(/ -3.0 (pow x 3.0))
(- (- (/ -1.0 (pow x 4.0)) (/ 1.0 (pow x 2.0))) (/ 3.0 x)))
(/ (- (* (+ x 1.0) (+ x 1.0)) (* x (+ x -1.0))) (* (+ x 1.0) (- 1.0 x)))))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002) {
tmp = (-3.0 / pow(x, 3.0)) + (((-1.0 / pow(x, 4.0)) - (1.0 / pow(x, 2.0))) - (3.0 / x));
} else {
tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0002d0) then
tmp = ((-3.0d0) / (x ** 3.0d0)) + ((((-1.0d0) / (x ** 4.0d0)) - (1.0d0 / (x ** 2.0d0))) - (3.0d0 / x))
else
tmp = (((x + 1.0d0) * (x + 1.0d0)) - (x * (x + (-1.0d0)))) / ((x + 1.0d0) * (1.0d0 - x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002) {
tmp = (-3.0 / Math.pow(x, 3.0)) + (((-1.0 / Math.pow(x, 4.0)) - (1.0 / Math.pow(x, 2.0))) - (3.0 / x));
} else {
tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x));
}
return tmp;
}
def code(x): tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002: tmp = (-3.0 / math.pow(x, 3.0)) + (((-1.0 / math.pow(x, 4.0)) - (1.0 / math.pow(x, 2.0))) - (3.0 / x)) else: tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x)) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0002) tmp = Float64(Float64(-3.0 / (x ^ 3.0)) + Float64(Float64(Float64(-1.0 / (x ^ 4.0)) - Float64(1.0 / (x ^ 2.0))) - Float64(3.0 / x))); else tmp = Float64(Float64(Float64(Float64(x + 1.0) * Float64(x + 1.0)) - Float64(x * Float64(x + -1.0))) / Float64(Float64(x + 1.0) * Float64(1.0 - x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002) tmp = (-3.0 / (x ^ 3.0)) + (((-1.0 / (x ^ 4.0)) - (1.0 / (x ^ 2.0))) - (3.0 / x)); else tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0002], N[(N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-1.0 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(3.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0.0002:\\
\;\;\;\;\frac{-3}{{x}^{3}} + \left(\left(\frac{-1}{{x}^{4}} - \frac{1}{{x}^{2}}\right) - \frac{3}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x + 1\right) \cdot \left(x + 1\right) - x \cdot \left(x + -1\right)}{\left(x + 1\right) \cdot \left(1 - x\right)}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 2.0000000000000001e-4Initial program 9.2%
Taylor expanded in x around inf 99.5%
distribute-neg-in99.5%
unsub-neg99.5%
associate-*r/99.5%
metadata-eval99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
if 2.0000000000000001e-4 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
frac-2neg99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
frac-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0002) (+ (/ -3.0 (pow x 3.0)) (- (/ -3.0 x) (pow x -2.0))) (/ (- (* (+ x 1.0) (+ x 1.0)) (* x (+ x -1.0))) (* (+ x 1.0) (- 1.0 x)))))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002) {
tmp = (-3.0 / pow(x, 3.0)) + ((-3.0 / x) - pow(x, -2.0));
} else {
tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0002d0) then
tmp = ((-3.0d0) / (x ** 3.0d0)) + (((-3.0d0) / x) - (x ** (-2.0d0)))
else
tmp = (((x + 1.0d0) * (x + 1.0d0)) - (x * (x + (-1.0d0)))) / ((x + 1.0d0) * (1.0d0 - x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002) {
tmp = (-3.0 / Math.pow(x, 3.0)) + ((-3.0 / x) - Math.pow(x, -2.0));
} else {
tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x));
}
return tmp;
}
def code(x): tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002: tmp = (-3.0 / math.pow(x, 3.0)) + ((-3.0 / x) - math.pow(x, -2.0)) else: tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x)) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0002) tmp = Float64(Float64(-3.0 / (x ^ 3.0)) + Float64(Float64(-3.0 / x) - (x ^ -2.0))); else tmp = Float64(Float64(Float64(Float64(x + 1.0) * Float64(x + 1.0)) - Float64(x * Float64(x + -1.0))) / Float64(Float64(x + 1.0) * Float64(1.0 - x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002) tmp = (-3.0 / (x ^ 3.0)) + ((-3.0 / x) - (x ^ -2.0)); else tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0002], N[(N[(-3.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-3.0 / x), $MachinePrecision] - N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0.0002:\\
\;\;\;\;\frac{-3}{{x}^{3}} + \left(\frac{-3}{x} - {x}^{-2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x + 1\right) \cdot \left(x + 1\right) - x \cdot \left(x + -1\right)}{\left(x + 1\right) \cdot \left(1 - x\right)}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 2.0000000000000001e-4Initial program 9.2%
Taylor expanded in x around inf 99.4%
+-commutative99.4%
distribute-neg-in99.4%
distribute-neg-in99.4%
associate-*r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
Simplified99.9%
*-un-lft-identity99.9%
fma-def99.9%
div-inv99.9%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
fma-udef99.9%
*-lft-identity99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
if 2.0000000000000001e-4 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
frac-2neg99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
frac-sub100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (<= (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))) 0.0002) (+ (/ -3.0 x) (- (* -3.0 (pow x -3.0)) (pow x -2.0))) (/ (- (* (+ x 1.0) (+ x 1.0)) (* x (+ x -1.0))) (* (+ x 1.0) (- 1.0 x)))))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002) {
tmp = (-3.0 / x) + ((-3.0 * pow(x, -3.0)) - pow(x, -2.0));
} else {
tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))) <= 0.0002d0) then
tmp = ((-3.0d0) / x) + (((-3.0d0) * (x ** (-3.0d0))) - (x ** (-2.0d0)))
else
tmp = (((x + 1.0d0) * (x + 1.0d0)) - (x * (x + (-1.0d0)))) / ((x + 1.0d0) * (1.0d0 - x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002) {
tmp = (-3.0 / x) + ((-3.0 * Math.pow(x, -3.0)) - Math.pow(x, -2.0));
} else {
tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x));
}
return tmp;
}
def code(x): tmp = 0 if ((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002: tmp = (-3.0 / x) + ((-3.0 * math.pow(x, -3.0)) - math.pow(x, -2.0)) else: tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x)) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) <= 0.0002) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(-3.0 * (x ^ -3.0)) - (x ^ -2.0))); else tmp = Float64(Float64(Float64(Float64(x + 1.0) * Float64(x + 1.0)) - Float64(x * Float64(x + -1.0))) / Float64(Float64(x + 1.0) * Float64(1.0 - x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0))) <= 0.0002) tmp = (-3.0 / x) + ((-3.0 * (x ^ -3.0)) - (x ^ -2.0)); else tmp = (((x + 1.0) * (x + 1.0)) - (x * (x + -1.0))) / ((x + 1.0) * (1.0 - x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0002], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(-3.0 * N[Power[x, -3.0], $MachinePrecision]), $MachinePrecision] - N[Power[x, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} + \frac{-1 - x}{x + -1} \leq 0.0002:\\
\;\;\;\;\frac{-3}{x} + \left(-3 \cdot {x}^{-3} - {x}^{-2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x + 1\right) \cdot \left(x + 1\right) - x \cdot \left(x + -1\right)}{\left(x + 1\right) \cdot \left(1 - x\right)}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 2.0000000000000001e-4Initial program 9.2%
Taylor expanded in x around inf 99.4%
+-commutative99.4%
distribute-neg-in99.4%
distribute-neg-in99.4%
associate-*r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
distribute-neg-frac99.9%
metadata-eval99.9%
Simplified99.9%
*-un-lft-identity99.9%
fma-def99.9%
div-inv99.9%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
fma-udef99.9%
*-lft-identity99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
metadata-eval99.9%
pow-flip99.9%
associate-+l-99.9%
pow-flip99.9%
metadata-eval99.9%
div-inv99.9%
pow-flip99.9%
metadata-eval99.9%
Applied egg-rr99.9%
if 2.0000000000000001e-4 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 100.0%
clear-num100.0%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
frac-2neg99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
frac-sub100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (/ x (+ x 1.0)) (/ (- -1.0 x) (+ x -1.0))))) (if (<= t_0 1e-7) (+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x))) t_0)))
double code(double x) {
double t_0 = (x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 1e-7) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x / (x + 1.0d0)) + (((-1.0d0) - x) / (x + (-1.0d0)))
if (t_0 <= 1d-7) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0));
double tmp;
if (t_0 <= 1e-7) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0)) tmp = 0 if t_0 <= 1e-7: tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) else: tmp = t_0 return tmp
function code(x) t_0 = Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(-1.0 - x) / Float64(x + -1.0))) tmp = 0.0 if (t_0 <= 1e-7) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = (x / (x + 1.0)) + ((-1.0 - x) / (x + -1.0)); tmp = 0.0; if (t_0 <= 1e-7) tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 - x), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-7], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1} + \frac{-1 - x}{x + -1}\\
\mathbf{if}\;t_0 \leq 10^{-7}:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) < 9.9999999999999995e-8Initial program 8.6%
clear-num8.5%
associate-/r/8.5%
sub-neg8.5%
metadata-eval8.5%
Applied egg-rr8.5%
distribute-rgt-in8.4%
un-div-inv8.5%
*-un-lft-identity8.5%
Applied egg-rr8.5%
Taylor expanded in x around inf 99.3%
associate-*r/99.8%
metadata-eval99.8%
distribute-neg-in99.8%
unsub-neg99.8%
distribute-neg-frac99.8%
metadata-eval99.8%
Simplified99.8%
inv-pow99.8%
unpow299.8%
pow-prod-down99.8%
inv-pow99.8%
inv-pow99.8%
Applied egg-rr99.8%
if 9.9999999999999995e-8 < (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (+.f64 x 1) (-.f64 x 1))) Initial program 99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x))) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
else
tmp = 1.0d0 + (x * (x + 3.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) else: tmp = 1.0 + (x * (x + 3.0)) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); else tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); else tmp = 1.0 + (x * (x + 3.0)); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 9.2%
clear-num9.1%
associate-/r/9.1%
sub-neg9.1%
metadata-eval9.1%
Applied egg-rr9.1%
distribute-rgt-in9.0%
un-div-inv9.1%
*-un-lft-identity9.1%
Applied egg-rr9.1%
Taylor expanded in x around inf 99.0%
associate-*r/99.5%
metadata-eval99.5%
distribute-neg-in99.5%
unsub-neg99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
inv-pow99.5%
unpow299.5%
pow-prod-down99.5%
inv-pow99.5%
inv-pow99.5%
Applied egg-rr99.5%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 98.4%
unpow298.4%
distribute-rgt-out98.4%
Simplified98.4%
Final simplification98.9%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -3.0 x) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (-3.0d0) / x
else
tmp = 1.0d0 + (x * (x + 3.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -3.0 / x else: tmp = 1.0 + (x * (x + 3.0)) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-3.0 / x); else tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = -3.0 / x; else tmp = 1.0 + (x * (x + 3.0)); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(-3.0 / x), $MachinePrecision], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 9.2%
Taylor expanded in x around inf 97.6%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 98.4%
unpow298.4%
distribute-rgt-out98.4%
Simplified98.4%
Final simplification98.0%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ 1.0 (+ (* x -0.3333333333333333) 0.1111111111111111)) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 1.0 / ((x * -0.3333333333333333) + 0.1111111111111111);
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = 1.0d0 / ((x * (-0.3333333333333333d0)) + 0.1111111111111111d0)
else
tmp = 1.0d0 + (x * (x + 3.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = 1.0 / ((x * -0.3333333333333333) + 0.1111111111111111);
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = 1.0 / ((x * -0.3333333333333333) + 0.1111111111111111) else: tmp = 1.0 + (x * (x + 3.0)) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(1.0 / Float64(Float64(x * -0.3333333333333333) + 0.1111111111111111)); else tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = 1.0 / ((x * -0.3333333333333333) + 0.1111111111111111); else tmp = 1.0 + (x * (x + 3.0)); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(1.0 / N[(N[(x * -0.3333333333333333), $MachinePrecision] + 0.1111111111111111), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{1}{x \cdot -0.3333333333333333 + 0.1111111111111111}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 9.2%
clear-num9.2%
clear-num9.1%
frac-sub9.3%
*-un-lft-identity9.3%
sub-neg9.3%
metadata-eval9.3%
sub-neg9.3%
metadata-eval9.3%
Applied egg-rr9.3%
Taylor expanded in x around 0 9.3%
clear-num9.3%
inv-pow9.3%
*-rgt-identity9.3%
Applied egg-rr9.3%
unpow-19.3%
sub-neg9.3%
distribute-neg-frac9.3%
metadata-eval9.3%
+-commutative9.3%
+-commutative9.3%
Simplified9.3%
Taylor expanded in x around inf 98.9%
+-commutative98.9%
*-commutative98.9%
Simplified98.9%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 98.4%
unpow298.4%
distribute-rgt-out98.4%
Simplified98.4%
Final simplification98.7%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -3.0 x) (+ 1.0 (* x 3.0))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * 3.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (-3.0d0) / x
else
tmp = 1.0d0 + (x * 3.0d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * 3.0);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -3.0 / x else: tmp = 1.0 + (x * 3.0) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-3.0 / x); else tmp = Float64(1.0 + Float64(x * 3.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = -3.0 / x; else tmp = 1.0 + (x * 3.0); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(-3.0 / x), $MachinePrecision], N[(1.0 + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot 3\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 9.2%
Taylor expanded in x around inf 97.6%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 97.4%
Final simplification97.5%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -3.0 x) 1.0))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 1.0d0))) then
tmp = (-3.0d0) / x
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -3.0 / x else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = Float64(-3.0 / x); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = -3.0 / x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[(-3.0 / x), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 9.2%
Taylor expanded in x around inf 97.6%
if -1 < x < 1Initial program 100.0%
Taylor expanded in x around 0 95.5%
Final simplification96.5%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 55.3%
Taylor expanded in x around 0 50.4%
Final simplification50.4%
herbie shell --seed 2023332
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))