?

Average Accuracy: 99.9% → 98.9%
Time: 4.8s
Precision: binary64
Cost: 584

?

\[\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.8:\\ \;\;\;\;0.8333333333333334 - \frac{0.2222222222222222}{t}\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334\\ \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.8)
   (- 0.8333333333333334 (/ 0.2222222222222222 t))
   (if (<= t 0.58) (+ (* t t) 0.5) 0.8333333333333334)))
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.8) {
		tmp = 0.8333333333333334 - (0.2222222222222222 / t);
	} else if (t <= 0.58) {
		tmp = (t * t) + 0.5;
	} else {
		tmp = 0.8333333333333334;
	}
	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.8d0)) then
        tmp = 0.8333333333333334d0 - (0.2222222222222222d0 / t)
    else if (t <= 0.58d0) then
        tmp = (t * t) + 0.5d0
    else
        tmp = 0.8333333333333334d0
    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.8) {
		tmp = 0.8333333333333334 - (0.2222222222222222 / t);
	} else if (t <= 0.58) {
		tmp = (t * t) + 0.5;
	} else {
		tmp = 0.8333333333333334;
	}
	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.8:
		tmp = 0.8333333333333334 - (0.2222222222222222 / t)
	elif t <= 0.58:
		tmp = (t * t) + 0.5
	else:
		tmp = 0.8333333333333334
	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.8)
		tmp = Float64(0.8333333333333334 - Float64(0.2222222222222222 / t));
	elseif (t <= 0.58)
		tmp = Float64(Float64(t * t) + 0.5);
	else
		tmp = 0.8333333333333334;
	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.8)
		tmp = 0.8333333333333334 - (0.2222222222222222 / t);
	elseif (t <= 0.58)
		tmp = (t * t) + 0.5;
	else
		tmp = 0.8333333333333334;
	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.8], N[(0.8333333333333334 - N[(0.2222222222222222 / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 0.58], N[(N[(t * t), $MachinePrecision] + 0.5), $MachinePrecision], 0.8333333333333334]]
\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.8:\\
\;\;\;\;0.8333333333333334 - \frac{0.2222222222222222}{t}\\

\mathbf{elif}\;t \leq 0.58:\\
\;\;\;\;t \cdot t + 0.5\\

\mathbf{else}:\\
\;\;\;\;0.8333333333333334\\


\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.80000000000000004

    1. Initial program 100.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. Simplified99.8%

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

      [Start]100.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}} \]

      associate-/l* [=>]100.0

      \[ \frac{1 + \frac{2 \cdot t}{1 + t} \cdot \color{blue}{\frac{2}{\frac{1 + t}{t}}}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-*r/ [=>]100.0

      \[ \frac{1 + \color{blue}{\frac{\frac{2 \cdot t}{1 + t} \cdot 2}{\frac{1 + t}{t}}}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-/r/ [=>]100.0

      \[ \frac{1 + \color{blue}{\frac{\frac{2 \cdot t}{1 + t} \cdot 2}{1 + t} \cdot t}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-*l/ [<=]100.0

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

      *-commutative [=>]100.0

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

      associate-*r/ [=>]100.0

      \[ \frac{1 + \color{blue}{\frac{2 \cdot \frac{2 \cdot t}{1 + t}}{1 + t}} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      *-commutative [=>]100.0

      \[ \frac{1 + \frac{\color{blue}{\frac{2 \cdot t}{1 + t} \cdot 2}}{1 + t} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-*l/ [=>]99.8

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

      *-commutative [=>]99.8

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

      associate-*l* [=>]99.8

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

      metadata-eval [=>]99.8

      \[ \frac{1 + \frac{\frac{t \cdot \color{blue}{4}}{1 + t}}{1 + t} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-/l* [=>]99.8

      \[ \frac{1 + \frac{\frac{t \cdot 4}{1 + t}}{1 + t} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \color{blue}{\frac{2}{\frac{1 + t}{t}}}} \]
    3. Taylor expanded in t around inf 99.2%

      \[\leadsto \color{blue}{0.8333333333333334 - 0.2222222222222222 \cdot \frac{1}{t}} \]
    4. Simplified99.2%

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

      [Start]99.2

      \[ 0.8333333333333334 - 0.2222222222222222 \cdot \frac{1}{t} \]

      associate-*r/ [=>]99.2

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

      metadata-eval [=>]99.2

      \[ 0.8333333333333334 - \frac{\color{blue}{0.2222222222222222}}{t} \]

    if -0.80000000000000004 < t < 0.57999999999999996

    1. Initial program 100.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. Simplified100.0%

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

      [Start]100.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}} \]

      associate-/l* [=>]100.0

      \[ \frac{1 + \frac{2 \cdot t}{1 + t} \cdot \color{blue}{\frac{2}{\frac{1 + t}{t}}}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-*r/ [=>]100.0

      \[ \frac{1 + \color{blue}{\frac{\frac{2 \cdot t}{1 + t} \cdot 2}{\frac{1 + t}{t}}}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-/r/ [=>]100.0

      \[ \frac{1 + \color{blue}{\frac{\frac{2 \cdot t}{1 + t} \cdot 2}{1 + t} \cdot t}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-*l/ [<=]100.0

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

      *-commutative [=>]100.0

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

      associate-*r/ [=>]100.0

      \[ \frac{1 + \color{blue}{\frac{2 \cdot \frac{2 \cdot t}{1 + t}}{1 + t}} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      *-commutative [=>]100.0

      \[ \frac{1 + \frac{\color{blue}{\frac{2 \cdot t}{1 + t} \cdot 2}}{1 + t} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-*l/ [=>]100.0

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

      *-commutative [=>]100.0

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

      associate-*l* [=>]100.0

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

      metadata-eval [=>]100.0

      \[ \frac{1 + \frac{\frac{t \cdot \color{blue}{4}}{1 + t}}{1 + t} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-/l* [=>]100.0

      \[ \frac{1 + \frac{\frac{t \cdot 4}{1 + t}}{1 + t} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \color{blue}{\frac{2}{\frac{1 + t}{t}}}} \]
    3. Taylor expanded in t around 0 99.4%

      \[\leadsto \color{blue}{0.5 + {t}^{2}} \]
    4. Simplified99.4%

      \[\leadsto \color{blue}{t \cdot t + 0.5} \]
      Proof

      [Start]99.4

      \[ 0.5 + {t}^{2} \]

      +-commutative [=>]99.4

      \[ \color{blue}{{t}^{2} + 0.5} \]

      unpow2 [=>]99.4

      \[ \color{blue}{t \cdot t} + 0.5 \]

    if 0.57999999999999996 < t

    1. Initial program 99.8%

      \[\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. Simplified99.8%

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

      [Start]99.8

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

      associate-/l* [=>]99.8

      \[ \frac{1 + \frac{2 \cdot t}{1 + t} \cdot \color{blue}{\frac{2}{\frac{1 + t}{t}}}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-*r/ [=>]99.8

      \[ \frac{1 + \color{blue}{\frac{\frac{2 \cdot t}{1 + t} \cdot 2}{\frac{1 + t}{t}}}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-/r/ [=>]99.8

      \[ \frac{1 + \color{blue}{\frac{\frac{2 \cdot t}{1 + t} \cdot 2}{1 + t} \cdot t}}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-*l/ [<=]99.8

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

      *-commutative [=>]99.8

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

      associate-*r/ [=>]99.8

      \[ \frac{1 + \color{blue}{\frac{2 \cdot \frac{2 \cdot t}{1 + t}}{1 + t}} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      *-commutative [=>]99.8

      \[ \frac{1 + \frac{\color{blue}{\frac{2 \cdot t}{1 + t} \cdot 2}}{1 + t} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-*l/ [=>]99.8

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

      *-commutative [=>]99.8

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

      associate-*l* [=>]99.8

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

      metadata-eval [=>]99.8

      \[ \frac{1 + \frac{\frac{t \cdot \color{blue}{4}}{1 + t}}{1 + t} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}} \]

      associate-/l* [=>]99.8

      \[ \frac{1 + \frac{\frac{t \cdot 4}{1 + t}}{1 + t} \cdot t}{2 + \frac{2 \cdot t}{1 + t} \cdot \color{blue}{\frac{2}{\frac{1 + t}{t}}}} \]
    3. Taylor expanded in t around inf 97.4%

      \[\leadsto \color{blue}{0.8333333333333334} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -0.8:\\ \;\;\;\;0.8333333333333334 - \frac{0.2222222222222222}{t}\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.9%
Cost1984
\[\begin{array}{l} t_1 := t \cdot \frac{\frac{t \cdot 4}{1 + t}}{1 + t}\\ \frac{1 + t_1}{t_1 + 2} \end{array} \]
Alternative 2
Accuracy98.6%
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -0.92:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334\\ \end{array} \]
Alternative 3
Accuracy98.4%
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 4
Accuracy59.3%
Cost64
\[0.5 \]

Error

Reproduce?

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