?

Average Error: 0.0 → 0.6
Time: 8.5s
Precision: binary64
Cost: 1608

?

\[\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} \]
(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}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 3 regimes
  2. if t < -0.419999999999999984

    1. Initial program 0.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}} \]
    2. Taylor expanded in t around inf 1.4

      \[\leadsto \color{blue}{0.8333333333333334} \]

    if -0.419999999999999984 < t < 0.75

    1. Initial program 0.0

      \[\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}} \]
    2. Taylor expanded in t around 0 0.4

      \[\leadsto \frac{1 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}}{2 + \frac{2 \cdot t}{1 + t} \cdot \color{blue}{\left(2 \cdot t\right)}} \]
    3. Taylor expanded in t around 0 0.4

      \[\leadsto \frac{1 + \frac{2 \cdot t}{1 + t} \cdot \color{blue}{\left(2 \cdot t\right)}}{2 + \frac{2 \cdot t}{1 + t} \cdot \left(2 \cdot t\right)} \]
    4. Taylor expanded in t around 0 0.3

      \[\leadsto \frac{1 + \frac{2 \cdot t}{1 + t} \cdot \left(2 \cdot t\right)}{2 + \color{blue}{\left(2 \cdot t\right)} \cdot \left(2 \cdot t\right)} \]
    5. Applied egg-rr0.3

      \[\leadsto \color{blue}{\frac{1 + 2 \cdot \left(t \cdot \frac{t + t}{1 + t}\right)}{2 + t \cdot \left(t \cdot 4\right)} + 0} \]
    6. Simplified0.3

      \[\leadsto \color{blue}{\frac{1 + \frac{t + t}{t + 1} \cdot \left(t \cdot 2\right)}{2 + 4 \cdot \left(t \cdot t\right)}} \]
      Proof

      [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

    1. Initial program 0.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}} \]
    2. Taylor expanded in t around inf 0.5

      \[\leadsto \color{blue}{0.8333333333333334 - 0.2222222222222222 \cdot \frac{1}{t}} \]
    3. Simplified0.5

      \[\leadsto \color{blue}{0.8333333333333334 - \frac{1}{t} \cdot 0.2222222222222222} \]
      Proof

      [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} \]
    4. Taylor expanded in t around 0 0.5

      \[\leadsto 0.8333333333333334 - \color{blue}{\frac{0.2222222222222222}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \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} \]

Alternatives

Alternative 1
Error0.0
Cost2240
\[\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} \]
Alternative 2
Error0.7
Cost1480
\[\begin{array}{l} t_1 := \left(2 \cdot t\right) \cdot \left(2 \cdot t\right)\\ \mathbf{if}\;t \leq -0.39:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 0.7:\\ \;\;\;\;\frac{1 + t_1}{2 + t_1}\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334 - \frac{0.2222222222222222}{t}\\ \end{array} \]
Alternative 3
Error0.8
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -0.33:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 0.66:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334 - \frac{0.2222222222222222}{t}\\ \end{array} \]
Alternative 4
Error0.9
Cost328
\[\begin{array}{l} \mathbf{if}\;t \leq -0.33:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 1:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334\\ \end{array} \]
Alternative 5
Error26.4
Cost64
\[0.5 \]

Error

Reproduce?

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))))))