Average Error: 0.0 → 0.0
Time: 8.0s
Precision: binary64
Cost: 1344
\[1 - \frac{1}{2 + \left(2 - \frac{\frac{2}{t}}{1 + \frac{1}{t}}\right) \cdot \left(2 - \frac{\frac{2}{t}}{1 + \frac{1}{t}}\right)} \]
\[\begin{array}{l} t_1 := 2 + \frac{-2}{1 + t}\\ 1 + \frac{-1}{2 + t_1 \cdot t_1} \end{array} \]
(FPCore (t)
 :precision binary64
 (-
  1.0
  (/
   1.0
   (+
    2.0
    (*
     (- 2.0 (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t))))
     (- 2.0 (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t)))))))))
(FPCore (t)
 :precision binary64
 (let* ((t_1 (+ 2.0 (/ -2.0 (+ 1.0 t)))))
   (+ 1.0 (/ -1.0 (+ 2.0 (* t_1 t_1))))))
double code(double t) {
	return 1.0 - (1.0 / (2.0 + ((2.0 - ((2.0 / t) / (1.0 + (1.0 / t)))) * (2.0 - ((2.0 / t) / (1.0 + (1.0 / t)))))));
}
double code(double t) {
	double t_1 = 2.0 + (-2.0 / (1.0 + t));
	return 1.0 + (-1.0 / (2.0 + (t_1 * t_1)));
}
real(8) function code(t)
    real(8), intent (in) :: t
    code = 1.0d0 - (1.0d0 / (2.0d0 + ((2.0d0 - ((2.0d0 / t) / (1.0d0 + (1.0d0 / t)))) * (2.0d0 - ((2.0d0 / t) / (1.0d0 + (1.0d0 / t)))))))
end function
real(8) function code(t)
    real(8), intent (in) :: t
    real(8) :: t_1
    t_1 = 2.0d0 + ((-2.0d0) / (1.0d0 + t))
    code = 1.0d0 + ((-1.0d0) / (2.0d0 + (t_1 * t_1)))
end function
public static double code(double t) {
	return 1.0 - (1.0 / (2.0 + ((2.0 - ((2.0 / t) / (1.0 + (1.0 / t)))) * (2.0 - ((2.0 / t) / (1.0 + (1.0 / t)))))));
}
public static double code(double t) {
	double t_1 = 2.0 + (-2.0 / (1.0 + t));
	return 1.0 + (-1.0 / (2.0 + (t_1 * t_1)));
}
def code(t):
	return 1.0 - (1.0 / (2.0 + ((2.0 - ((2.0 / t) / (1.0 + (1.0 / t)))) * (2.0 - ((2.0 / t) / (1.0 + (1.0 / t)))))))
def code(t):
	t_1 = 2.0 + (-2.0 / (1.0 + t))
	return 1.0 + (-1.0 / (2.0 + (t_1 * t_1)))
function code(t)
	return Float64(1.0 - Float64(1.0 / Float64(2.0 + Float64(Float64(2.0 - Float64(Float64(2.0 / t) / Float64(1.0 + Float64(1.0 / t)))) * Float64(2.0 - Float64(Float64(2.0 / t) / Float64(1.0 + Float64(1.0 / t))))))))
end
function code(t)
	t_1 = Float64(2.0 + Float64(-2.0 / Float64(1.0 + t)))
	return Float64(1.0 + Float64(-1.0 / Float64(2.0 + Float64(t_1 * t_1))))
end
function tmp = code(t)
	tmp = 1.0 - (1.0 / (2.0 + ((2.0 - ((2.0 / t) / (1.0 + (1.0 / t)))) * (2.0 - ((2.0 / t) / (1.0 + (1.0 / t)))))));
end
function tmp = code(t)
	t_1 = 2.0 + (-2.0 / (1.0 + t));
	tmp = 1.0 + (-1.0 / (2.0 + (t_1 * t_1)));
end
code[t_] := N[(1.0 - N[(1.0 / N[(2.0 + N[(N[(2.0 - N[(N[(2.0 / t), $MachinePrecision] / N[(1.0 + N[(1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(2.0 - N[(N[(2.0 / t), $MachinePrecision] / N[(1.0 + N[(1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[t_] := Block[{t$95$1 = N[(2.0 + N[(-2.0 / N[(1.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(1.0 + N[(-1.0 / N[(2.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
1 - \frac{1}{2 + \left(2 - \frac{\frac{2}{t}}{1 + \frac{1}{t}}\right) \cdot \left(2 - \frac{\frac{2}{t}}{1 + \frac{1}{t}}\right)}
\begin{array}{l}
t_1 := 2 + \frac{-2}{1 + t}\\
1 + \frac{-1}{2 + t_1 \cdot t_1}
\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

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

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

    \[\leadsto 1 - \frac{1}{2 + \left(2 - \frac{\frac{2}{t}}{1 + \frac{1}{t}}\right) \cdot \color{blue}{\left(2 + \frac{-2}{t + 1}\right)}} \]
    Proof
    (+.f64 2 (/.f64 -2 (+.f64 t 1))): 0 points increase in error, 0 points decrease in error
    (+.f64 2 (/.f64 -2 (+.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 t)) 1))): 0 points increase in error, 0 points decrease in error
    (+.f64 2 (/.f64 -2 (+.f64 (*.f64 1 t) (Rewrite<= lft-mult-inverse_binary64 (*.f64 (/.f64 1 t) t))))): 20 points increase in error, 0 points decrease in error
    (+.f64 2 (/.f64 -2 (Rewrite=> distribute-rgt-out_binary64 (*.f64 t (+.f64 1 (/.f64 1 t)))))): 1 points increase in error, 1 points decrease in error
    (+.f64 2 (Rewrite=> associate-/r*_binary64 (/.f64 (/.f64 -2 t) (+.f64 1 (/.f64 1 t))))): 0 points increase in error, 22 points decrease in error
  4. Applied egg-rr0.0

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

    \[\leadsto 1 - \frac{1}{2 + \color{blue}{\left(2 + \frac{-2}{t + 1}\right)} \cdot \left(2 + \frac{-2}{t + 1}\right)} \]
    Proof
    (+.f64 2 (/.f64 -2 (+.f64 t 1))): 0 points increase in error, 0 points decrease in error
    (+.f64 2 (/.f64 -2 (+.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 t)) 1))): 0 points increase in error, 0 points decrease in error
    (+.f64 2 (/.f64 -2 (+.f64 (*.f64 1 t) (Rewrite<= lft-mult-inverse_binary64 (*.f64 (/.f64 1 t) t))))): 20 points increase in error, 0 points decrease in error
    (+.f64 2 (/.f64 -2 (Rewrite=> distribute-rgt-out_binary64 (*.f64 t (+.f64 1 (/.f64 1 t)))))): 1 points increase in error, 1 points decrease in error
    (+.f64 2 (Rewrite=> associate-/r*_binary64 (/.f64 (/.f64 -2 t) (+.f64 1 (/.f64 1 t))))): 0 points increase in error, 22 points decrease in error
  6. Final simplification0.0

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

Alternatives

Alternative 1
Error0.4
Cost1224
\[\begin{array}{l} t_1 := 1 + \left(\frac{\frac{0.037037037037037035}{t} + -0.2222222222222222}{t} + -0.16666666666666666\right)\\ \mathbf{if}\;t \leq -1.65:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.45:\\ \;\;\;\;1 + \frac{-1}{2 + \left(t \cdot t\right) \cdot \left(4 + t \cdot -8\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error0.0
Cost1088
\[1 + \frac{-1}{\frac{\frac{4}{1 + t} + -8}{1 + t} + 6} \]
Alternative 3
Error0.4
Cost968
\[\begin{array}{l} t_1 := \left(0.8333333333333334 - \frac{0.2222222222222222}{t}\right) - \frac{\frac{-0.037037037037037035}{t}}{t}\\ \mathbf{if}\;t \leq -0.82:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.33:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error0.4
Cost968
\[\begin{array}{l} t_1 := 1 + \left(\frac{\frac{0.037037037037037035}{t} + -0.2222222222222222}{t} + -0.16666666666666666\right)\\ \mathbf{if}\;t \leq -0.82:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.33:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error0.4
Cost968
\[\begin{array}{l} t_1 := 1 + \left(\frac{\frac{0.037037037037037035}{t} + -0.2222222222222222}{t} + -0.16666666666666666\right)\\ \mathbf{if}\;t \leq -0.65:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.44:\\ \;\;\;\;1 + \frac{-1}{2 + 4 \cdot \left(t \cdot t\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error0.8
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 7
Error0.5
Cost584
\[\begin{array}{l} t_1 := 0.8333333333333334 - \frac{0.2222222222222222}{t}\\ \mathbf{if}\;t \leq -0.78:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.55:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error1.0
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.6
Cost64
\[0.8333333333333334 \]

Error

Reproduce

herbie shell --seed 2022329 
(FPCore (t)
  :name "Kahan p13 Example 3"
  :precision binary64
  (- 1.0 (/ 1.0 (+ 2.0 (* (- 2.0 (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t)))) (- 2.0 (/ (/ 2.0 t) (+ 1.0 (/ 1.0 t)))))))))