Average Error: 0.0 → 0.0
Time: 9.7s
Precision: binary64
Cost: 2376
\[\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 -4 \cdot 10^{+154}:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 10000000:\\ \;\;\;\;\frac{1 + \frac{\frac{t \cdot \left(t \cdot 4\right)}{1 + t}}{1 + t}}{1 + \left(1 + \frac{\frac{\left(t \cdot t\right) \cdot -4}{1 + t}}{-1 - 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 -4e+154)
   0.8333333333333334
   (if (<= t 10000000.0)
     (/
      (+ 1.0 (/ (/ (* t (* t 4.0)) (+ 1.0 t)) (+ 1.0 t)))
      (+ 1.0 (+ 1.0 (/ (/ (* (* t t) -4.0) (+ 1.0 t)) (- -1.0 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 <= -4e+154) {
		tmp = 0.8333333333333334;
	} else if (t <= 10000000.0) {
		tmp = (1.0 + (((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t))) / (1.0 + (1.0 + ((((t * t) * -4.0) / (1.0 + t)) / (-1.0 - 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 <= (-4d+154)) then
        tmp = 0.8333333333333334d0
    else if (t <= 10000000.0d0) then
        tmp = (1.0d0 + (((t * (t * 4.0d0)) / (1.0d0 + t)) / (1.0d0 + t))) / (1.0d0 + (1.0d0 + ((((t * t) * (-4.0d0)) / (1.0d0 + t)) / ((-1.0d0) - 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 <= -4e+154) {
		tmp = 0.8333333333333334;
	} else if (t <= 10000000.0) {
		tmp = (1.0 + (((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t))) / (1.0 + (1.0 + ((((t * t) * -4.0) / (1.0 + t)) / (-1.0 - 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 <= -4e+154:
		tmp = 0.8333333333333334
	elif t <= 10000000.0:
		tmp = (1.0 + (((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t))) / (1.0 + (1.0 + ((((t * t) * -4.0) / (1.0 + t)) / (-1.0 - 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 <= -4e+154)
		tmp = 0.8333333333333334;
	elseif (t <= 10000000.0)
		tmp = Float64(Float64(1.0 + Float64(Float64(Float64(t * Float64(t * 4.0)) / Float64(1.0 + t)) / Float64(1.0 + t))) / Float64(1.0 + Float64(1.0 + Float64(Float64(Float64(Float64(t * t) * -4.0) / Float64(1.0 + t)) / Float64(-1.0 - 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 <= -4e+154)
		tmp = 0.8333333333333334;
	elseif (t <= 10000000.0)
		tmp = (1.0 + (((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t))) / (1.0 + (1.0 + ((((t * t) * -4.0) / (1.0 + t)) / (-1.0 - 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, -4e+154], 0.8333333333333334, If[LessEqual[t, 10000000.0], N[(N[(1.0 + N[(N[(N[(t * N[(t * 4.0), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + 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]), $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 -4 \cdot 10^{+154}:\\
\;\;\;\;0.8333333333333334\\

\mathbf{elif}\;t \leq 10000000:\\
\;\;\;\;\frac{1 + \frac{\frac{t \cdot \left(t \cdot 4\right)}{1 + t}}{1 + t}}{1 + \left(1 + \frac{\frac{\left(t \cdot t\right) \cdot -4}{1 + t}}{-1 - 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 < -4.00000000000000015e154

    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

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

    if -4.00000000000000015e154 < t < 1e7

    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. Simplified0.0

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

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

      associate-*r/ [=>]0.0

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

      associate-*l/ [=>]0.1

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

      *-commutative [=>]0.1

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

      associate-*l* [=>]0.1

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

      associate-*r* [=>]0.1

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

      *-commutative [<=]0.1

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

      metadata-eval [=>]0.1

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

      associate-*r/ [=>]0.1

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

      associate-*l/ [=>]0.0

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

      *-commutative [=>]0.0

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

      associate-*l* [=>]0.0

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

      associate-*r* [=>]0.0

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

      *-commutative [<=]0.0

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

      metadata-eval [=>]0.0

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

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

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

    if 1e7 < t

    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 inf 0.0

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

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

      [Start]0.0

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

      associate-*r/ [=>]0.0

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

      metadata-eval [=>]0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -4 \cdot 10^{+154}:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 10000000:\\ \;\;\;\;\frac{1 + \frac{\frac{t \cdot \left(t \cdot 4\right)}{1 + t}}{1 + t}}{1 + \left(1 + \frac{\frac{\left(t \cdot t\right) \cdot -4}{1 + t}}{-1 - t}\right)}\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error0.0
Cost2248
\[\begin{array}{l} t_1 := \frac{\frac{t \cdot \left(t \cdot 4\right)}{1 + t}}{1 + t}\\ \mathbf{if}\;t \leq -4 \cdot 10^{+154}:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 10000000:\\ \;\;\;\;\frac{1 + t_1}{2 + t_1}\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \end{array} \]
Alternative 2
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 3
Error0.3
Cost1480
\[\begin{array}{l} t_1 := 4 \cdot \left(t \cdot t\right)\\ \mathbf{if}\;t \leq -0.49:\\ \;\;\;\;\frac{5 + \frac{-8}{t}}{6 + \frac{-8}{t}}\\ \mathbf{elif}\;t \leq 0.55:\\ \;\;\;\;\frac{1 + \frac{t_1}{1 + t}}{2 + t_1}\\ \mathbf{else}:\\ \;\;\;\;\left(0.8333333333333334 + \frac{-0.2222222222222222}{t}\right) + \frac{0.037037037037037035}{t \cdot t}\\ \end{array} \]
Alternative 4
Error0.4
Cost968
\[\begin{array}{l} t_1 := 0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \mathbf{if}\;t \leq -0.78:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.33:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;t_1 + \frac{0.037037037037037035}{t \cdot t}\\ \end{array} \]
Alternative 5
Error0.4
Cost968
\[\begin{array}{l} \mathbf{if}\;t \leq -0.55:\\ \;\;\;\;\frac{5 + \frac{-8}{t}}{6 + \frac{-8}{t}}\\ \mathbf{elif}\;t \leq 0.33:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(0.8333333333333334 + \frac{-0.2222222222222222}{t}\right) + \frac{0.037037037037037035}{t \cdot t}\\ \end{array} \]
Alternative 6
Error0.4
Cost585
\[\begin{array}{l} \mathbf{if}\;t \leq -0.78 \lor \neg \left(t \leq 0.58\right):\\ \;\;\;\;0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \mathbf{else}:\\ \;\;\;\;t \cdot t + 0.5\\ \end{array} \]
Alternative 7
Error0.8
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -0.9:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334\\ \end{array} \]
Alternative 8
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 9
Error26.1
Cost64
\[0.5 \]

Error

Reproduce

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