Average Error: 0.0 → 0.4
Time: 7.1s
Precision: binary64
Cost: 1992
\[\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 := 0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \mathbf{if}\;t \leq -0.52:\\ \;\;\;\;\frac{0.037037037037037035}{t \cdot t} + t_1\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;\frac{1 + \frac{\frac{\left(t \cdot t\right) \cdot 4}{1 + t}}{1 + t}}{2 + \left(t \cdot t\right) \cdot \left(4 + t \cdot -8\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (+ 0.8333333333333334 (/ -0.2222222222222222 t))))
   (if (<= t -0.52)
     (+ (/ 0.037037037037037035 (* t t)) t_1)
     (if (<= t 0.58)
       (/
        (+ 1.0 (/ (/ (* (* t t) 4.0) (+ 1.0 t)) (+ 1.0 t)))
        (+ 2.0 (* (* t t) (+ 4.0 (* t -8.0)))))
       t_1))))
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 = 0.8333333333333334 + (-0.2222222222222222 / t);
	double tmp;
	if (t <= -0.52) {
		tmp = (0.037037037037037035 / (t * t)) + t_1;
	} else if (t <= 0.58) {
		tmp = (1.0 + ((((t * t) * 4.0) / (1.0 + t)) / (1.0 + t))) / (2.0 + ((t * t) * (4.0 + (t * -8.0))));
	} else {
		tmp = t_1;
	}
	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 = 0.8333333333333334d0 + ((-0.2222222222222222d0) / t)
    if (t <= (-0.52d0)) then
        tmp = (0.037037037037037035d0 / (t * t)) + t_1
    else if (t <= 0.58d0) then
        tmp = (1.0d0 + ((((t * t) * 4.0d0) / (1.0d0 + t)) / (1.0d0 + t))) / (2.0d0 + ((t * t) * (4.0d0 + (t * (-8.0d0)))))
    else
        tmp = t_1
    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 = 0.8333333333333334 + (-0.2222222222222222 / t);
	double tmp;
	if (t <= -0.52) {
		tmp = (0.037037037037037035 / (t * t)) + t_1;
	} else if (t <= 0.58) {
		tmp = (1.0 + ((((t * t) * 4.0) / (1.0 + t)) / (1.0 + t))) / (2.0 + ((t * t) * (4.0 + (t * -8.0))));
	} else {
		tmp = t_1;
	}
	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 = 0.8333333333333334 + (-0.2222222222222222 / t)
	tmp = 0
	if t <= -0.52:
		tmp = (0.037037037037037035 / (t * t)) + t_1
	elif t <= 0.58:
		tmp = (1.0 + ((((t * t) * 4.0) / (1.0 + t)) / (1.0 + t))) / (2.0 + ((t * t) * (4.0 + (t * -8.0))))
	else:
		tmp = t_1
	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(0.8333333333333334 + Float64(-0.2222222222222222 / t))
	tmp = 0.0
	if (t <= -0.52)
		tmp = Float64(Float64(0.037037037037037035 / Float64(t * t)) + t_1);
	elseif (t <= 0.58)
		tmp = Float64(Float64(1.0 + Float64(Float64(Float64(Float64(t * t) * 4.0) / Float64(1.0 + t)) / Float64(1.0 + t))) / Float64(2.0 + Float64(Float64(t * t) * Float64(4.0 + Float64(t * -8.0)))));
	else
		tmp = t_1;
	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 = 0.8333333333333334 + (-0.2222222222222222 / t);
	tmp = 0.0;
	if (t <= -0.52)
		tmp = (0.037037037037037035 / (t * t)) + t_1;
	elseif (t <= 0.58)
		tmp = (1.0 + ((((t * t) * 4.0) / (1.0 + t)) / (1.0 + t))) / (2.0 + ((t * t) * (4.0 + (t * -8.0))));
	else
		tmp = t_1;
	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[(0.8333333333333334 + N[(-0.2222222222222222 / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -0.52], N[(N[(0.037037037037037035 / N[(t * t), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[t, 0.58], N[(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] / N[(2.0 + N[(N[(t * t), $MachinePrecision] * N[(4.0 + N[(t * -8.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$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}}
\begin{array}{l}
t_1 := 0.8333333333333334 + \frac{-0.2222222222222222}{t}\\
\mathbf{if}\;t \leq -0.52:\\
\;\;\;\;\frac{0.037037037037037035}{t \cdot t} + t_1\\

\mathbf{elif}\;t \leq 0.58:\\
\;\;\;\;\frac{1 + \frac{\frac{\left(t \cdot t\right) \cdot 4}{1 + t}}{1 + t}}{2 + \left(t \cdot t\right) \cdot \left(4 + t \cdot -8\right)}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


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

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

      \[\leadsto \color{blue}{\left(0.037037037037037035 \cdot \frac{1}{{t}^{2}} + 0.8333333333333334\right) - 0.2222222222222222 \cdot \frac{1}{t}} \]
    3. Simplified0.5

      \[\leadsto \color{blue}{\frac{0.037037037037037035}{t \cdot t} + \left(0.8333333333333334 - \frac{0.2222222222222222}{t}\right)} \]
      Proof
      (+.f64 (/.f64 1/27 (*.f64 t t)) (-.f64 5/6 (/.f64 2/9 t))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 1/27 1)) (*.f64 t t)) (-.f64 5/6 (/.f64 2/9 t))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (*.f64 1/27 1) (Rewrite<= unpow2_binary64 (pow.f64 t 2))) (-.f64 5/6 (/.f64 2/9 t))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= associate-*r/_binary64 (*.f64 1/27 (/.f64 1 (pow.f64 t 2)))) (-.f64 5/6 (/.f64 2/9 t))): 5 points increase in error, 4 points decrease in error
      (+.f64 (*.f64 1/27 (/.f64 1 (pow.f64 t 2))) (-.f64 5/6 (/.f64 (Rewrite<= metadata-eval (*.f64 2/9 1)) t))): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 1/27 (/.f64 1 (pow.f64 t 2))) (-.f64 5/6 (Rewrite<= associate-*r/_binary64 (*.f64 2/9 (/.f64 1 t))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (*.f64 1/27 (/.f64 1 (pow.f64 t 2))) 5/6) (*.f64 2/9 (/.f64 1 t)))): 2 points increase in error, 0 points decrease in error

    if -0.52000000000000002 < t < 0.57999999999999996

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

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

      \[\leadsto \frac{1 + \frac{2 \cdot t}{1 + t} \cdot \frac{2 \cdot t}{1 + t}}{2 + \color{blue}{\left(t \cdot t\right) \cdot \left(-8 \cdot t + 4\right)}} \]
      Proof
      (*.f64 (*.f64 t t) (+.f64 (*.f64 -8 t) 4)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 t 2)) (+.f64 (*.f64 -8 t) 4)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= distribute-rgt-out_binary64 (+.f64 (*.f64 (*.f64 -8 t) (pow.f64 t 2)) (*.f64 4 (pow.f64 t 2)))): 0 points increase in error, 1 points decrease in error
      (+.f64 (Rewrite<= associate-*r*_binary64 (*.f64 -8 (*.f64 t (pow.f64 t 2)))) (*.f64 4 (pow.f64 t 2))): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 -8 (*.f64 t (Rewrite=> unpow2_binary64 (*.f64 t t)))) (*.f64 4 (pow.f64 t 2))): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 -8 (Rewrite<= cube-mult_binary64 (pow.f64 t 3))) (*.f64 4 (pow.f64 t 2))): 6 points increase in error, 5 points decrease in error
    4. Applied egg-rr0.3

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

    if 0.57999999999999996 < 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{0.2222222222222222}{t}} \]
      Proof
      (-.f64 5/6 (/.f64 2/9 t)): 0 points increase in error, 0 points decrease in error
      (-.f64 5/6 (/.f64 (Rewrite<= metadata-eval (*.f64 2/9 1)) t)): 0 points increase in error, 0 points decrease in error
      (-.f64 5/6 (Rewrite<= associate-*r/_binary64 (*.f64 2/9 (/.f64 1 t)))): 12 points increase in error, 20 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -0.52:\\ \;\;\;\;\frac{0.037037037037037035}{t \cdot t} + \left(0.8333333333333334 + \frac{-0.2222222222222222}{t}\right)\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;\frac{1 + \frac{\frac{\left(t \cdot t\right) \cdot 4}{1 + t}}{1 + t}}{2 + \left(t \cdot t\right) \cdot \left(4 + t \cdot -8\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.4
Cost1736
\[\begin{array}{l} t_1 := \left(t \cdot t\right) \cdot \left(4 + t \cdot -8\right)\\ t_2 := 0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \mathbf{if}\;t \leq -0.8:\\ \;\;\;\;\frac{0.037037037037037035}{t \cdot t} + t_2\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;\frac{1 + t_1}{2 + t_1}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error0.4
Cost1480
\[\begin{array}{l} t_1 := 0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \mathbf{if}\;t \leq -0.65:\\ \;\;\;\;\frac{0.037037037037037035}{t \cdot t} + t_1\\ \mathbf{elif}\;t \leq 0.47:\\ \;\;\;\;\frac{1 + \left(t \cdot t\right) \cdot \left(4 + t \cdot -8\right)}{2 + t \cdot \left(t \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error0.4
Cost836
\[\begin{array}{l} t_1 := 0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \mathbf{if}\;t \leq -0.82:\\ \;\;\;\;\frac{0.037037037037037035}{t \cdot t} + t_1\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error0.7
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 6
Error0.5
Cost584
\[\begin{array}{l} t_1 := 0.8333333333333334 + \frac{-0.2222222222222222}{t}\\ \mathbf{if}\;t \leq -0.8:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 0.58:\\ \;\;\;\;t \cdot t + 0.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error0.8
Cost328
\[\begin{array}{l} \mathbf{if}\;t \leq -0.34:\\ \;\;\;\;0.8333333333333334\\ \mathbf{elif}\;t \leq 1:\\ \;\;\;\;0.5\\ \mathbf{else}:\\ \;\;\;\;0.8333333333333334\\ \end{array} \]
Alternative 8
Error26.1
Cost64
\[0.5 \]

Error

Reproduce

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