| 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 (/ (/ (* t (* t 4.0)) (+ 1.0 t)) (+ 1.0 t))))
(if (<= t -2.4e+15)
0.8333333333333334
(if (<= t 100000000.0)
(/ (+ 1.0 t_1) (+ 2.0 t_1))
(/ (- 5.0 (/ 8.0 t)) (+ 6.0 (/ -8.0 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 = ((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t);
double tmp;
if (t <= -2.4e+15) {
tmp = 0.8333333333333334;
} else if (t <= 100000000.0) {
tmp = (1.0 + t_1) / (2.0 + t_1);
} else {
tmp = (5.0 - (8.0 / t)) / (6.0 + (-8.0 / 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 = ((t * (t * 4.0d0)) / (1.0d0 + t)) / (1.0d0 + t)
if (t <= (-2.4d+15)) then
tmp = 0.8333333333333334d0
else if (t <= 100000000.0d0) then
tmp = (1.0d0 + t_1) / (2.0d0 + t_1)
else
tmp = (5.0d0 - (8.0d0 / t)) / (6.0d0 + ((-8.0d0) / 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 = ((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t);
double tmp;
if (t <= -2.4e+15) {
tmp = 0.8333333333333334;
} else if (t <= 100000000.0) {
tmp = (1.0 + t_1) / (2.0 + t_1);
} else {
tmp = (5.0 - (8.0 / t)) / (6.0 + (-8.0 / 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 = ((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t) tmp = 0 if t <= -2.4e+15: tmp = 0.8333333333333334 elif t <= 100000000.0: tmp = (1.0 + t_1) / (2.0 + t_1) else: tmp = (5.0 - (8.0 / t)) / (6.0 + (-8.0 / 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(Float64(Float64(t * Float64(t * 4.0)) / Float64(1.0 + t)) / Float64(1.0 + t)) tmp = 0.0 if (t <= -2.4e+15) tmp = 0.8333333333333334; elseif (t <= 100000000.0) tmp = Float64(Float64(1.0 + t_1) / Float64(2.0 + t_1)); else tmp = Float64(Float64(5.0 - Float64(8.0 / t)) / Float64(6.0 + Float64(-8.0 / 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 = ((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t); tmp = 0.0; if (t <= -2.4e+15) tmp = 0.8333333333333334; elseif (t <= 100000000.0) tmp = (1.0 + t_1) / (2.0 + t_1); else tmp = (5.0 - (8.0 / t)) / (6.0 + (-8.0 / 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[(N[(N[(t * N[(t * 4.0), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -2.4e+15], 0.8333333333333334, If[LessEqual[t, 100000000.0], N[(N[(1.0 + t$95$1), $MachinePrecision] / N[(2.0 + t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(5.0 - N[(8.0 / t), $MachinePrecision]), $MachinePrecision] / N[(6.0 + N[(-8.0 / t), $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{t \cdot \left(t \cdot 4\right)}{1 + t}}{1 + t}\\
\mathbf{if}\;t \leq -2.4 \cdot 10^{+15}:\\
\;\;\;\;0.8333333333333334\\
\mathbf{elif}\;t \leq 100000000:\\
\;\;\;\;\frac{1 + t_1}{2 + t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{5 - \frac{8}{t}}{6 + \frac{-8}{t}}\\
\end{array}
Results
if t < -2.4e15Initial program 0.1
Taylor expanded in t around inf 0
if -2.4e15 < t < 1e8Initial program 0.0
Simplified0.0
if 1e8 < t Initial program 0.0
Simplified32.6
Taylor expanded in t around inf 32.6
Simplified32.6
Taylor expanded in t around inf 0.0
Simplified0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 2240 |
| Alternative 2 | |
|---|---|
| Error | 0.6 |
| Cost | 968 |
| Alternative 3 | |
|---|---|
| Error | 0.6 |
| Cost | 968 |
| Alternative 4 | |
|---|---|
| Error | 0.6 |
| Cost | 585 |
| Alternative 5 | |
|---|---|
| Error | 1.0 |
| Cost | 584 |
| Alternative 6 | |
|---|---|
| Error | 1.1 |
| Cost | 328 |
| Alternative 7 | |
|---|---|
| Error | 26.1 |
| Cost | 64 |
herbie shell --seed 2022343
(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))))))