| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 2240 |
\[\begin{array}{l}
t_1 := \frac{2 \cdot t}{1 + t}\\
t_2 := t_1 \cdot t_1\\
\frac{1 + t_2}{2 + t_2}
\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 (/ (/ (* 4.0 (* t t)) (+ 1.0 t)) (+ 1.0 t))))
(if (<= t -2.3403016542663982e+154)
0.8333333333333334
(if (<= t 1443494.361181734)
(/ (+ 1.0 t_1) (+ 2.0 t_1))
(+ 0.8333333333333334 (+ 1.0 (+ (/ -0.2222222222222222 t) -1.0)))))))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 = ((4.0 * (t * t)) / (1.0 + t)) / (1.0 + t);
double tmp;
if (t <= -2.3403016542663982e+154) {
tmp = 0.8333333333333334;
} else if (t <= 1443494.361181734) {
tmp = (1.0 + t_1) / (2.0 + t_1);
} else {
tmp = 0.8333333333333334 + (1.0 + ((-0.2222222222222222 / t) + -1.0));
}
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 = ((4.0d0 * (t * t)) / (1.0d0 + t)) / (1.0d0 + t)
if (t <= (-2.3403016542663982d+154)) then
tmp = 0.8333333333333334d0
else if (t <= 1443494.361181734d0) then
tmp = (1.0d0 + t_1) / (2.0d0 + t_1)
else
tmp = 0.8333333333333334d0 + (1.0d0 + (((-0.2222222222222222d0) / t) + (-1.0d0)))
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 = ((4.0 * (t * t)) / (1.0 + t)) / (1.0 + t);
double tmp;
if (t <= -2.3403016542663982e+154) {
tmp = 0.8333333333333334;
} else if (t <= 1443494.361181734) {
tmp = (1.0 + t_1) / (2.0 + t_1);
} else {
tmp = 0.8333333333333334 + (1.0 + ((-0.2222222222222222 / t) + -1.0));
}
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 = ((4.0 * (t * t)) / (1.0 + t)) / (1.0 + t) tmp = 0 if t <= -2.3403016542663982e+154: tmp = 0.8333333333333334 elif t <= 1443494.361181734: tmp = (1.0 + t_1) / (2.0 + t_1) else: tmp = 0.8333333333333334 + (1.0 + ((-0.2222222222222222 / t) + -1.0)) 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(Float64(Float64(4.0 * Float64(t * t)) / Float64(1.0 + t)) / Float64(1.0 + t)) tmp = 0.0 if (t <= -2.3403016542663982e+154) tmp = 0.8333333333333334; elseif (t <= 1443494.361181734) tmp = Float64(Float64(1.0 + t_1) / Float64(2.0 + t_1)); else tmp = Float64(0.8333333333333334 + Float64(1.0 + Float64(Float64(-0.2222222222222222 / t) + -1.0))); 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 = ((4.0 * (t * t)) / (1.0 + t)) / (1.0 + t); tmp = 0.0; if (t <= -2.3403016542663982e+154) tmp = 0.8333333333333334; elseif (t <= 1443494.361181734) tmp = (1.0 + t_1) / (2.0 + t_1); else tmp = 0.8333333333333334 + (1.0 + ((-0.2222222222222222 / t) + -1.0)); 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[(N[(N[(4.0 * N[(t * t), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -2.3403016542663982e+154], 0.8333333333333334, If[LessEqual[t, 1443494.361181734], N[(N[(1.0 + t$95$1), $MachinePrecision] / N[(2.0 + t$95$1), $MachinePrecision]), $MachinePrecision], N[(0.8333333333333334 + N[(1.0 + N[(N[(-0.2222222222222222 / t), $MachinePrecision] + -1.0), $MachinePrecision]), $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 := \frac{\frac{4 \cdot \left(t \cdot t\right)}{1 + t}}{1 + t}\\
\mathbf{if}\;t \leq -2.3403016542663982 \cdot 10^{+154}:\\
\;\;\;\;0.8333333333333334\\
\mathbf{elif}\;t \leq 1443494.361181734:\\
\;\;\;\;\frac{1 + t_1}{2 + t_1}\\
\mathbf{else}:\\
\;\;\;\;0.8333333333333334 + \left(1 + \left(\frac{-0.2222222222222222}{t} + -1\right)\right)\\
\end{array}
Results
if t < -2.34030165426639823e154Initial program 0.2
Taylor expanded in t around inf 0
Simplified0
Applied egg-rr0
Applied egg-rr1.0
Taylor expanded in t around inf 0
if -2.34030165426639823e154 < t < 1443494.3611817339Initial program 0.0
Applied egg-rr0.1
Applied egg-rr0.1
if 1443494.3611817339 < t Initial program 0.0
Taylor expanded in t around inf 0.0
Simplified0.0
Applied egg-rr0.0
Applied egg-rr0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 2240 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 2120 |
| Alternative 3 | |
|---|---|
| Error | 0.4 |
| Cost | 1992 |
| Alternative 4 | |
|---|---|
| Error | 0.4 |
| Cost | 1736 |
| Alternative 5 | |
|---|---|
| Error | 0.5 |
| Cost | 1480 |
| Alternative 6 | |
|---|---|
| Error | 0.6 |
| Cost | 1096 |
| Alternative 7 | |
|---|---|
| Error | 0.6 |
| Cost | 968 |
| Alternative 8 | |
|---|---|
| Error | 0.7 |
| Cost | 840 |
| Alternative 9 | |
|---|---|
| Error | 0.7 |
| Cost | 712 |
| Alternative 10 | |
|---|---|
| Error | 0.7 |
| Cost | 584 |
| Alternative 11 | |
|---|---|
| Error | 0.9 |
| Cost | 328 |
| Alternative 12 | |
|---|---|
| Error | 26.0 |
| Cost | 64 |

herbie shell --seed 2022295
(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))))))