?

Average Accuracy: 99.7% → 99.9%
Time: 9.8s
Precision: binary64
Cost: 7232

?

\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
\[\frac{1 - x}{\sqrt{x} \cdot -4 + \left(-1 - x\right)} \cdot 6 \]
(FPCore (x)
 :precision binary64
 (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))
(FPCore (x)
 :precision binary64
 (* (/ (- 1.0 x) (+ (* (sqrt x) -4.0) (- -1.0 x))) 6.0))
double code(double x) {
	return (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)));
}
double code(double x) {
	return ((1.0 - x) / ((sqrt(x) * -4.0) + (-1.0 - x))) * 6.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 = ((1.0d0 - x) / ((sqrt(x) * (-4.0d0)) + ((-1.0d0) - x))) * 6.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 ((1.0 - x) / ((Math.sqrt(x) * -4.0) + (-1.0 - x))) * 6.0;
}
def code(x):
	return (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * math.sqrt(x)))
def code(x):
	return ((1.0 - x) / ((math.sqrt(x) * -4.0) + (-1.0 - x))) * 6.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(Float64(Float64(1.0 - x) / Float64(Float64(sqrt(x) * -4.0) + Float64(-1.0 - x))) * 6.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 = ((1.0 - x) / ((sqrt(x) * -4.0) + (-1.0 - x))) * 6.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[(N[(N[(1.0 - x), $MachinePrecision] / N[(N[(N[Sqrt[x], $MachinePrecision] * -4.0), $MachinePrecision] + N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 6.0), $MachinePrecision]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\frac{1 - x}{\sqrt{x} \cdot -4 + \left(-1 - x\right)} \cdot 6

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original99.7%
Target99.9%
Herbie99.9%
\[\frac{6}{\frac{\left(x + 1\right) + 4 \cdot \sqrt{x}}{x - 1}} \]

Derivation?

  1. Initial program 99.8%

    \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
  2. Simplified99.9%

    \[\leadsto \color{blue}{\frac{6}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)} \cdot \left(x + -1\right)} \]
    Step-by-step derivation

    [Start]99.8

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

    associate-*l/ [<=]99.9

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

    +-commutative [=>]99.9

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

    fma-def [=>]99.9

    \[ \frac{6}{\color{blue}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)}} \cdot \left(x - 1\right) \]

    sub-neg [=>]99.9

    \[ \frac{6}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)} \cdot \color{blue}{\left(x + \left(-1\right)\right)} \]

    metadata-eval [=>]99.9

    \[ \frac{6}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)} \cdot \left(x + \color{blue}{-1}\right) \]
  3. Applied egg-rr99.6%

    \[\leadsto \color{blue}{\frac{x + -1}{\left(\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1\right) \cdot 0.16666666666666666}} \]
    Step-by-step derivation

    [Start]99.9

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

    *-commutative [=>]99.9

    \[ \color{blue}{\left(x + -1\right) \cdot \frac{6}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)}} \]

    clear-num [=>]99.7

    \[ \left(x + -1\right) \cdot \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)}{6}}} \]

    un-div-inv [=>]99.9

    \[ \color{blue}{\frac{x + -1}{\frac{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)}{6}}} \]

    div-inv [=>]99.6

    \[ \frac{x + -1}{\color{blue}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right) \cdot \frac{1}{6}}} \]

    fma-udef [=>]99.6

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

    associate-+r+ [=>]99.6

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

    fma-def [=>]99.6

    \[ \frac{x + -1}{\left(\color{blue}{\mathsf{fma}\left(4, \sqrt{x}, x\right)} + 1\right) \cdot \frac{1}{6}} \]

    metadata-eval [=>]99.6

    \[ \frac{x + -1}{\left(\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1\right) \cdot \color{blue}{0.16666666666666666}} \]
  4. Simplified99.9%

    \[\leadsto \color{blue}{\frac{x + -1}{x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)} \cdot 6} \]
    Step-by-step derivation

    [Start]99.6

    \[ \frac{x + -1}{\left(\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1\right) \cdot 0.16666666666666666} \]

    /-rgt-identity [<=]99.6

    \[ \frac{x + -1}{\color{blue}{\frac{\left(\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1\right) \cdot 0.16666666666666666}{1}}} \]

    associate-/l* [=>]99.9

    \[ \frac{x + -1}{\color{blue}{\frac{\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1}{\frac{1}{0.16666666666666666}}}} \]

    metadata-eval [=>]99.9

    \[ \frac{x + -1}{\frac{\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1}{\color{blue}{6}}} \]

    associate-/r/ [=>]100.0

    \[ \color{blue}{\frac{x + -1}{\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1} \cdot 6} \]

    *-lft-identity [<=]100.0

    \[ \frac{x + -1}{\color{blue}{1 \cdot \left(\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1\right)}} \cdot 6 \]

    *-lft-identity [=>]100.0

    \[ \frac{x + -1}{\color{blue}{\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1}} \cdot 6 \]

    fma-udef [=>]100.0

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

    +-commutative [=>]100.0

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

    associate-+r+ [<=]99.9

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

    fma-udef [<=]99.9

    \[ \frac{x + -1}{x + \color{blue}{\mathsf{fma}\left(4, \sqrt{x}, 1\right)}} \cdot 6 \]
  5. Applied egg-rr99.9%

    \[\leadsto \color{blue}{\left(\left(1 + \left(-x\right)\right) \cdot \frac{1}{-\left(x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)\right)}\right)} \cdot 6 \]
    Step-by-step derivation

    [Start]99.9

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

    frac-2neg [=>]99.9

    \[ \color{blue}{\frac{-\left(x + -1\right)}{-\left(x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)\right)}} \cdot 6 \]

    div-inv [=>]99.9

    \[ \color{blue}{\left(\left(-\left(x + -1\right)\right) \cdot \frac{1}{-\left(x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)\right)}\right)} \cdot 6 \]

    +-commutative [=>]99.9

    \[ \left(\left(-\color{blue}{\left(-1 + x\right)}\right) \cdot \frac{1}{-\left(x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)\right)}\right) \cdot 6 \]

    distribute-neg-in [=>]99.9

    \[ \left(\color{blue}{\left(\left(--1\right) + \left(-x\right)\right)} \cdot \frac{1}{-\left(x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)\right)}\right) \cdot 6 \]

    metadata-eval [=>]99.9

    \[ \left(\left(\color{blue}{1} + \left(-x\right)\right) \cdot \frac{1}{-\left(x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)\right)}\right) \cdot 6 \]
  6. Simplified99.9%

    \[\leadsto \color{blue}{\frac{1 - x}{\sqrt{x} \cdot -4 + \left(-1 - x\right)}} \cdot 6 \]
    Step-by-step derivation

    [Start]99.9

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

    associate-*r/ [=>]99.9

    \[ \color{blue}{\frac{\left(1 + \left(-x\right)\right) \cdot 1}{-\left(x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)\right)}} \cdot 6 \]

    *-rgt-identity [=>]99.9

    \[ \frac{\color{blue}{1 + \left(-x\right)}}{-\left(x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)\right)} \cdot 6 \]

    unsub-neg [=>]99.9

    \[ \frac{\color{blue}{1 - x}}{-\left(x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)\right)} \cdot 6 \]

    +-commutative [=>]99.9

    \[ \frac{1 - x}{-\color{blue}{\left(\mathsf{fma}\left(4, \sqrt{x}, 1\right) + x\right)}} \cdot 6 \]

    distribute-neg-in [=>]99.9

    \[ \frac{1 - x}{\color{blue}{\left(-\mathsf{fma}\left(4, \sqrt{x}, 1\right)\right) + \left(-x\right)}} \cdot 6 \]

    fma-def [<=]99.9

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

    distribute-neg-in [=>]99.9

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

    metadata-eval [=>]99.9

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

    associate-+l+ [=>]99.9

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

    *-commutative [=>]99.9

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

    distribute-rgt-neg-in [=>]99.9

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

    metadata-eval [=>]99.9

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

    sub-neg [<=]99.9

    \[ \frac{1 - x}{\sqrt{x} \cdot -4 + \color{blue}{\left(-1 - x\right)}} \cdot 6 \]
  7. Final simplification99.9%

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

Alternatives

Alternative 1
Accuracy99.9%
Cost7232
\[\frac{6}{\left(1 + x\right) + \sqrt{x} \cdot 4} \cdot \left(x + -1\right) \]
Alternative 2
Accuracy95.4%
Cost6848
\[\frac{\mathsf{fma}\left(6, x, -6\right)}{1 + x} \]
Alternative 3
Accuracy95.6%
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;-6\\ \mathbf{else}:\\ \;\;\;\;6 - \frac{12}{x}\\ \end{array} \]
Alternative 4
Accuracy95.6%
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq 0.5:\\ \;\;\;\;x \cdot 12 - 6\\ \mathbf{else}:\\ \;\;\;\;6 - \frac{12}{x}\\ \end{array} \]
Alternative 5
Accuracy95.6%
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;-6\\ \mathbf{else}:\\ \;\;\;\;6\\ \end{array} \]
Alternative 6
Accuracy48.4%
Cost64
\[-6 \]

Error

Reproduce?

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