| Alternative 1 | |
|---|---|
| Error | 0.17% |
| Cost | 2368 |
\[\begin{array}{l}
t_1 := \frac{2 \cdot t}{t + 1}\\
\frac{\left(2 + \frac{\left(2 \cdot \frac{t}{t + 1}\right) \cdot \left(2 \cdot t\right)}{t + 1}\right) + -1}{2 + t_1 \cdot t_1}
\end{array}
\]
(FPCore (t) :precision binary64 (/ (+ 1.0 (* (/ (* 2.0 t) (+ 1.0 t)) (/ (* 2.0 t) (+ 1.0 t)))) (+ 2.0 (* (/ (* 2.0 t) (+ 1.0 t)) (/ (* 2.0 t) (+ 1.0 t))))))
(FPCore (t)
:precision binary64
(let* ((t_1 (+ 2.0 (/ (/ (* (* t t) 4.0) (+ t 1.0)) (+ t 1.0)))))
(if (<= t -1e+154)
0.8333333333333334
(if (<= t 20000.0)
(/ (+ t_1 -1.0) t_1)
(+ 0.8333333333333334 (/ -0.2222222222222222 t))))))double code(double t) {
return (1.0 + (((2.0 * t) / (1.0 + t)) * ((2.0 * t) / (1.0 + t)))) / (2.0 + (((2.0 * t) / (1.0 + t)) * ((2.0 * t) / (1.0 + t))));
}
double code(double t) {
double t_1 = 2.0 + ((((t * t) * 4.0) / (t + 1.0)) / (t + 1.0));
double tmp;
if (t <= -1e+154) {
tmp = 0.8333333333333334;
} else if (t <= 20000.0) {
tmp = (t_1 + -1.0) / t_1;
} else {
tmp = 0.8333333333333334 + (-0.2222222222222222 / t);
}
return tmp;
}
real(8) function code(t)
real(8), intent (in) :: t
code = (1.0d0 + (((2.0d0 * t) / (1.0d0 + t)) * ((2.0d0 * t) / (1.0d0 + t)))) / (2.0d0 + (((2.0d0 * t) / (1.0d0 + t)) * ((2.0d0 * t) / (1.0d0 + t))))
end function
real(8) function code(t)
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = 2.0d0 + ((((t * t) * 4.0d0) / (t + 1.0d0)) / (t + 1.0d0))
if (t <= (-1d+154)) then
tmp = 0.8333333333333334d0
else if (t <= 20000.0d0) then
tmp = (t_1 + (-1.0d0)) / t_1
else
tmp = 0.8333333333333334d0 + ((-0.2222222222222222d0) / t)
end if
code = tmp
end function
public static double code(double t) {
return (1.0 + (((2.0 * t) / (1.0 + t)) * ((2.0 * t) / (1.0 + t)))) / (2.0 + (((2.0 * t) / (1.0 + t)) * ((2.0 * t) / (1.0 + t))));
}
public static double code(double t) {
double t_1 = 2.0 + ((((t * t) * 4.0) / (t + 1.0)) / (t + 1.0));
double tmp;
if (t <= -1e+154) {
tmp = 0.8333333333333334;
} else if (t <= 20000.0) {
tmp = (t_1 + -1.0) / t_1;
} else {
tmp = 0.8333333333333334 + (-0.2222222222222222 / t);
}
return tmp;
}
def code(t): return (1.0 + (((2.0 * t) / (1.0 + t)) * ((2.0 * t) / (1.0 + t)))) / (2.0 + (((2.0 * t) / (1.0 + t)) * ((2.0 * t) / (1.0 + t))))
def code(t): t_1 = 2.0 + ((((t * t) * 4.0) / (t + 1.0)) / (t + 1.0)) tmp = 0 if t <= -1e+154: tmp = 0.8333333333333334 elif t <= 20000.0: tmp = (t_1 + -1.0) / t_1 else: tmp = 0.8333333333333334 + (-0.2222222222222222 / t) return tmp
function code(t) return Float64(Float64(1.0 + Float64(Float64(Float64(2.0 * t) / Float64(1.0 + t)) * Float64(Float64(2.0 * t) / Float64(1.0 + t)))) / Float64(2.0 + Float64(Float64(Float64(2.0 * t) / Float64(1.0 + t)) * Float64(Float64(2.0 * t) / Float64(1.0 + t))))) end
function code(t) t_1 = Float64(2.0 + Float64(Float64(Float64(Float64(t * t) * 4.0) / Float64(t + 1.0)) / Float64(t + 1.0))) tmp = 0.0 if (t <= -1e+154) tmp = 0.8333333333333334; elseif (t <= 20000.0) tmp = Float64(Float64(t_1 + -1.0) / t_1); else tmp = Float64(0.8333333333333334 + Float64(-0.2222222222222222 / t)); end return tmp end
function tmp = code(t) tmp = (1.0 + (((2.0 * t) / (1.0 + t)) * ((2.0 * t) / (1.0 + t)))) / (2.0 + (((2.0 * t) / (1.0 + t)) * ((2.0 * t) / (1.0 + t)))); end
function tmp_2 = code(t) t_1 = 2.0 + ((((t * t) * 4.0) / (t + 1.0)) / (t + 1.0)); tmp = 0.0; if (t <= -1e+154) tmp = 0.8333333333333334; elseif (t <= 20000.0) tmp = (t_1 + -1.0) / t_1; else tmp = 0.8333333333333334 + (-0.2222222222222222 / t); end tmp_2 = tmp; end
code[t_] := N[(N[(1.0 + N[(N[(N[(2.0 * t), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * t), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 + N[(N[(N[(2.0 * t), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * t), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[t_] := Block[{t$95$1 = N[(2.0 + N[(N[(N[(N[(t * t), $MachinePrecision] * 4.0), $MachinePrecision] / N[(t + 1.0), $MachinePrecision]), $MachinePrecision] / N[(t + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1e+154], 0.8333333333333334, If[LessEqual[t, 20000.0], N[(N[(t$95$1 + -1.0), $MachinePrecision] / t$95$1), $MachinePrecision], N[(0.8333333333333334 + N[(-0.2222222222222222 / t), $MachinePrecision]), $MachinePrecision]]]]
\frac{1 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}}
\begin{array}{l}
t_1 := 2 + \frac{\frac{\left(t \cdot t\right) \cdot 4}{t + 1}}{t + 1}\\
\mathbf{if}\;t \leq -1 \cdot 10^{+154}:\\
\;\;\;\;0.8333333333333334\\
\mathbf{elif}\;t \leq 20000:\\
\;\;\;\;\frac{t_1 + -1}{t_1}\\
\mathbf{else}:\\
\;\;\;\;0.8333333333333334 + \frac{-0.2222222222222222}{t}\\
\end{array}
Results
if t < -1.00000000000000004e154Initial program 0.1
Taylor expanded in t around inf 0
if -1.00000000000000004e154 < t < 2e4Initial program 0.02
Applied egg-rr0.09
Applied egg-rr0.02
Applied egg-rr0.06
Applied egg-rr0.03
if 2e4 < t Initial program 0.35
Taylor expanded in t around inf 0.14
Simplified0.14
[Start]0.14 | \[ 0.8333333333333334 - 0.2222222222222222 \cdot \frac{1}{t}
\] |
|---|---|
associate-*r/ [=>]0.14 | \[ 0.8333333333333334 - \color{blue}{\frac{0.2222222222222222 \cdot 1}{t}}
\] |
metadata-eval [=>]0.14 | \[ 0.8333333333333334 - \frac{\color{blue}{0.2222222222222222}}{t}
\] |
Final simplification0.05
| Alternative 1 | |
|---|---|
| Error | 0.17% |
| Cost | 2368 |
| Alternative 2 | |
|---|---|
| Error | 0.06% |
| Cost | 2248 |
| Alternative 3 | |
|---|---|
| Error | 0.11% |
| Cost | 2240 |
| Alternative 4 | |
|---|---|
| Error | 0.54% |
| Cost | 1736 |
| Alternative 5 | |
|---|---|
| Error | 0.54% |
| Cost | 1480 |
| Alternative 6 | |
|---|---|
| Error | 0.63% |
| Cost | 836 |
| Alternative 7 | |
|---|---|
| Error | 0.69% |
| Cost | 585 |
| Alternative 8 | |
|---|---|
| Error | 1.26% |
| Cost | 584 |
| Alternative 9 | |
|---|---|
| Error | 1.42% |
| Cost | 328 |
| Alternative 10 | |
|---|---|
| Error | 40.63% |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (t)
:name "Kahan p13 Example 1"
:precision binary64
(/ (+ 1.0 (* (/ (* 2.0 t) (+ 1.0 t)) (/ (* 2.0 t) (+ 1.0 t)))) (+ 2.0 (* (/ (* 2.0 t) (+ 1.0 t)) (/ (* 2.0 t) (+ 1.0 t))))))