
(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 (/ (+ 3.0 (/ 1.0 x)) (* (/ (+ 1.0 x) x) (- 1.0 x))))
double code(double x) {
return (3.0 + (1.0 / x)) / (((1.0 + x) / x) * (1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (3.0d0 + (1.0d0 / x)) / (((1.0d0 + x) / x) * (1.0d0 - x))
end function
public static double code(double x) {
return (3.0 + (1.0 / x)) / (((1.0 + x) / x) * (1.0 - x));
}
def code(x): return (3.0 + (1.0 / x)) / (((1.0 + x) / x) * (1.0 - x))
function code(x) return Float64(Float64(3.0 + Float64(1.0 / x)) / Float64(Float64(Float64(1.0 + x) / x) * Float64(1.0 - x))) end
function tmp = code(x) tmp = (3.0 + (1.0 / x)) / (((1.0 + x) / x) * (1.0 - x)); end
code[x_] := N[(N[(3.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{3 + \frac{1}{x}}{\frac{1 + x}{x} \cdot \left(1 - x\right)}
\end{array}
Initial program 51.0%
remove-double-neg51.0%
distribute-neg-frac51.0%
distribute-neg-in51.0%
sub-neg51.0%
distribute-frac-neg251.0%
sub-neg51.0%
+-commutative51.0%
unsub-neg51.0%
metadata-eval51.0%
neg-sub051.0%
associate-+l-51.0%
neg-sub051.0%
+-commutative51.0%
unsub-neg51.0%
Simplified51.0%
clear-num51.0%
frac-sub51.6%
*-un-lft-identity51.6%
Applied egg-rr51.6%
Taylor expanded in x around inf 100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (/ x (+ 1.0 x)) (/ (+ 1.0 x) (- 1.0 x)))))
(if (<= t_0 1e-5)
(+ (/ -3.0 x) (* (/ 1.0 x) (/ (- -1.0 (/ 3.0 x)) x)))
t_0)))
double code(double x) {
double t_0 = (x / (1.0 + x)) + ((1.0 + x) / (1.0 - x));
double tmp;
if (t_0 <= 1e-5) {
tmp = (-3.0 / x) + ((1.0 / x) * ((-1.0 - (3.0 / 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 / (1.0d0 + x)) + ((1.0d0 + x) / (1.0d0 - x))
if (t_0 <= 1d-5) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * (((-1.0d0) - (3.0d0 / x)) / x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (x / (1.0 + x)) + ((1.0 + x) / (1.0 - x));
double tmp;
if (t_0 <= 1e-5) {
tmp = (-3.0 / x) + ((1.0 / x) * ((-1.0 - (3.0 / x)) / x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (1.0 + x)) + ((1.0 + x) / (1.0 - x)) tmp = 0 if t_0 <= 1e-5: tmp = (-3.0 / x) + ((1.0 / x) * ((-1.0 - (3.0 / x)) / x)) else: tmp = t_0 return tmp
function code(x) t_0 = Float64(Float64(x / Float64(1.0 + x)) + Float64(Float64(1.0 + x) / Float64(1.0 - x))) tmp = 0.0 if (t_0 <= 1e-5) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(Float64(-1.0 - Float64(3.0 / x)) / x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = (x / (1.0 + x)) + ((1.0 + x) / (1.0 - x)); tmp = 0.0; if (t_0 <= 1e-5) tmp = (-3.0 / x) + ((1.0 / x) * ((-1.0 - (3.0 / x)) / x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-5], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(N[(-1.0 - N[(3.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x} + \frac{1 + x}{1 - x}\\
\mathbf{if}\;t\_0 \leq 10^{-5}:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1 - \frac{3}{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)))) < 1.00000000000000008e-5Initial program 9.8%
remove-double-neg9.8%
distribute-neg-frac9.8%
distribute-neg-in9.8%
sub-neg9.8%
distribute-frac-neg29.8%
sub-neg9.8%
+-commutative9.8%
unsub-neg9.8%
metadata-eval9.8%
neg-sub09.8%
associate-+l-9.8%
neg-sub09.8%
+-commutative9.8%
unsub-neg9.8%
Simplified9.8%
Taylor expanded in x around inf 99.7%
sub-neg99.7%
metadata-eval99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
div-sub99.7%
associate-/l/99.7%
pow299.7%
Applied egg-rr99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.7%
Applied egg-rr99.7%
if 1.00000000000000008e-5 < (-.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.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ x (+ 1.0 x))))
(if (<= (+ t_0 (/ (+ 1.0 x) (- 1.0 x))) 1e-5)
(+ (/ -3.0 x) (* (/ 1.0 x) (/ (- -1.0 (/ 3.0 x)) x)))
(+ t_0 (* (+ 1.0 x) (/ 1.0 (- 1.0 x)))))))
double code(double x) {
double t_0 = x / (1.0 + x);
double tmp;
if ((t_0 + ((1.0 + x) / (1.0 - x))) <= 1e-5) {
tmp = (-3.0 / x) + ((1.0 / x) * ((-1.0 - (3.0 / x)) / x));
} else {
tmp = t_0 + ((1.0 + x) * (1.0 / (1.0 - x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x / (1.0d0 + x)
if ((t_0 + ((1.0d0 + x) / (1.0d0 - x))) <= 1d-5) then
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * (((-1.0d0) - (3.0d0 / x)) / x))
else
tmp = t_0 + ((1.0d0 + x) * (1.0d0 / (1.0d0 - x)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = x / (1.0 + x);
double tmp;
if ((t_0 + ((1.0 + x) / (1.0 - x))) <= 1e-5) {
tmp = (-3.0 / x) + ((1.0 / x) * ((-1.0 - (3.0 / x)) / x));
} else {
tmp = t_0 + ((1.0 + x) * (1.0 / (1.0 - x)));
}
return tmp;
}
def code(x): t_0 = x / (1.0 + x) tmp = 0 if (t_0 + ((1.0 + x) / (1.0 - x))) <= 1e-5: tmp = (-3.0 / x) + ((1.0 / x) * ((-1.0 - (3.0 / x)) / x)) else: tmp = t_0 + ((1.0 + x) * (1.0 / (1.0 - x))) return tmp
function code(x) t_0 = Float64(x / Float64(1.0 + x)) tmp = 0.0 if (Float64(t_0 + Float64(Float64(1.0 + x) / Float64(1.0 - x))) <= 1e-5) tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(Float64(-1.0 - Float64(3.0 / x)) / x))); else tmp = Float64(t_0 + Float64(Float64(1.0 + x) * Float64(1.0 / Float64(1.0 - x)))); end return tmp end
function tmp_2 = code(x) t_0 = x / (1.0 + x); tmp = 0.0; if ((t_0 + ((1.0 + x) / (1.0 - x))) <= 1e-5) tmp = (-3.0 / x) + ((1.0 / x) * ((-1.0 - (3.0 / x)) / x)); else tmp = t_0 + ((1.0 + x) * (1.0 / (1.0 - x))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 + N[(N[(1.0 + x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-5], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(N[(-1.0 - N[(3.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(N[(1.0 + x), $MachinePrecision] * N[(1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{1 + x}\\
\mathbf{if}\;t\_0 + \frac{1 + x}{1 - x} \leq 10^{-5}:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1 - \frac{3}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0 + \left(1 + x\right) \cdot \frac{1}{1 - x}\\
\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)))) < 1.00000000000000008e-5Initial program 9.8%
remove-double-neg9.8%
distribute-neg-frac9.8%
distribute-neg-in9.8%
sub-neg9.8%
distribute-frac-neg29.8%
sub-neg9.8%
+-commutative9.8%
unsub-neg9.8%
metadata-eval9.8%
neg-sub09.8%
associate-+l-9.8%
neg-sub09.8%
+-commutative9.8%
unsub-neg9.8%
Simplified9.8%
Taylor expanded in x around inf 99.7%
sub-neg99.7%
metadata-eval99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
div-sub99.7%
associate-/l/99.7%
pow299.7%
Applied egg-rr99.7%
*-un-lft-identity99.7%
unpow299.7%
times-frac99.7%
Applied egg-rr99.7%
if 1.00000000000000008e-5 < (-.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%
clear-num100.0%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.8%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (/ x (+ 1.0 x)) (/ (+ 1.0 x) (- 1.0 x))))) (if (<= t_0 1e-5) (/ (+ -3.0 (/ (- -1.0 (/ 3.0 x)) x)) x) t_0)))
double code(double x) {
double t_0 = (x / (1.0 + x)) + ((1.0 + x) / (1.0 - x));
double tmp;
if (t_0 <= 1e-5) {
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 / (1.0d0 + x)) + ((1.0d0 + x) / (1.0d0 - x))
if (t_0 <= 1d-5) 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 / (1.0 + x)) + ((1.0 + x) / (1.0 - x));
double tmp;
if (t_0 <= 1e-5) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = (x / (1.0 + x)) + ((1.0 + x) / (1.0 - x)) tmp = 0 if t_0 <= 1e-5: 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(1.0 + x)) + Float64(Float64(1.0 + x) / Float64(1.0 - x))) tmp = 0.0 if (t_0 <= 1e-5) 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 / (1.0 + x)) + ((1.0 + x) / (1.0 - x)); tmp = 0.0; if (t_0 <= 1e-5) 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[(1.0 + x), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + x), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-5], 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}{1 + x} + \frac{1 + x}{1 - x}\\
\mathbf{if}\;t\_0 \leq 10^{-5}:\\
\;\;\;\;\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)))) < 1.00000000000000008e-5Initial program 9.8%
remove-double-neg9.8%
distribute-neg-frac9.8%
distribute-neg-in9.8%
sub-neg9.8%
distribute-frac-neg29.8%
sub-neg9.8%
+-commutative9.8%
unsub-neg9.8%
metadata-eval9.8%
neg-sub09.8%
associate-+l-9.8%
neg-sub09.8%
+-commutative9.8%
unsub-neg9.8%
Simplified9.8%
Taylor expanded in x around inf 99.7%
sub-neg99.7%
metadata-eval99.7%
+-commutative99.7%
mul-1-neg99.7%
unsub-neg99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
if 1.00000000000000008e-5 < (-.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.8%
(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 (+ 3.0 x)))))
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 * (3.0 + x));
}
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 * (3.0d0 + x))
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 * (3.0 + x));
}
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 * (3.0 + x)) 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(3.0 + x))); 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 * (3.0 + x)); 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[(3.0 + x), $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(3 + x\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 10.4%
remove-double-neg10.4%
distribute-neg-frac10.4%
distribute-neg-in10.4%
sub-neg10.4%
distribute-frac-neg210.4%
sub-neg10.4%
+-commutative10.4%
unsub-neg10.4%
metadata-eval10.4%
neg-sub010.4%
associate-+l-10.4%
neg-sub010.4%
+-commutative10.4%
unsub-neg10.4%
Simplified10.4%
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 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%
Taylor expanded in x around 0 99.4%
Final simplification99.3%
(FPCore (x)
:precision binary64
(if (<= x -1.0)
(/ (+ -3.0 (/ -1.0 x)) x)
(if (<= x 1.0)
(+ 1.0 (* x (+ 3.0 x)))
(+ (/ -3.0 x) (* (/ 1.0 x) (/ -1.0 x))))))
double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = (-3.0 + (-1.0 / x)) / x;
} else if (x <= 1.0) {
tmp = 1.0 + (x * (3.0 + x));
} else {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = ((-3.0d0) + ((-1.0d0) / x)) / x
else if (x <= 1.0d0) then
tmp = 1.0d0 + (x * (3.0d0 + x))
else
tmp = ((-3.0d0) / x) + ((1.0d0 / x) * ((-1.0d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.0) {
tmp = (-3.0 + (-1.0 / x)) / x;
} else if (x <= 1.0) {
tmp = 1.0 + (x * (3.0 + x));
} else {
tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.0: tmp = (-3.0 + (-1.0 / x)) / x elif x <= 1.0: tmp = 1.0 + (x * (3.0 + x)) else: tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)) return tmp
function code(x) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(-3.0 + Float64(-1.0 / x)) / x); elseif (x <= 1.0) tmp = Float64(1.0 + Float64(x * Float64(3.0 + x))); else tmp = Float64(Float64(-3.0 / x) + Float64(Float64(1.0 / x) * Float64(-1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.0) tmp = (-3.0 + (-1.0 / x)) / x; elseif (x <= 1.0) tmp = 1.0 + (x * (3.0 + x)); else tmp = (-3.0 / x) + ((1.0 / x) * (-1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.0], N[(N[(-3.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 + N[(x * N[(3.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-3.0 / x), $MachinePrecision] + N[(N[(1.0 / x), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{-3 + \frac{-1}{x}}{x}\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 + x \cdot \left(3 + x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-3}{x} + \frac{1}{x} \cdot \frac{-1}{x}\\
\end{array}
\end{array}
if x < -1Initial program 11.0%
remove-double-neg11.0%
distribute-neg-frac11.0%
distribute-neg-in11.0%
sub-neg11.0%
distribute-frac-neg211.0%
sub-neg11.0%
+-commutative11.0%
unsub-neg11.0%
metadata-eval11.0%
neg-sub011.0%
associate-+l-11.0%
neg-sub011.0%
+-commutative11.0%
unsub-neg11.0%
Simplified11.0%
Taylor expanded in x around inf 98.1%
associate-*r/98.1%
distribute-lft-in98.1%
metadata-eval98.1%
neg-mul-198.1%
distribute-neg-frac98.1%
metadata-eval98.1%
Simplified98.1%
if -1 < x < 1Initial 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%
Taylor expanded in x around 0 99.4%
if 1 < x Initial program 9.8%
remove-double-neg9.8%
distribute-neg-frac9.8%
distribute-neg-in9.8%
sub-neg9.8%
distribute-frac-neg29.8%
sub-neg9.8%
+-commutative9.8%
unsub-neg9.8%
metadata-eval9.8%
neg-sub09.8%
associate-+l-9.8%
neg-sub09.8%
+-commutative9.8%
unsub-neg9.8%
Simplified9.8%
Taylor expanded in x around inf 99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
mul-1-neg99.5%
unsub-neg99.5%
associate-*r/99.5%
metadata-eval99.5%
Simplified99.5%
div-sub99.5%
associate-/l/99.5%
pow299.5%
Applied egg-rr99.5%
*-un-lft-identity99.5%
unpow299.5%
times-frac99.5%
Applied egg-rr99.5%
Taylor expanded in x around inf 98.8%
Final simplification98.9%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -3.0 x) (+ 1.0 (* x (+ 3.0 x)))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * (3.0 + x));
}
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 + x))
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 + x));
}
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 + x)) 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(3.0 + x))); 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 + x)); 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[(3.0 + x), $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(3 + x\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 10.4%
remove-double-neg10.4%
distribute-neg-frac10.4%
distribute-neg-in10.4%
sub-neg10.4%
distribute-frac-neg210.4%
sub-neg10.4%
+-commutative10.4%
unsub-neg10.4%
metadata-eval10.4%
neg-sub010.4%
associate-+l-10.4%
neg-sub010.4%
+-commutative10.4%
unsub-neg10.4%
Simplified10.4%
Taylor expanded in x around inf 96.7%
if -1 < x < 1Initial 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%
Taylor expanded in x around 0 99.4%
Final simplification97.9%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ (+ -3.0 (/ -1.0 x)) x) (+ 1.0 (* x (+ 3.0 x)))))
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 * (3.0 + x));
}
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 * (3.0d0 + x))
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 * (3.0 + x));
}
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 * (3.0 + x)) 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(3.0 + x))); 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 * (3.0 + x)); 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[(3.0 + x), $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(3 + x\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 10.4%
remove-double-neg10.4%
distribute-neg-frac10.4%
distribute-neg-in10.4%
sub-neg10.4%
distribute-frac-neg210.4%
sub-neg10.4%
+-commutative10.4%
unsub-neg10.4%
metadata-eval10.4%
neg-sub010.4%
associate-+l-10.4%
neg-sub010.4%
+-commutative10.4%
unsub-neg10.4%
Simplified10.4%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
distribute-lft-in98.5%
metadata-eval98.5%
neg-mul-198.5%
distribute-neg-frac98.5%
metadata-eval98.5%
Simplified98.5%
if -1 < x < 1Initial 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%
Taylor expanded in x around 0 99.4%
Final simplification98.9%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (/ -3.0 x) (+ 1.0 (* 3.0 x))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (3.0 * x);
}
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 + (3.0d0 * x)
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 + (3.0 * x);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = -3.0 / x else: tmp = 1.0 + (3.0 * x) 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(3.0 * x)); 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 + (3.0 * x); 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[(3.0 * x), $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 + 3 \cdot x\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 10.4%
remove-double-neg10.4%
distribute-neg-frac10.4%
distribute-neg-in10.4%
sub-neg10.4%
distribute-frac-neg210.4%
sub-neg10.4%
+-commutative10.4%
unsub-neg10.4%
metadata-eval10.4%
neg-sub010.4%
associate-+l-10.4%
neg-sub010.4%
+-commutative10.4%
unsub-neg10.4%
Simplified10.4%
Taylor expanded in x around inf 96.7%
if -1 < x < 1Initial 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%
Taylor expanded in x around 0 99.0%
Final simplification97.7%
(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 10.4%
remove-double-neg10.4%
distribute-neg-frac10.4%
distribute-neg-in10.4%
sub-neg10.4%
distribute-frac-neg210.4%
sub-neg10.4%
+-commutative10.4%
unsub-neg10.4%
metadata-eval10.4%
neg-sub010.4%
associate-+l-10.4%
neg-sub010.4%
+-commutative10.4%
unsub-neg10.4%
Simplified10.4%
Taylor expanded in x around inf 96.7%
if -1 < x < 1Initial 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%
Taylor expanded in x around 0 97.6%
Final simplification97.1%
(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 51.0%
remove-double-neg51.0%
distribute-neg-frac51.0%
distribute-neg-in51.0%
sub-neg51.0%
distribute-frac-neg251.0%
sub-neg51.0%
+-commutative51.0%
unsub-neg51.0%
metadata-eval51.0%
neg-sub051.0%
associate-+l-51.0%
neg-sub051.0%
+-commutative51.0%
unsub-neg51.0%
Simplified51.0%
Taylor expanded in x around 0 46.3%
Final simplification46.3%
herbie shell --seed 2024075
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))