?

Average Error: 0.2 → 0.3
Time: 41.1s
Precision: binary64
Cost: 21952

?

\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
\[\begin{array}{l} t_0 := \frac{6 \cdot \left(x + -1\right)}{x + \left(1 + 4 \cdot \sqrt{x}\right)}\\ \frac{1}{t_0} \cdot \left(t_0 \cdot t_0\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ (* 6.0 (+ x -1.0)) (+ x (+ 1.0 (* 4.0 (sqrt x)))))))
   (* (/ 1.0 t_0) (* t_0 t_0))))
double code(double x) {
	return (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)));
}
double code(double x) {
	double t_0 = (6.0 * (x + -1.0)) / (x + (1.0 + (4.0 * sqrt(x))));
	return (1.0 / t_0) * (t_0 * t_0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (6.0d0 * (x - 1.0d0)) / ((x + 1.0d0) + (4.0d0 * sqrt(x)))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = (6.0d0 * (x + (-1.0d0))) / (x + (1.0d0 + (4.0d0 * sqrt(x))))
    code = (1.0d0 / t_0) * (t_0 * t_0)
end function
public static double code(double x) {
	return (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * Math.sqrt(x)));
}
public static double code(double x) {
	double t_0 = (6.0 * (x + -1.0)) / (x + (1.0 + (4.0 * Math.sqrt(x))));
	return (1.0 / t_0) * (t_0 * t_0);
}
def code(x):
	return (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * math.sqrt(x)))
def code(x):
	t_0 = (6.0 * (x + -1.0)) / (x + (1.0 + (4.0 * math.sqrt(x))))
	return (1.0 / t_0) * (t_0 * t_0)
function code(x)
	return Float64(Float64(6.0 * Float64(x - 1.0)) / Float64(Float64(x + 1.0) + Float64(4.0 * sqrt(x))))
end
function code(x)
	t_0 = Float64(Float64(6.0 * Float64(x + -1.0)) / Float64(x + Float64(1.0 + Float64(4.0 * sqrt(x)))))
	return Float64(Float64(1.0 / t_0) * Float64(t_0 * t_0))
end
function tmp = code(x)
	tmp = (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)));
end
function tmp = code(x)
	t_0 = (6.0 * (x + -1.0)) / (x + (1.0 + (4.0 * sqrt(x))));
	tmp = (1.0 / t_0) * (t_0 * t_0);
end
code[x_] := N[(N[(6.0 * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] + N[(4.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(N[(6.0 * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x + N[(1.0 + N[(4.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\begin{array}{l}
t_0 := \frac{6 \cdot \left(x + -1\right)}{x + \left(1 + 4 \cdot \sqrt{x}\right)}\\
\frac{1}{t_0} \cdot \left(t_0 \cdot t_0\right)
\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.2
Target0.1
Herbie0.3
\[\frac{6}{\frac{\left(x + 1\right) + 4 \cdot \sqrt{x}}{x - 1}} \]

Derivation?

  1. Initial program 0.2

    \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
  2. Applied egg-rr0.3

    \[\leadsto \color{blue}{\frac{1}{\frac{6 \cdot \left(x + -1\right)}{x + \left(1 + 4 \cdot \sqrt{x}\right)}} \cdot \left(\frac{6 \cdot \left(x + -1\right)}{x + \left(1 + 4 \cdot \sqrt{x}\right)} \cdot \frac{6 \cdot \left(x + -1\right)}{x + \left(1 + 4 \cdot \sqrt{x}\right)}\right)} \]
  3. Final simplification0.3

    \[\leadsto \frac{1}{\frac{6 \cdot \left(x + -1\right)}{x + \left(1 + 4 \cdot \sqrt{x}\right)}} \cdot \left(\frac{6 \cdot \left(x + -1\right)}{x + \left(1 + 4 \cdot \sqrt{x}\right)} \cdot \frac{6 \cdot \left(x + -1\right)}{x + \left(1 + 4 \cdot \sqrt{x}\right)}\right) \]

Alternatives

Alternative 1
Error1.6
Cost7236
\[\begin{array}{l} t_0 := \left(x + 1\right) + 4 \cdot \sqrt{x}\\ \mathbf{if}\;x \leq 1:\\ \;\;\;\;\frac{-6}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{6 \cdot x}{t_0}\\ \end{array} \]
Alternative 2
Error0.2
Cost7232
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
Alternative 3
Error0.2
Cost7232
\[\frac{6 \cdot x - 6}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
Alternative 4
Error2.2
Cost7108
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\frac{-6}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;6\\ \end{array} \]
Alternative 5
Error3.0
Cost580
\[\begin{array}{l} \mathbf{if}\;x \leq 2:\\ \;\;\;\;\frac{6 \cdot \left(x - 1\right)}{1}\\ \mathbf{else}:\\ \;\;\;\;6\\ \end{array} \]
Alternative 6
Error3.0
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;-6\\ \mathbf{else}:\\ \;\;\;\;6\\ \end{array} \]
Alternative 7
Error33.2
Cost64
\[-6 \]

Error

Reproduce?

herbie shell --seed 2023077 
(FPCore (x)
  :name "Data.Approximate.Numerics:blog from approximate-0.2.2.1"
  :precision binary64

  :herbie-target
  (/ 6.0 (/ (+ (+ x 1.0) (* 4.0 (sqrt x))) (- x 1.0)))

  (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))