Average Error: 0.2 → 0.0
Time: 9.3s
Precision: binary64
Cost: 7232
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
\[\frac{6}{\frac{x + \left(1 + 4 \cdot \sqrt{x}\right)}{x + -1}} \]
(FPCore (x)
 :precision binary64
 (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))
(FPCore (x)
 :precision binary64
 (/ 6.0 (/ (+ x (+ 1.0 (* 4.0 (sqrt x)))) (+ x -1.0))))
double code(double x) {
	return (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)));
}
double code(double x) {
	return 6.0 / ((x + (1.0 + (4.0 * sqrt(x)))) / (x + -1.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
    code = 6.0d0 / ((x + (1.0d0 + (4.0d0 * sqrt(x)))) / (x + (-1.0d0)))
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) {
	return 6.0 / ((x + (1.0 + (4.0 * Math.sqrt(x)))) / (x + -1.0));
}
def code(x):
	return (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * math.sqrt(x)))
def code(x):
	return 6.0 / ((x + (1.0 + (4.0 * math.sqrt(x)))) / (x + -1.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)
	return Float64(6.0 / Float64(Float64(x + Float64(1.0 + Float64(4.0 * sqrt(x)))) / Float64(x + -1.0)))
end
function tmp = code(x)
	tmp = (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)));
end
function tmp = code(x)
	tmp = 6.0 / ((x + (1.0 + (4.0 * sqrt(x)))) / (x + -1.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_] := N[(6.0 / N[(N[(x + N[(1.0 + N[(4.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\frac{6}{\frac{x + \left(1 + 4 \cdot \sqrt{x}\right)}{x + -1}}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.2
Target0.0
Herbie0.0
\[\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. Simplified0.0

    \[\leadsto \color{blue}{\frac{6}{\frac{x + \left(1 + 4 \cdot \sqrt{x}\right)}{x + -1}}} \]
    Proof
    (/.f64 6 (/.f64 (+.f64 x (+.f64 1 (*.f64 4 (sqrt.f64 x)))) (+.f64 x -1))): 0 points increase in error, 0 points decrease in error
    (/.f64 6 (/.f64 (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x)))) (+.f64 x -1))): 0 points increase in error, 14 points decrease in error
    (/.f64 6 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (+.f64 x (Rewrite<= metadata-eval (neg.f64 1))))): 0 points increase in error, 0 points decrease in error
    (/.f64 6 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (Rewrite<= sub-neg_binary64 (-.f64 x 1)))): 1 points increase in error, 0 points decrease in error
    (/.f64 6 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 (-.f64 x 1)))))): 11 points increase in error, 0 points decrease in error
    (/.f64 6 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (neg.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 x 1)))))): 0 points increase in error, 12 points decrease in error
    (/.f64 6 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (neg.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 x) 1))))): 0 points increase in error, 0 points decrease in error
    (/.f64 6 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (neg.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 x)) 1)))): 1 points increase in error, 0 points decrease in error
    (/.f64 6 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (+.f64 (neg.f64 x) 1))))): 0 points increase in error, 1 points decrease in error
    (/.f64 6 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (*.f64 (Rewrite<= metadata-eval (neg.f64 1)) (+.f64 (neg.f64 x) 1)))): 0 points increase in error, 0 points decrease in error
    (/.f64 6 (Rewrite=> associate-/r*_binary64 (/.f64 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (neg.f64 1)) (+.f64 (neg.f64 x) 1)))): 0 points increase in error, 1 points decrease in error
    (Rewrite=> associate-/r/_binary64 (*.f64 (/.f64 6 (/.f64 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))) (neg.f64 1))) (+.f64 (neg.f64 x) 1))): 0 points increase in error, 0 points decrease in error
    (*.f64 (Rewrite=> associate-/r/_binary64 (*.f64 (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x)))) (neg.f64 1))) (+.f64 (neg.f64 x) 1)): 0 points increase in error, 0 points decrease in error
    (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x)))))) (+.f64 (neg.f64 x) 1)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 (neg.f64 x) 1) (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-rgt1-in_binary64 (+.f64 (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) (*.f64 (neg.f64 x) (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x)))))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) (*.f64 x (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x)))))))): 1 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) x))): 0 points increase in error, 1 points decrease in error
    (-.f64 (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) (*.f64 (*.f64 (Rewrite=> metadata-eval -1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) x)): 0 points increase in error, 0 points decrease in error
    (-.f64 (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) (*.f64 (Rewrite=> mul-1-neg_binary64 (neg.f64 (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x)))))) x)): 0 points increase in error, 0 points decrease in error
    (Rewrite=> cancel-sign-sub_binary64 (+.f64 (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) (*.f64 (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x)))) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) (Rewrite<= *-commutative_binary64 (*.f64 x (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))))): 1 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 x (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) (*.f64 (neg.f64 1) (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))))): 0 points increase in error, 1 points decrease in error
    (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 x (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))) (*.f64 1 (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))))): 25 points increase in error, 0 points decrease in error
    (Rewrite=> distribute-rgt-out--_binary64 (*.f64 (/.f64 6 (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x)))) (-.f64 x 1))): 0 points increase in error, 25 points decrease in error
    (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 6 (-.f64 x 1)) (+.f64 (+.f64 x 1) (*.f64 4 (sqrt.f64 x))))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error0.2
Cost7232
\[-6 \cdot \frac{x + -1}{\left(-1 - x\right) - \sqrt{x \cdot 16}} \]
Alternative 2
Error0.1
Cost7232
\[\left(x + -1\right) \cdot \frac{6}{1 + \left(x + 4 \cdot \sqrt{x}\right)} \]
Alternative 3
Error2.8
Cost708
\[\begin{array}{l} \mathbf{if}\;x \leq 1.55:\\ \;\;\;\;\left(x + -1\right) \cdot \left(6 + x \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;6 - \frac{12}{x}\\ \end{array} \]
Alternative 4
Error2.8
Cost580
\[\begin{array}{l} \mathbf{if}\;x \leq 0.5:\\ \;\;\;\;-6 + x \cdot 12\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{\frac{x}{x + -1}}\\ \end{array} \]
Alternative 5
Error2.9
Cost576
\[\left(x + -1\right) \cdot \frac{6}{x + 1} \]
Alternative 6
Error2.8
Cost576
\[\frac{6}{\frac{x + 1}{x + -1}} \]
Alternative 7
Error2.8
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq 0.5:\\ \;\;\;\;-6\\ \mathbf{else}:\\ \;\;\;\;6 - \frac{6}{x}\\ \end{array} \]
Alternative 8
Error2.8
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq 2:\\ \;\;\;\;-6 + 6 \cdot x\\ \mathbf{else}:\\ \;\;\;\;6 - \frac{12}{x}\\ \end{array} \]
Alternative 9
Error2.8
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq 0.5:\\ \;\;\;\;-6 + x \cdot 12\\ \mathbf{else}:\\ \;\;\;\;6 - \frac{6}{x}\\ \end{array} \]
Alternative 10
Error2.8
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;-6\\ \mathbf{else}:\\ \;\;\;\;6\\ \end{array} \]
Alternative 11
Error32.5
Cost64
\[-6 \]

Error

Reproduce

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