?

Average Error: 0.0 → 0.0
Time: 15.3s
Precision: binary64
Cost: 2248

?

\[\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 := \frac{\frac{t \cdot \left(t \cdot 4\right)}{1 + t}}{1 + t}\\ \mathbf{if}\;t \leq -5 \cdot 10^{+153}:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 5000000:\\ \;\;\;\;\frac{1 + t_1}{2 + t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{5 - \frac{8}{t}}{6 - \frac{8}{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
 (let* ((t_1 (/ (/ (* t (* t 4.0)) (+ 1.0 t)) (+ 1.0 t))))
   (if (<= t -5e+153)
     0.8333333333333334
     (if (<= t 5000000.0)
       (/ (+ 1.0 t_1) (+ 2.0 t_1))
       (/ (- 5.0 (/ 8.0 t)) (- 6.0 (/ 8.0 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 t_1 = ((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t);
	double tmp;
	if (t <= -5e+153) {
		tmp = 0.8333333333333334;
	} else if (t <= 5000000.0) {
		tmp = (1.0 + t_1) / (2.0 + t_1);
	} else {
		tmp = (5.0 - (8.0 / t)) / (6.0 - (8.0 / 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) :: t_1
    real(8) :: tmp
    t_1 = ((t * (t * 4.0d0)) / (1.0d0 + t)) / (1.0d0 + t)
    if (t <= (-5d+153)) then
        tmp = 0.8333333333333334d0
    else if (t <= 5000000.0d0) then
        tmp = (1.0d0 + t_1) / (2.0d0 + t_1)
    else
        tmp = (5.0d0 - (8.0d0 / t)) / (6.0d0 - (8.0d0 / 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 t_1 = ((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t);
	double tmp;
	if (t <= -5e+153) {
		tmp = 0.8333333333333334;
	} else if (t <= 5000000.0) {
		tmp = (1.0 + t_1) / (2.0 + t_1);
	} else {
		tmp = (5.0 - (8.0 / t)) / (6.0 - (8.0 / 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):
	t_1 = ((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t)
	tmp = 0
	if t <= -5e+153:
		tmp = 0.8333333333333334
	elif t <= 5000000.0:
		tmp = (1.0 + t_1) / (2.0 + t_1)
	else:
		tmp = (5.0 - (8.0 / t)) / (6.0 - (8.0 / 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)
	t_1 = Float64(Float64(Float64(t * Float64(t * 4.0)) / Float64(1.0 + t)) / Float64(1.0 + t))
	tmp = 0.0
	if (t <= -5e+153)
		tmp = 0.8333333333333334;
	elseif (t <= 5000000.0)
		tmp = Float64(Float64(1.0 + t_1) / Float64(2.0 + t_1));
	else
		tmp = Float64(Float64(5.0 - Float64(8.0 / t)) / Float64(6.0 - Float64(8.0 / 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)
	t_1 = ((t * (t * 4.0)) / (1.0 + t)) / (1.0 + t);
	tmp = 0.0;
	if (t <= -5e+153)
		tmp = 0.8333333333333334;
	elseif (t <= 5000000.0)
		tmp = (1.0 + t_1) / (2.0 + t_1);
	else
		tmp = (5.0 - (8.0 / t)) / (6.0 - (8.0 / 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_] := Block[{t$95$1 = N[(N[(N[(t * N[(t * 4.0), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -5e+153], 0.8333333333333334, If[LessEqual[t, 5000000.0], N[(N[(1.0 + t$95$1), $MachinePrecision] / N[(2.0 + t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(5.0 - N[(8.0 / t), $MachinePrecision]), $MachinePrecision] / N[(6.0 - N[(8.0 / t), $MachinePrecision]), $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}
t_1 := \frac{\frac{t \cdot \left(t \cdot 4\right)}{1 + t}}{1 + t}\\
\mathbf{if}\;t \leq -5 \cdot 10^{+153}:\\
\;\;\;\;0.8333333333333334\\

\mathbf{elif}\;t \leq 5000000:\\
\;\;\;\;\frac{1 + t_1}{2 + t_1}\\

\mathbf{else}:\\
\;\;\;\;\frac{5 - \frac{8}{t}}{6 - \frac{8}{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 < -5.00000000000000018e153

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

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

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

      associate-/l* [=>]0.1

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

      associate-/l* [=>]0.1

      \[ \frac{1 + \frac{2}{\frac{1 + t}{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-/l* [=>]0.1

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

      associate-/l* [=>]0

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

      \[\leadsto \frac{1 + \frac{2}{\frac{1 + t}{t}} \cdot \frac{2}{\frac{1 + t}{t}}}{\color{blue}{6}} \]
    4. Taylor expanded in t around inf 0

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

    if -5.00000000000000018e153 < t < 5e6

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

      \[ \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.0

      \[ \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.0

      \[ \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.0

      \[ \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.0

      \[ \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.0

      \[ \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.0

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

    if 5e6 < 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. Simplified33.6

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

      associate-*r/ [=>]0.1

      \[ \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/ [=>]33.6

      \[ \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 [=>]33.6

      \[ \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* [=>]33.6

      \[ \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* [=>]33.6

      \[ \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 [<=]33.6

      \[ \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 [=>]33.6

      \[ \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/ [=>]33.6

      \[ \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}}} \]
    3. Taylor expanded in t around inf 33.6

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

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

      [Start]33.6

      \[ \frac{1 + \frac{\frac{t \cdot \left(t \cdot 4\right)}{1 + t}}{1 + t}}{6 - 8 \cdot \frac{1}{t}} \]

      associate-*r/ [=>]33.6

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

      metadata-eval [=>]33.6

      \[ \frac{1 + \frac{\frac{t \cdot \left(t \cdot 4\right)}{1 + t}}{1 + t}}{6 - \frac{\color{blue}{8}}{t}} \]
    5. Taylor expanded in t around inf 0.0

      \[\leadsto \frac{\color{blue}{5 - 8 \cdot \frac{1}{t}}}{6 - \frac{8}{t}} \]
    6. Simplified0.0

      \[\leadsto \frac{\color{blue}{5 - \frac{8}{t}}}{6 - \frac{8}{t}} \]
      Proof

      [Start]0.0

      \[ \frac{5 - 8 \cdot \frac{1}{t}}{6 - \frac{8}{t}} \]

      associate-*r/ [=>]0.0

      \[ \frac{5 - \color{blue}{\frac{8 \cdot 1}{t}}}{6 - \frac{8}{t}} \]

      metadata-eval [=>]0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{+153}:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 5000000:\\ \;\;\;\;\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}}\\ \mathbf{else}:\\ \;\;\;\;\frac{5 - \frac{8}{t}}{6 - \frac{8}{t}}\\ \end{array} \]

Alternatives

Alternative 1
Error0.0
Cost2240
\[\begin{array}{l} t_1 := \frac{2}{\frac{1 + t}{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 := 4 \cdot \left(t \cdot t\right)\\ \mathbf{if}\;t \leq -0.43:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 0.56:\\ \;\;\;\;\frac{1 + \frac{t_1}{1 + t}}{2 + t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.037037037037037035}{t \cdot t} + \left(0.8333333333333334 + \frac{-0.2222222222222222}{t}\right)\\ \end{array} \]
Alternative 3
Error0.8
Cost968
\[\begin{array}{l} \mathbf{if}\;t \leq -0.42:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 0.235:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{0.037037037037037035}{t \cdot t} + \left(0.8333333333333334 + \frac{-0.2222222222222222}{t}\right)\\ \end{array} \]
Alternative 4
Error1.0
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -0.42:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334\\ \end{array} \]
Alternative 5
Error0.8
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -0.42:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 0.56:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \end{array} \]
Alternative 6
Error1.1
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 7
Error26.2
Cost64
\[0.5 \]

Error

Reproduce?

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