
(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 (/ (+ (/ 1.0 x) 3.0) (* (/ (+ 1.0 x) x) (- 1.0 x))))
double code(double x) {
return ((1.0 / x) + 3.0) / (((1.0 + x) / x) * (1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / x) + 3.0d0) / (((1.0d0 + x) / x) * (1.0d0 - x))
end function
public static double code(double x) {
return ((1.0 / x) + 3.0) / (((1.0 + x) / x) * (1.0 - x));
}
def code(x): return ((1.0 / x) + 3.0) / (((1.0 + x) / x) * (1.0 - x))
function code(x) return Float64(Float64(Float64(1.0 / x) + 3.0) / Float64(Float64(Float64(1.0 + x) / x) * Float64(1.0 - x))) end
function tmp = code(x) tmp = ((1.0 / x) + 3.0) / (((1.0 + x) / x) * (1.0 - x)); end
code[x_] := N[(N[(N[(1.0 / x), $MachinePrecision] + 3.0), $MachinePrecision] / N[(N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x} + 3}{\frac{1 + x}{x} \cdot \left(1 - x\right)}
\end{array}
Initial program 54.5%
remove-double-neg54.5%
distribute-neg-frac54.5%
distribute-neg-in54.5%
sub-neg54.5%
distribute-frac-neg254.5%
sub-neg54.5%
+-commutative54.5%
unsub-neg54.5%
metadata-eval54.5%
neg-sub054.5%
associate-+l-54.5%
neg-sub054.5%
+-commutative54.5%
unsub-neg54.5%
Simplified54.5%
clear-num54.5%
frac-sub54.6%
*-un-lft-identity54.6%
Applied egg-rr54.6%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (let* ((t_0 (+ (/ x (+ 1.0 x)) (/ (- -1.0 x) (+ x -1.0))))) (if (<= t_0 0.0) (/ (+ -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) / (x + -1.0));
double tmp;
if (t_0 <= 0.0) {
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) / (x + (-1.0d0)))
if (t_0 <= 0.0d0) 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) / (x + -1.0));
double tmp;
if (t_0 <= 0.0) {
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) / (x + -1.0)) tmp = 0 if t_0 <= 0.0: 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(x + -1.0))) tmp = 0.0 if (t_0 <= 0.0) 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) / (x + -1.0)); tmp = 0.0; if (t_0 <= 0.0) 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[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], 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}{x + -1}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\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)))) < 0.0Initial program 7.5%
remove-double-neg7.5%
distribute-neg-frac7.5%
distribute-neg-in7.5%
sub-neg7.5%
distribute-frac-neg27.5%
sub-neg7.5%
+-commutative7.5%
unsub-neg7.5%
metadata-eval7.5%
neg-sub07.5%
associate-+l-7.5%
neg-sub07.5%
+-commutative7.5%
unsub-neg7.5%
Simplified7.5%
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 0.0 < (-.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.4%
Final simplification99.6%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 5.1e-11))) (/ (+ -3.0 (/ (- -1.0 (/ 3.0 x)) x)) x) (+ 1.0 (* x (+ 3.0 (* x (+ 1.0 (* x 3.0))))))))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 5.1e-11)) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x;
} else {
tmp = 1.0 + (x * (3.0 + (x * (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 <= 5.1d-11))) then
tmp = ((-3.0d0) + (((-1.0d0) - (3.0d0 / x)) / x)) / x
else
tmp = 1.0d0 + (x * (3.0d0 + (x * (1.0d0 + (x * 3.0d0)))))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 5.1e-11)) {
tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x;
} else {
tmp = 1.0 + (x * (3.0 + (x * (1.0 + (x * 3.0)))));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 5.1e-11): tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x else: tmp = 1.0 + (x * (3.0 + (x * (1.0 + (x * 3.0))))) return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 5.1e-11)) 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 + Float64(x * Float64(1.0 + Float64(x * 3.0)))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 5.1e-11))) tmp = (-3.0 + ((-1.0 - (3.0 / x)) / x)) / x; else tmp = 1.0 + (x * (3.0 + (x * (1.0 + (x * 3.0))))); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 5.1e-11]], $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 + N[(x * N[(1.0 + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 5.1 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{-3 + \frac{-1 - \frac{3}{x}}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(3 + x \cdot \left(1 + x \cdot 3\right)\right)\\
\end{array}
\end{array}
if x < -1 or 5.09999999999999984e-11 < x Initial program 10.5%
remove-double-neg10.5%
distribute-neg-frac10.5%
distribute-neg-in10.5%
sub-neg10.5%
distribute-frac-neg210.5%
sub-neg10.5%
+-commutative10.5%
unsub-neg10.5%
metadata-eval10.5%
neg-sub010.5%
associate-+l-10.5%
neg-sub010.5%
+-commutative10.5%
unsub-neg10.5%
Simplified10.5%
Taylor expanded in x around inf 97.8%
sub-neg97.8%
metadata-eval97.8%
+-commutative97.8%
mul-1-neg97.8%
unsub-neg97.8%
associate-*r/97.8%
metadata-eval97.8%
Simplified97.8%
if -1 < x < 5.09999999999999984e-11Initial 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 99.7%
Final simplification98.7%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 5.1e-11))) (/ (+ -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 <= 5.1e-11)) {
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 <= 5.1d-11))) 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 <= 5.1e-11)) {
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 <= 5.1e-11): 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 <= 5.1e-11)) 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 <= 5.1e-11))) 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, 5.1e-11]], $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 5.1 \cdot 10^{-11}\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 5.09999999999999984e-11 < x Initial program 10.5%
remove-double-neg10.5%
distribute-neg-frac10.5%
distribute-neg-in10.5%
sub-neg10.5%
distribute-frac-neg210.5%
sub-neg10.5%
+-commutative10.5%
unsub-neg10.5%
metadata-eval10.5%
neg-sub010.5%
associate-+l-10.5%
neg-sub010.5%
+-commutative10.5%
unsub-neg10.5%
Simplified10.5%
Taylor expanded in x around inf 97.8%
sub-neg97.8%
metadata-eval97.8%
+-commutative97.8%
mul-1-neg97.8%
unsub-neg97.8%
associate-*r/97.8%
metadata-eval97.8%
Simplified97.8%
if -1 < x < 5.09999999999999984e-11Initial 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 99.5%
Final simplification98.6%
(FPCore (x) :precision binary64 (if (or (<= x -3.25e+50) (not (<= x 5.1e-11))) (/ -3.0 x) (+ 1.0 (* x (+ x 3.0)))))
double code(double x) {
double tmp;
if ((x <= -3.25e+50) || !(x <= 5.1e-11)) {
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 <= (-3.25d+50)) .or. (.not. (x <= 5.1d-11))) 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 <= -3.25e+50) || !(x <= 5.1e-11)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * (x + 3.0));
}
return tmp;
}
def code(x): tmp = 0 if (x <= -3.25e+50) or not (x <= 5.1e-11): tmp = -3.0 / x else: tmp = 1.0 + (x * (x + 3.0)) return tmp
function code(x) tmp = 0.0 if ((x <= -3.25e+50) || !(x <= 5.1e-11)) 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 <= -3.25e+50) || ~((x <= 5.1e-11))) tmp = -3.0 / x; else tmp = 1.0 + (x * (x + 3.0)); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -3.25e+50], N[Not[LessEqual[x, 5.1e-11]], $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 -3.25 \cdot 10^{+50} \lor \neg \left(x \leq 5.1 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\end{array}
\end{array}
if x < -3.2500000000000001e50 or 5.09999999999999984e-11 < x Initial program 9.0%
remove-double-neg9.0%
distribute-neg-frac9.0%
distribute-neg-in9.0%
sub-neg9.0%
distribute-frac-neg29.0%
sub-neg9.0%
+-commutative9.0%
unsub-neg9.0%
metadata-eval9.0%
neg-sub09.0%
associate-+l-9.0%
neg-sub09.0%
+-commutative9.0%
unsub-neg9.0%
Simplified9.0%
Taylor expanded in x around inf 97.1%
if -3.2500000000000001e50 < x < 5.09999999999999984e-11Initial program 98.0%
remove-double-neg98.0%
distribute-neg-frac98.0%
distribute-neg-in98.0%
sub-neg98.0%
distribute-frac-neg298.0%
sub-neg98.0%
+-commutative98.0%
unsub-neg98.0%
metadata-eval98.0%
neg-sub098.0%
associate-+l-98.0%
neg-sub098.0%
+-commutative98.0%
unsub-neg98.0%
Simplified98.0%
Taylor expanded in x around 0 96.0%
Final simplification96.5%
(FPCore (x) :precision binary64 (if (<= x -3.25e+50) (/ -3.0 x) (if (<= x 1.25e-17) (+ 1.0 (* x (+ x 3.0))) (/ (+ -3.0 (/ -1.0 x)) x))))
double code(double x) {
double tmp;
if (x <= -3.25e+50) {
tmp = -3.0 / x;
} else if (x <= 1.25e-17) {
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 <= (-3.25d+50)) then
tmp = (-3.0d0) / x
else if (x <= 1.25d-17) 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 <= -3.25e+50) {
tmp = -3.0 / x;
} else if (x <= 1.25e-17) {
tmp = 1.0 + (x * (x + 3.0));
} else {
tmp = (-3.0 + (-1.0 / x)) / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= -3.25e+50: tmp = -3.0 / x elif x <= 1.25e-17: 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 <= -3.25e+50) tmp = Float64(-3.0 / x); elseif (x <= 1.25e-17) 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 <= -3.25e+50) tmp = -3.0 / x; elseif (x <= 1.25e-17) 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, -3.25e+50], N[(-3.0 / x), $MachinePrecision], If[LessEqual[x, 1.25e-17], 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 -3.25 \cdot 10^{+50}:\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{-17}:\\
\;\;\;\;1 + x \cdot \left(x + 3\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-3 + \frac{-1}{x}}{x}\\
\end{array}
\end{array}
if x < -3.2500000000000001e50Initial program 5.7%
remove-double-neg5.7%
distribute-neg-frac5.7%
distribute-neg-in5.7%
sub-neg5.7%
distribute-frac-neg25.7%
sub-neg5.7%
+-commutative5.7%
unsub-neg5.7%
metadata-eval5.7%
neg-sub05.7%
associate-+l-5.7%
neg-sub05.7%
+-commutative5.7%
unsub-neg5.7%
Simplified5.7%
Taylor expanded in x around inf 100.0%
if -3.2500000000000001e50 < x < 1.25e-17Initial program 98.0%
remove-double-neg98.0%
distribute-neg-frac98.0%
distribute-neg-in98.0%
sub-neg98.0%
distribute-frac-neg298.0%
sub-neg98.0%
+-commutative98.0%
unsub-neg98.0%
metadata-eval98.0%
neg-sub098.0%
associate-+l-98.0%
neg-sub098.0%
+-commutative98.0%
unsub-neg98.0%
Simplified98.0%
Taylor expanded in x around 0 95.9%
if 1.25e-17 < x Initial program 12.0%
remove-double-neg12.0%
distribute-neg-frac12.0%
distribute-neg-in12.0%
sub-neg12.0%
distribute-frac-neg212.0%
sub-neg12.0%
+-commutative12.0%
unsub-neg12.0%
metadata-eval12.0%
neg-sub012.0%
associate-+l-12.0%
neg-sub012.0%
+-commutative12.0%
unsub-neg12.0%
Simplified12.0%
Taylor expanded in x around inf 95.2%
associate-*r/95.2%
neg-mul-195.2%
distribute-neg-in95.2%
metadata-eval95.2%
distribute-neg-frac95.2%
metadata-eval95.2%
Simplified95.2%
Final simplification96.4%
(FPCore (x) :precision binary64 (if (or (<= x -3.25e+50) (not (<= x 5.1e-11))) (/ -3.0 x) (+ 1.0 (* x 3.0))))
double code(double x) {
double tmp;
if ((x <= -3.25e+50) || !(x <= 5.1e-11)) {
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 <= (-3.25d+50)) .or. (.not. (x <= 5.1d-11))) 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 <= -3.25e+50) || !(x <= 5.1e-11)) {
tmp = -3.0 / x;
} else {
tmp = 1.0 + (x * 3.0);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -3.25e+50) or not (x <= 5.1e-11): tmp = -3.0 / x else: tmp = 1.0 + (x * 3.0) return tmp
function code(x) tmp = 0.0 if ((x <= -3.25e+50) || !(x <= 5.1e-11)) 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 <= -3.25e+50) || ~((x <= 5.1e-11))) tmp = -3.0 / x; else tmp = 1.0 + (x * 3.0); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -3.25e+50], N[Not[LessEqual[x, 5.1e-11]], $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 -3.25 \cdot 10^{+50} \lor \neg \left(x \leq 5.1 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot 3\\
\end{array}
\end{array}
if x < -3.2500000000000001e50 or 5.09999999999999984e-11 < x Initial program 9.0%
remove-double-neg9.0%
distribute-neg-frac9.0%
distribute-neg-in9.0%
sub-neg9.0%
distribute-frac-neg29.0%
sub-neg9.0%
+-commutative9.0%
unsub-neg9.0%
metadata-eval9.0%
neg-sub09.0%
associate-+l-9.0%
neg-sub09.0%
+-commutative9.0%
unsub-neg9.0%
Simplified9.0%
Taylor expanded in x around inf 97.1%
if -3.2500000000000001e50 < x < 5.09999999999999984e-11Initial program 98.0%
remove-double-neg98.0%
distribute-neg-frac98.0%
distribute-neg-in98.0%
sub-neg98.0%
distribute-frac-neg298.0%
sub-neg98.0%
+-commutative98.0%
unsub-neg98.0%
metadata-eval98.0%
neg-sub098.0%
associate-+l-98.0%
neg-sub098.0%
+-commutative98.0%
unsub-neg98.0%
Simplified98.0%
Taylor expanded in x around 0 95.4%
Final simplification96.3%
(FPCore (x) :precision binary64 (* (+ (/ 1.0 x) 3.0) (/ (/ x (+ 1.0 x)) (- 1.0 x))))
double code(double x) {
return ((1.0 / x) + 3.0) * ((x / (1.0 + x)) / (1.0 - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / x) + 3.0d0) * ((x / (1.0d0 + x)) / (1.0d0 - x))
end function
public static double code(double x) {
return ((1.0 / x) + 3.0) * ((x / (1.0 + x)) / (1.0 - x));
}
def code(x): return ((1.0 / x) + 3.0) * ((x / (1.0 + x)) / (1.0 - x))
function code(x) return Float64(Float64(Float64(1.0 / x) + 3.0) * Float64(Float64(x / Float64(1.0 + x)) / Float64(1.0 - x))) end
function tmp = code(x) tmp = ((1.0 / x) + 3.0) * ((x / (1.0 + x)) / (1.0 - x)); end
code[x_] := N[(N[(N[(1.0 / x), $MachinePrecision] + 3.0), $MachinePrecision] * N[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{x} + 3\right) \cdot \frac{\frac{x}{1 + x}}{1 - x}
\end{array}
Initial program 54.5%
remove-double-neg54.5%
distribute-neg-frac54.5%
distribute-neg-in54.5%
sub-neg54.5%
distribute-frac-neg254.5%
sub-neg54.5%
+-commutative54.5%
unsub-neg54.5%
metadata-eval54.5%
neg-sub054.5%
associate-+l-54.5%
neg-sub054.5%
+-commutative54.5%
unsub-neg54.5%
Simplified54.5%
clear-num54.5%
frac-sub54.6%
*-un-lft-identity54.6%
Applied egg-rr54.6%
Taylor expanded in x around inf 100.0%
+-commutative100.0%
Simplified100.0%
clear-num99.8%
associate-/r/99.7%
associate-/r*99.7%
clear-num99.7%
+-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (or (<= x -3.25e+50) (not (<= x 5.1e-11))) (/ -3.0 x) 1.0))
double code(double x) {
double tmp;
if ((x <= -3.25e+50) || !(x <= 5.1e-11)) {
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 <= (-3.25d+50)) .or. (.not. (x <= 5.1d-11))) 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 <= -3.25e+50) || !(x <= 5.1e-11)) {
tmp = -3.0 / x;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -3.25e+50) or not (x <= 5.1e-11): tmp = -3.0 / x else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if ((x <= -3.25e+50) || !(x <= 5.1e-11)) tmp = Float64(-3.0 / x); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -3.25e+50) || ~((x <= 5.1e-11))) tmp = -3.0 / x; else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -3.25e+50], N[Not[LessEqual[x, 5.1e-11]], $MachinePrecision]], N[(-3.0 / x), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.25 \cdot 10^{+50} \lor \neg \left(x \leq 5.1 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{-3}{x}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -3.2500000000000001e50 or 5.09999999999999984e-11 < x Initial program 9.0%
remove-double-neg9.0%
distribute-neg-frac9.0%
distribute-neg-in9.0%
sub-neg9.0%
distribute-frac-neg29.0%
sub-neg9.0%
+-commutative9.0%
unsub-neg9.0%
metadata-eval9.0%
neg-sub09.0%
associate-+l-9.0%
neg-sub09.0%
+-commutative9.0%
unsub-neg9.0%
Simplified9.0%
Taylor expanded in x around inf 97.1%
if -3.2500000000000001e50 < x < 5.09999999999999984e-11Initial program 98.0%
remove-double-neg98.0%
distribute-neg-frac98.0%
distribute-neg-in98.0%
sub-neg98.0%
distribute-frac-neg298.0%
sub-neg98.0%
+-commutative98.0%
unsub-neg98.0%
metadata-eval98.0%
neg-sub098.0%
associate-+l-98.0%
neg-sub098.0%
+-commutative98.0%
unsub-neg98.0%
Simplified98.0%
Taylor expanded in x around 0 94.7%
Final simplification95.9%
(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.5%
remove-double-neg54.5%
distribute-neg-frac54.5%
distribute-neg-in54.5%
sub-neg54.5%
distribute-frac-neg254.5%
sub-neg54.5%
+-commutative54.5%
unsub-neg54.5%
metadata-eval54.5%
neg-sub054.5%
associate-+l-54.5%
neg-sub054.5%
+-commutative54.5%
unsub-neg54.5%
Simplified54.5%
Taylor expanded in x around 0 50.4%
herbie shell --seed 2024107
(FPCore (x)
:name "Asymptote C"
:precision binary64
(- (/ x (+ x 1.0)) (/ (+ x 1.0) (- x 1.0))))