| 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 (+ 0.8333333333333334 (/ -0.2222222222222222 t))))
(if (<= t -0.52)
(+ (/ 0.037037037037037035 (* t t)) t_1)
(if (<= t 0.58)
(/
(+ 1.0 (/ (/ (* (* t t) 4.0) (+ 1.0 t)) (+ 1.0 t)))
(+ 2.0 (* (* t t) (+ 4.0 (* t -8.0)))))
t_1))))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 = 0.8333333333333334 + (-0.2222222222222222 / t);
double tmp;
if (t <= -0.52) {
tmp = (0.037037037037037035 / (t * t)) + t_1;
} else if (t <= 0.58) {
tmp = (1.0 + ((((t * t) * 4.0) / (1.0 + t)) / (1.0 + t))) / (2.0 + ((t * t) * (4.0 + (t * -8.0))));
} else {
tmp = t_1;
}
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 = 0.8333333333333334d0 + ((-0.2222222222222222d0) / t)
if (t <= (-0.52d0)) then
tmp = (0.037037037037037035d0 / (t * t)) + t_1
else if (t <= 0.58d0) then
tmp = (1.0d0 + ((((t * t) * 4.0d0) / (1.0d0 + t)) / (1.0d0 + t))) / (2.0d0 + ((t * t) * (4.0d0 + (t * (-8.0d0)))))
else
tmp = t_1
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 = 0.8333333333333334 + (-0.2222222222222222 / t);
double tmp;
if (t <= -0.52) {
tmp = (0.037037037037037035 / (t * t)) + t_1;
} else if (t <= 0.58) {
tmp = (1.0 + ((((t * t) * 4.0) / (1.0 + t)) / (1.0 + t))) / (2.0 + ((t * t) * (4.0 + (t * -8.0))));
} else {
tmp = t_1;
}
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 = 0.8333333333333334 + (-0.2222222222222222 / t) tmp = 0 if t <= -0.52: tmp = (0.037037037037037035 / (t * t)) + t_1 elif t <= 0.58: tmp = (1.0 + ((((t * t) * 4.0) / (1.0 + t)) / (1.0 + t))) / (2.0 + ((t * t) * (4.0 + (t * -8.0)))) else: tmp = t_1 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(0.8333333333333334 + Float64(-0.2222222222222222 / t)) tmp = 0.0 if (t <= -0.52) tmp = Float64(Float64(0.037037037037037035 / Float64(t * t)) + t_1); elseif (t <= 0.58) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(Float64(t * t) * 4.0) / Float64(1.0 + t)) / Float64(1.0 + t))) / Float64(2.0 + Float64(Float64(t * t) * Float64(4.0 + Float64(t * -8.0))))); else tmp = t_1; 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 = 0.8333333333333334 + (-0.2222222222222222 / t); tmp = 0.0; if (t <= -0.52) tmp = (0.037037037037037035 / (t * t)) + t_1; elseif (t <= 0.58) tmp = (1.0 + ((((t * t) * 4.0) / (1.0 + t)) / (1.0 + t))) / (2.0 + ((t * t) * (4.0 + (t * -8.0)))); else tmp = t_1; 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[(0.8333333333333334 + N[(-0.2222222222222222 / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -0.52], N[(N[(0.037037037037037035 / N[(t * t), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[t, 0.58], N[(N[(1.0 + N[(N[(N[(N[(t * t), $MachinePrecision] * 4.0), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 + N[(N[(t * t), $MachinePrecision] * N[(4.0 + N[(t * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\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 := 0.8333333333333334 + \frac{-0.2222222222222222}{t}\\
\mathbf{if}\;t \leq -0.52:\\
\;\;\;\;\frac{0.037037037037037035}{t \cdot t} + t_1\\
\mathbf{elif}\;t \leq 0.58:\\
\;\;\;\;\frac{1 + \frac{\frac{\left(t \cdot t\right) \cdot 4}{1 + t}}{1 + t}}{2 + \left(t \cdot t\right) \cdot \left(4 + t \cdot -8\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
if t < -0.52000000000000002Initial program 0.0
Taylor expanded in t around inf 0.5
Simplified0.5
if -0.52000000000000002 < t < 0.57999999999999996Initial program 0.0
Taylor expanded in t around 0 0.3
Simplified0.3
Applied egg-rr0.3
if 0.57999999999999996 < t Initial program 0.1
Taylor expanded in t around inf 0.5
Simplified0.5
Final simplification0.4
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 2240 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 1736 |
| Alternative 3 | |
|---|---|
| Error | 0.4 |
| Cost | 1480 |
| Alternative 4 | |
|---|---|
| Error | 0.4 |
| Cost | 836 |
| Alternative 5 | |
|---|---|
| Error | 0.7 |
| Cost | 584 |
| Alternative 6 | |
|---|---|
| Error | 0.5 |
| Cost | 584 |
| Alternative 7 | |
|---|---|
| Error | 0.8 |
| Cost | 328 |
| Alternative 8 | |
|---|---|
| Error | 26.1 |
| Cost | 64 |
herbie shell --seed 2022329
(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))))))