
(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 11 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)) (/ (+ x 1.0) (- 1.0 x))) 0.0004) (/ (+ 3.0 (/ (- (/ (+ 2.0 (/ -2.0 x)) x) 2.0) x)) (- 1.0 x)) (/ (- (- -1.0 x) (* x (/ (+ x -1.0) (- -1.0 x)))) (+ x -1.0))))
double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((x + 1.0) / (1.0 - x))) <= 0.0004) {
tmp = (3.0 + ((((2.0 + (-2.0 / x)) / x) - 2.0) / x)) / (1.0 - x);
} else {
tmp = ((-1.0 - x) - (x * ((x + -1.0) / (-1.0 - x)))) / (x + -1.0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((x / (x + 1.0d0)) + ((x + 1.0d0) / (1.0d0 - x))) <= 0.0004d0) then
tmp = (3.0d0 + ((((2.0d0 + ((-2.0d0) / x)) / x) - 2.0d0) / x)) / (1.0d0 - x)
else
tmp = (((-1.0d0) - x) - (x * ((x + (-1.0d0)) / ((-1.0d0) - x)))) / (x + (-1.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((x / (x + 1.0)) + ((x + 1.0) / (1.0 - x))) <= 0.0004) {
tmp = (3.0 + ((((2.0 + (-2.0 / x)) / x) - 2.0) / x)) / (1.0 - x);
} else {
tmp = ((-1.0 - x) - (x * ((x + -1.0) / (-1.0 - x)))) / (x + -1.0);
}
return tmp;
}
def code(x): tmp = 0 if ((x / (x + 1.0)) + ((x + 1.0) / (1.0 - x))) <= 0.0004: tmp = (3.0 + ((((2.0 + (-2.0 / x)) / x) - 2.0) / x)) / (1.0 - x) else: tmp = ((-1.0 - x) - (x * ((x + -1.0) / (-1.0 - x)))) / (x + -1.0) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(x + 1.0) / Float64(1.0 - x))) <= 0.0004) tmp = Float64(Float64(3.0 + Float64(Float64(Float64(Float64(2.0 + Float64(-2.0 / x)) / x) - 2.0) / x)) / Float64(1.0 - x)); else tmp = Float64(Float64(Float64(-1.0 - x) - Float64(x * Float64(Float64(x + -1.0) / Float64(-1.0 - x)))) / Float64(x + -1.0)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((x / (x + 1.0)) + ((x + 1.0) / (1.0 - x))) <= 0.0004) tmp = (3.0 + ((((2.0 + (-2.0 / x)) / x) - 2.0) / x)) / (1.0 - x); else tmp = ((-1.0 - x) - (x * ((x + -1.0) / (-1.0 - x)))) / (x + -1.0); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x + 1.0), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0004], N[(N[(3.0 + N[(N[(N[(N[(2.0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-1.0 - x), $MachinePrecision] - N[(x * N[(N[(x + -1.0), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{x + 1} + \frac{x + 1}{1 - x} \leq 0.0004:\\
\;\;\;\;\frac{3 + \frac{\frac{2 + \frac{-2}{x}}{x} - 2}{x}}{1 - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-1 - x\right) - x \cdot \frac{x + -1}{-1 - x}}{x + -1}\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 4.00000000000000019e-4Initial program 8.9%
remove-double-neg8.9%
distribute-neg-frac8.9%
distribute-neg-in8.9%
sub-neg8.9%
distribute-frac-neg28.9%
sub-neg8.9%
+-commutative8.9%
unsub-neg8.9%
metadata-eval8.9%
neg-sub08.9%
associate-+l-8.9%
neg-sub08.9%
+-commutative8.9%
unsub-neg8.9%
Simplified8.9%
frac-2neg8.9%
clear-num9.0%
frac-sub9.8%
+-commutative9.8%
distribute-neg-in9.8%
metadata-eval9.8%
sub-neg9.8%
*-commutative9.8%
*-un-lft-identity9.8%
+-commutative9.8%
distribute-neg-in9.8%
metadata-eval9.8%
sub-neg9.8%
Applied egg-rr9.8%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if 4.00000000000000019e-4 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
remove-double-neg99.9%
distribute-neg-frac99.9%
distribute-neg-in99.9%
sub-neg99.9%
distribute-frac-neg299.9%
sub-neg99.9%
+-commutative99.9%
unsub-neg99.9%
metadata-eval99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
Simplified99.9%
frac-2neg99.9%
clear-num99.9%
frac-sub99.9%
+-commutative99.9%
distribute-neg-in99.9%
metadata-eval99.9%
sub-neg99.9%
*-commutative99.9%
*-un-lft-identity99.9%
+-commutative99.9%
distribute-neg-in99.9%
metadata-eval99.9%
sub-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 100.0%
mul-1-neg2.5%
unsub-neg2.5%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (/ x (+ x 1.0)) (/ (+ x 1.0) (- 1.0 x)))))
(if (<= t_0 0.0004)
(/ (+ 3.0 (/ (- (/ (+ 2.0 (/ -2.0 x)) x) 2.0) x)) (- 1.0 x))
t_0)))
double code(double x) {
double t_0 = (x / (x + 1.0)) + ((x + 1.0) / (1.0 - x));
double tmp;
if (t_0 <= 0.0004) {
tmp = (3.0 + ((((2.0 + (-2.0 / x)) / x) - 2.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)) + ((x + 1.0d0) / (1.0d0 - x))
if (t_0 <= 0.0004d0) then
tmp = (3.0d0 + ((((2.0d0 + ((-2.0d0) / x)) / x) - 2.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)) + ((x + 1.0) / (1.0 - x));
double tmp;
if (t_0 <= 0.0004) {
tmp = (3.0 + ((((2.0 + (-2.0 / x)) / x) - 2.0) / x)) / (1.0 - x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (x + 1.0)) + ((x + 1.0) / (1.0 - x)) tmp = 0 if t_0 <= 0.0004: tmp = (3.0 + ((((2.0 + (-2.0 / x)) / x) - 2.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(x + 1.0) / Float64(1.0 - x))) tmp = 0.0 if (t_0 <= 0.0004) tmp = Float64(Float64(3.0 + Float64(Float64(Float64(Float64(2.0 + Float64(-2.0 / x)) / x) - 2.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)) + ((x + 1.0) / (1.0 - x)); tmp = 0.0; if (t_0 <= 0.0004) tmp = (3.0 + ((((2.0 + (-2.0 / x)) / x) - 2.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[(x + 1.0), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0004], N[(N[(3.0 + N[(N[(N[(N[(2.0 + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 2.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1} + \frac{x + 1}{1 - x}\\
\mathbf{if}\;t\_0 \leq 0.0004:\\
\;\;\;\;\frac{3 + \frac{\frac{2 + \frac{-2}{x}}{x} - 2}{x}}{1 - x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 4.00000000000000019e-4Initial program 8.9%
remove-double-neg8.9%
distribute-neg-frac8.9%
distribute-neg-in8.9%
sub-neg8.9%
distribute-frac-neg28.9%
sub-neg8.9%
+-commutative8.9%
unsub-neg8.9%
metadata-eval8.9%
neg-sub08.9%
associate-+l-8.9%
neg-sub08.9%
+-commutative8.9%
unsub-neg8.9%
Simplified8.9%
frac-2neg8.9%
clear-num9.0%
frac-sub9.8%
+-commutative9.8%
distribute-neg-in9.8%
metadata-eval9.8%
sub-neg9.8%
*-commutative9.8%
*-un-lft-identity9.8%
+-commutative9.8%
distribute-neg-in9.8%
metadata-eval9.8%
sub-neg9.8%
Applied egg-rr9.8%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
associate-*r/100.0%
metadata-eval100.0%
distribute-neg-frac100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if 4.00000000000000019e-4 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (/ x (+ x 1.0)) (/ (+ x 1.0) (- 1.0 x)))))
(if (<= t_0 0.0004)
(/ (- (/ (+ -1.0 (/ (+ -3.0 (/ -1.0 x)) x)) x) 3.0) x)
t_0)))
double code(double x) {
double t_0 = (x / (x + 1.0)) + ((x + 1.0) / (1.0 - x));
double tmp;
if (t_0 <= 0.0004) {
tmp = (((-1.0 + ((-3.0 + (-1.0 / x)) / x)) / x) - 3.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)) + ((x + 1.0d0) / (1.0d0 - x))
if (t_0 <= 0.0004d0) then
tmp = ((((-1.0d0) + (((-3.0d0) + ((-1.0d0) / x)) / x)) / x) - 3.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)) + ((x + 1.0) / (1.0 - x));
double tmp;
if (t_0 <= 0.0004) {
tmp = (((-1.0 + ((-3.0 + (-1.0 / x)) / x)) / x) - 3.0) / x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (x + 1.0)) + ((x + 1.0) / (1.0 - x)) tmp = 0 if t_0 <= 0.0004: tmp = (((-1.0 + ((-3.0 + (-1.0 / x)) / x)) / x) - 3.0) / x else: tmp = t_0 return tmp
function code(x) t_0 = Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(x + 1.0) / Float64(1.0 - x))) tmp = 0.0 if (t_0 <= 0.0004) tmp = Float64(Float64(Float64(Float64(-1.0 + Float64(Float64(-3.0 + Float64(-1.0 / x)) / x)) / x) - 3.0) / x); else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = (x / (x + 1.0)) + ((x + 1.0) / (1.0 - x)); tmp = 0.0; if (t_0 <= 0.0004) tmp = (((-1.0 + ((-3.0 + (-1.0 / x)) / x)) / x) - 3.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[(x + 1.0), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0004], N[(N[(N[(N[(-1.0 + N[(N[(-3.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 3.0), $MachinePrecision] / x), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1} + \frac{x + 1}{1 - x}\\
\mathbf{if}\;t\_0 \leq 0.0004:\\
\;\;\;\;\frac{\frac{-1 + \frac{-3 + \frac{-1}{x}}{x}}{x} - 3}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 4.00000000000000019e-4Initial program 8.9%
remove-double-neg8.9%
distribute-neg-frac8.9%
distribute-neg-in8.9%
sub-neg8.9%
distribute-frac-neg28.9%
sub-neg8.9%
+-commutative8.9%
unsub-neg8.9%
metadata-eval8.9%
neg-sub08.9%
associate-+l-8.9%
neg-sub08.9%
+-commutative8.9%
unsub-neg8.9%
Simplified8.9%
Taylor expanded in x around inf 100.0%
Simplified100.0%
if 4.00000000000000019e-4 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Final simplification100.0%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (/ x (+ x 1.0)) (/ (+ x 1.0) (- 1.0 x))))) (if (<= t_0 0.0004) (/ (+ -3.0 (/ (- -1.0 (/ 3.0 x)) x)) x) t_0)))
double code(double x) {
double t_0 = (x / (x + 1.0)) + ((x + 1.0) / (1.0 - x));
double tmp;
if (t_0 <= 0.0004) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / 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)) + ((x + 1.0d0) / (1.0d0 - x))
if (t_0 <= 0.0004d0) then
tmp = ((-3.0d0) + (((-1.0d0) - (3.0d0 / x)) / x)) / x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x / (x + 1.0)) + ((x + 1.0) / (1.0 - x));
double tmp;
if (t_0 <= 0.0004) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (x + 1.0)) + ((x + 1.0) / (1.0 - x)) tmp = 0 if t_0 <= 0.0004: tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x else: tmp = t_0 return tmp
function code(x) t_0 = Float64(Float64(x / Float64(x + 1.0)) + Float64(Float64(x + 1.0) / Float64(1.0 - x))) tmp = 0.0 if (t_0 <= 0.0004) tmp = Float64(Float64(-3.0 + Float64(Float64(-1.0 - Float64(3.0 / x)) / x)) / x); else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = (x / (x + 1.0)) + ((x + 1.0) / (1.0 - x)); tmp = 0.0; if (t_0 <= 0.0004) tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / 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[(x + 1.0), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0004], N[(N[(-3.0 + N[(N[(-1.0 - N[(3.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{x + 1} + \frac{x + 1}{1 - x}\\
\mathbf{if}\;t\_0 \leq 0.0004:\\
\;\;\;\;\frac{-3 + \frac{-1 - \frac{3}{x}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) < 4.00000000000000019e-4Initial program 8.9%
remove-double-neg8.9%
distribute-neg-frac8.9%
distribute-neg-in8.9%
sub-neg8.9%
distribute-frac-neg28.9%
sub-neg8.9%
+-commutative8.9%
unsub-neg8.9%
metadata-eval8.9%
neg-sub08.9%
associate-+l-8.9%
neg-sub08.9%
+-commutative8.9%
unsub-neg8.9%
Simplified8.9%
Taylor expanded in x around inf 99.8%
sub-neg99.8%
metadata-eval99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
associate-*r/99.8%
metadata-eval99.8%
Simplified99.8%
if 4.00000000000000019e-4 < (-.f64 (/.f64 x (+.f64 x #s(literal 1 binary64))) (/.f64 (+.f64 x #s(literal 1 binary64)) (-.f64 x #s(literal 1 binary64)))) Initial program 99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ (+ -3.0 (/ (- -1.0 (/ 3.0 x)) x)) x) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / 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) + (((-1.0d0) - (3.0d0 / x)) / x)) / 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 + ((-1.0 - (3.0 / x)) / x)) / 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 + ((-1.0 - (3.0 / x)) / x)) / 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 + Float64(Float64(-1.0 - Float64(3.0 / x)) / x)) / 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 + ((-1.0 - (3.0 / x)) / x)) / 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 + N[(N[(-1.0 - N[(3.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / 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 + \frac{-1 - \frac{3}{x}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 9.6%
remove-double-neg9.6%
distribute-neg-frac9.6%
distribute-neg-in9.6%
sub-neg9.6%
distribute-frac-neg29.6%
sub-neg9.6%
+-commutative9.6%
unsub-neg9.6%
metadata-eval9.6%
neg-sub09.6%
associate-+l-9.6%
neg-sub09.6%
+-commutative9.6%
unsub-neg9.6%
Simplified9.6%
Taylor expanded in x around inf 99.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
if -1 < x < 1Initial program 100.0%
remove-double-neg100.0%
distribute-neg-frac100.0%
distribute-neg-in100.0%
sub-neg100.0%
distribute-frac-neg2100.0%
sub-neg100.0%
+-commutative100.0%
unsub-neg100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.1%
Final simplification98.7%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ (+ -3.0 (/ -1.0 x)) x) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = (-3.0 + (-1.0 / x)) / 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) + ((-1.0d0) / x)) / 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 + (-1.0 / x)) / 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 + (-1.0 / x)) / 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 + Float64(-1.0 / x)) / 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 + (-1.0 / x)) / 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 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / 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 + \frac{-1}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 9.6%
remove-double-neg9.6%
distribute-neg-frac9.6%
distribute-neg-in9.6%
sub-neg9.6%
distribute-frac-neg29.6%
sub-neg9.6%
+-commutative9.6%
unsub-neg9.6%
metadata-eval9.6%
neg-sub09.6%
associate-+l-9.6%
neg-sub09.6%
+-commutative9.6%
unsub-neg9.6%
Simplified9.6%
Taylor expanded in x around inf 98.8%
associate-*r/98.8%
neg-mul-198.8%
distribute-neg-in98.8%
metadata-eval98.8%
distribute-neg-frac98.8%
metadata-eval98.8%
Simplified98.8%
if -1 < x < 1Initial program 100.0%
remove-double-neg100.0%
distribute-neg-frac100.0%
distribute-neg-in100.0%
sub-neg100.0%
distribute-frac-neg2100.0%
sub-neg100.0%
+-commutative100.0%
unsub-neg100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.1%
Final simplification98.4%
(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.6%
remove-double-neg9.6%
distribute-neg-frac9.6%
distribute-neg-in9.6%
sub-neg9.6%
distribute-frac-neg29.6%
sub-neg9.6%
+-commutative9.6%
unsub-neg9.6%
metadata-eval9.6%
neg-sub09.6%
associate-+l-9.6%
neg-sub09.6%
+-commutative9.6%
unsub-neg9.6%
Simplified9.6%
Taylor expanded in x around inf 97.3%
if -1 < x < 1Initial program 100.0%
remove-double-neg100.0%
distribute-neg-frac100.0%
distribute-neg-in100.0%
sub-neg100.0%
distribute-frac-neg2100.0%
sub-neg100.0%
+-commutative100.0%
unsub-neg100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.1%
Final simplification97.7%
(FPCore (x) :precision binary64 (if (<= x -1.0) (/ (- 3.0 (/ 2.0 x)) (- 1.0 x)) (if (<= x 1.0) (+ 1.0 (* x (+ x 3.0))) (/ (+ -3.0 (/ -1.0 x)) x))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = (3.0 - (2.0 / x)) / (1.0 - x);
} else if (x <= 1.0) {
tmp = 1.0 + (x * (x + 3.0));
} else {
tmp = (-3.0 + (-1.0 / x)) / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = (3.0d0 - (2.0d0 / x)) / (1.0d0 - x)
else if (x <= 1.0d0) then
tmp = 1.0d0 + (x * (x + 3.0d0))
else
tmp = ((-3.0d0) + ((-1.0d0) / x)) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = (3.0 - (2.0 / x)) / (1.0 - x);
} else if (x <= 1.0) {
tmp = 1.0 + (x * (x + 3.0));
} else {
tmp = (-3.0 + (-1.0 / x)) / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = (3.0 - (2.0 / x)) / (1.0 - x) elif x <= 1.0: tmp = 1.0 + (x * (x + 3.0)) else: tmp = (-3.0 + (-1.0 / x)) / x return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(3.0 - Float64(2.0 / x)) / Float64(1.0 - x)); elseif (x <= 1.0) tmp = Float64(1.0 + Float64(x * Float64(x + 3.0))); else tmp = Float64(Float64(-3.0 + Float64(-1.0 / x)) / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = (3.0 - (2.0 / x)) / (1.0 - x); elseif (x <= 1.0) tmp = 1.0 + (x * (x + 3.0)); else tmp = (-3.0 + (-1.0 / x)) / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], N[(N[(3.0 - N[(2.0 / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 + N[(x * N[(x + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-3.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{3 - \frac{2}{x}}{1 - x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-3 + \frac{-1}{x}}{x}\\
\end{array}
\end{array}
if x < -1Initial program 12.4%
remove-double-neg12.4%
distribute-neg-frac12.4%
distribute-neg-in12.4%
sub-neg12.4%
distribute-frac-neg212.4%
sub-neg12.4%
+-commutative12.4%
unsub-neg12.4%
metadata-eval12.4%
neg-sub012.4%
associate-+l-12.4%
neg-sub012.4%
+-commutative12.4%
unsub-neg12.4%
Simplified12.4%
frac-2neg12.4%
clear-num12.6%
frac-sub13.6%
+-commutative13.6%
distribute-neg-in13.6%
metadata-eval13.6%
sub-neg13.6%
*-commutative13.6%
*-un-lft-identity13.6%
+-commutative13.6%
distribute-neg-in13.6%
metadata-eval13.6%
sub-neg13.6%
Applied egg-rr13.6%
Taylor expanded in x around 0 13.6%
mul-1-neg98.9%
unsub-neg98.9%
Simplified13.6%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
metadata-eval97.9%
Simplified97.9%
if -1 < x < 1Initial program 100.0%
remove-double-neg100.0%
distribute-neg-frac100.0%
distribute-neg-in100.0%
sub-neg100.0%
distribute-frac-neg2100.0%
sub-neg100.0%
+-commutative100.0%
unsub-neg100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 98.1%
if 1 < x Initial program 7.6%
remove-double-neg7.6%
distribute-neg-frac7.6%
distribute-neg-in7.6%
sub-neg7.6%
distribute-frac-neg27.6%
sub-neg7.6%
+-commutative7.6%
unsub-neg7.6%
metadata-eval7.6%
neg-sub07.6%
associate-+l-7.6%
neg-sub07.6%
+-commutative7.6%
unsub-neg7.6%
Simplified7.6%
Taylor expanded in x around inf 99.5%
associate-*r/99.5%
neg-mul-199.5%
distribute-neg-in99.5%
metadata-eval99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
Simplified99.5%
Final simplification98.5%
(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.6%
remove-double-neg9.6%
distribute-neg-frac9.6%
distribute-neg-in9.6%
sub-neg9.6%
distribute-frac-neg29.6%
sub-neg9.6%
+-commutative9.6%
unsub-neg9.6%
metadata-eval9.6%
neg-sub09.6%
associate-+l-9.6%
neg-sub09.6%
+-commutative9.6%
unsub-neg9.6%
Simplified9.6%
Taylor expanded in x around inf 97.3%
if -1 < x < 1Initial program 100.0%
remove-double-neg100.0%
distribute-neg-frac100.0%
distribute-neg-in100.0%
sub-neg100.0%
distribute-frac-neg2100.0%
sub-neg100.0%
+-commutative100.0%
unsub-neg100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 97.4%
Final simplification97.3%
(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.6%
remove-double-neg9.6%
distribute-neg-frac9.6%
distribute-neg-in9.6%
sub-neg9.6%
distribute-frac-neg29.6%
sub-neg9.6%
+-commutative9.6%
unsub-neg9.6%
metadata-eval9.6%
neg-sub09.6%
associate-+l-9.6%
neg-sub09.6%
+-commutative9.6%
unsub-neg9.6%
Simplified9.6%
Taylor expanded in x around inf 97.3%
if -1 < x < 1Initial program 100.0%
remove-double-neg100.0%
distribute-neg-frac100.0%
distribute-neg-in100.0%
sub-neg100.0%
distribute-frac-neg2100.0%
sub-neg100.0%
+-commutative100.0%
unsub-neg100.0%
metadata-eval100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 95.5%
Final simplification96.4%
(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 54.1%
remove-double-neg54.1%
distribute-neg-frac54.1%
distribute-neg-in54.1%
sub-neg54.1%
distribute-frac-neg254.1%
sub-neg54.1%
+-commutative54.1%
unsub-neg54.1%
metadata-eval54.1%
neg-sub054.1%
associate-+l-54.1%
neg-sub054.1%
+-commutative54.1%
unsub-neg54.1%
Simplified54.1%
Taylor expanded in x around 0 48.9%
herbie shell --seed 2024139
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))