| 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
(if (<= t -0.42)
0.8333333333333334
(if (<= t 0.75)
(/ (+ 1.0 (* (/ (+ t t) (+ t 1.0)) (* t 2.0))) (+ 2.0 (* 4.0 (* t t))))
(- 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 tmp;
if (t <= -0.42) {
tmp = 0.8333333333333334;
} else if (t <= 0.75) {
tmp = (1.0 + (((t + t) / (t + 1.0)) * (t * 2.0))) / (2.0 + (4.0 * (t * t)));
} 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) :: tmp
if (t <= (-0.42d0)) then
tmp = 0.8333333333333334d0
else if (t <= 0.75d0) then
tmp = (1.0d0 + (((t + t) / (t + 1.0d0)) * (t * 2.0d0))) / (2.0d0 + (4.0d0 * (t * t)))
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 tmp;
if (t <= -0.42) {
tmp = 0.8333333333333334;
} else if (t <= 0.75) {
tmp = (1.0 + (((t + t) / (t + 1.0)) * (t * 2.0))) / (2.0 + (4.0 * (t * t)));
} 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): tmp = 0 if t <= -0.42: tmp = 0.8333333333333334 elif t <= 0.75: tmp = (1.0 + (((t + t) / (t + 1.0)) * (t * 2.0))) / (2.0 + (4.0 * (t * t))) 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) tmp = 0.0 if (t <= -0.42) tmp = 0.8333333333333334; elseif (t <= 0.75) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(t + t) / Float64(t + 1.0)) * Float64(t * 2.0))) / Float64(2.0 + Float64(4.0 * Float64(t * t)))); 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) tmp = 0.0; if (t <= -0.42) tmp = 0.8333333333333334; elseif (t <= 0.75) tmp = (1.0 + (((t + t) / (t + 1.0)) * (t * 2.0))) / (2.0 + (4.0 * (t * t))); 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_] := If[LessEqual[t, -0.42], 0.8333333333333334, If[LessEqual[t, 0.75], N[(N[(1.0 + N[(N[(N[(t + t), $MachinePrecision] / N[(t + 1.0), $MachinePrecision]), $MachinePrecision] * N[(t * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 + N[(4.0 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;t \leq -0.42:\\
\;\;\;\;0.8333333333333334\\
\mathbf{elif}\;t \leq 0.75:\\
\;\;\;\;\frac{1 + \frac{t + t}{t + 1} \cdot \left(t \cdot 2\right)}{2 + 4 \cdot \left(t \cdot t\right)}\\
\mathbf{else}:\\
\;\;\;\;0.8333333333333334 - \frac{0.2222222222222222}{t}\\
\end{array}
Results
if t < -0.419999999999999984Initial program 0.1
Taylor expanded in t around inf 1.4
if -0.419999999999999984 < t < 0.75Initial program 0.0
Taylor expanded in t around 0 0.4
Taylor expanded in t around 0 0.4
Taylor expanded in t around 0 0.3
Applied egg-rr0.3
Simplified0.3
[Start]0.3 | \[ \frac{1 + 2 \cdot \left(t \cdot \frac{t + t}{1 + t}\right)}{2 + t \cdot \left(t \cdot 4\right)} + 0
\] |
|---|---|
rational_best-simplify-4 [=>]0.3 | \[ \color{blue}{\frac{1 + 2 \cdot \left(t \cdot \frac{t + t}{1 + t}\right)}{2 + t \cdot \left(t \cdot 4\right)}}
\] |
rational_best-simplify-2 [=>]0.3 | \[ \frac{1 + 2 \cdot \color{blue}{\left(\frac{t + t}{1 + t} \cdot t\right)}}{2 + t \cdot \left(t \cdot 4\right)}
\] |
rational_best-simplify-44 [=>]0.3 | \[ \frac{1 + \color{blue}{\frac{t + t}{1 + t} \cdot \left(2 \cdot t\right)}}{2 + t \cdot \left(t \cdot 4\right)}
\] |
rational_best-simplify-1 [=>]0.3 | \[ \frac{1 + \frac{t + t}{\color{blue}{t + 1}} \cdot \left(2 \cdot t\right)}{2 + t \cdot \left(t \cdot 4\right)}
\] |
rational_best-simplify-2 [=>]0.3 | \[ \frac{1 + \frac{t + t}{t + 1} \cdot \color{blue}{\left(t \cdot 2\right)}}{2 + t \cdot \left(t \cdot 4\right)}
\] |
rational_best-simplify-2 [=>]0.3 | \[ \frac{1 + \frac{t + t}{t + 1} \cdot \left(t \cdot 2\right)}{2 + t \cdot \color{blue}{\left(4 \cdot t\right)}}
\] |
rational_best-simplify-44 [=>]0.3 | \[ \frac{1 + \frac{t + t}{t + 1} \cdot \left(t \cdot 2\right)}{2 + \color{blue}{4 \cdot \left(t \cdot t\right)}}
\] |
if 0.75 < t Initial program 0.1
Taylor expanded in t around inf 0.5
Simplified0.5
[Start]0.5 | \[ 0.8333333333333334 - 0.2222222222222222 \cdot \frac{1}{t}
\] |
|---|---|
rational_best-simplify-2 [=>]0.5 | \[ 0.8333333333333334 - \color{blue}{\frac{1}{t} \cdot 0.2222222222222222}
\] |
Taylor expanded in t around 0 0.5
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 2240 |
| Alternative 2 | |
|---|---|
| Error | 0.7 |
| Cost | 1480 |
| Alternative 3 | |
|---|---|
| Error | 0.8 |
| Cost | 584 |
| Alternative 4 | |
|---|---|
| Error | 0.9 |
| Cost | 328 |
| Alternative 5 | |
|---|---|
| Error | 26.4 |
| Cost | 64 |
herbie shell --seed 2023092
(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))))))