?

Average Accuracy: 52.6% → 99.4%
Time: 18.5s
Precision: binary64
Cost: 704

?

\[-1 \leq x \land x \leq 1\]
\[\frac{x - \sin x}{\tan x} \]
\[x \cdot \left(x \cdot \left(x \cdot \left(x \cdot -0.06388888888888888\right) + 0.16666666666666666\right)\right) \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x)
 :precision binary64
 (* x (* x (+ (* x (* x -0.06388888888888888)) 0.16666666666666666))))
double code(double x) {
	return (x - sin(x)) / tan(x);
}
double code(double x) {
	return x * (x * ((x * (x * -0.06388888888888888)) + 0.16666666666666666));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x - sin(x)) / tan(x)
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = x * (x * ((x * (x * (-0.06388888888888888d0))) + 0.16666666666666666d0))
end function
public static double code(double x) {
	return (x - Math.sin(x)) / Math.tan(x);
}
public static double code(double x) {
	return x * (x * ((x * (x * -0.06388888888888888)) + 0.16666666666666666));
}
def code(x):
	return (x - math.sin(x)) / math.tan(x)
def code(x):
	return x * (x * ((x * (x * -0.06388888888888888)) + 0.16666666666666666))
function code(x)
	return Float64(Float64(x - sin(x)) / tan(x))
end
function code(x)
	return Float64(x * Float64(x * Float64(Float64(x * Float64(x * -0.06388888888888888)) + 0.16666666666666666)))
end
function tmp = code(x)
	tmp = (x - sin(x)) / tan(x);
end
function tmp = code(x)
	tmp = x * (x * ((x * (x * -0.06388888888888888)) + 0.16666666666666666));
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(x * N[(x * N[(N[(x * N[(x * -0.06388888888888888), $MachinePrecision]), $MachinePrecision] + 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
x \cdot \left(x \cdot \left(x \cdot \left(x \cdot -0.06388888888888888\right) + 0.16666666666666666\right)\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original52.6%
Target98.7%
Herbie99.4%
\[0.16666666666666666 \cdot \left(x \cdot x\right) \]

Derivation?

  1. Initial program 52.6%

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around 0 99.3%

    \[\leadsto \color{blue}{0.16666666666666666 \cdot {x}^{2} + -0.06388888888888888 \cdot {x}^{4}} \]
  3. Simplified99.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.06388888888888888 \cdot {x}^{4}\right)} \]
    Proof

    [Start]99.3

    \[ 0.16666666666666666 \cdot {x}^{2} + -0.06388888888888888 \cdot {x}^{4} \]

    fma-def [=>]99.3

    \[ \color{blue}{\mathsf{fma}\left(0.16666666666666666, {x}^{2}, -0.06388888888888888 \cdot {x}^{4}\right)} \]

    unpow2 [=>]99.3

    \[ \mathsf{fma}\left(0.16666666666666666, \color{blue}{x \cdot x}, -0.06388888888888888 \cdot {x}^{4}\right) \]
  4. Applied egg-rr99.3%

    \[\leadsto \color{blue}{0.16666666666666666 \cdot \left(x \cdot x\right) + -0.06388888888888888 \cdot {x}^{4}} \]
    Proof

    [Start]99.3

    \[ \mathsf{fma}\left(0.16666666666666666, x \cdot x, -0.06388888888888888 \cdot {x}^{4}\right) \]

    fma-udef [=>]99.3

    \[ \color{blue}{0.16666666666666666 \cdot \left(x \cdot x\right) + -0.06388888888888888 \cdot {x}^{4}} \]
  5. Taylor expanded in x around 0 99.3%

    \[\leadsto \color{blue}{0.16666666666666666 \cdot {x}^{2} + -0.06388888888888888 \cdot {x}^{4}} \]
  6. Simplified99.4%

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot -0.06388888888888888, 0.16666666666666666\right)\right)} \]
    Proof

    [Start]99.3

    \[ 0.16666666666666666 \cdot {x}^{2} + -0.06388888888888888 \cdot {x}^{4} \]

    unpow2 [=>]99.3

    \[ 0.16666666666666666 \cdot \color{blue}{\left(x \cdot x\right)} + -0.06388888888888888 \cdot {x}^{4} \]

    +-commutative [<=]99.3

    \[ \color{blue}{-0.06388888888888888 \cdot {x}^{4} + 0.16666666666666666 \cdot \left(x \cdot x\right)} \]

    *-commutative [=>]99.3

    \[ \color{blue}{{x}^{4} \cdot -0.06388888888888888} + 0.16666666666666666 \cdot \left(x \cdot x\right) \]

    metadata-eval [<=]99.3

    \[ {x}^{\color{blue}{\left(3 + 1\right)}} \cdot -0.06388888888888888 + 0.16666666666666666 \cdot \left(x \cdot x\right) \]

    pow-plus [<=]99.3

    \[ \color{blue}{\left({x}^{3} \cdot x\right)} \cdot -0.06388888888888888 + 0.16666666666666666 \cdot \left(x \cdot x\right) \]

    unpow3 [=>]99.3

    \[ \left(\color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} \cdot x\right) \cdot -0.06388888888888888 + 0.16666666666666666 \cdot \left(x \cdot x\right) \]

    associate-*r* [<=]99.3

    \[ \color{blue}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)} \cdot -0.06388888888888888 + 0.16666666666666666 \cdot \left(x \cdot x\right) \]

    associate-*r* [<=]99.3

    \[ \color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888\right)} + 0.16666666666666666 \cdot \left(x \cdot x\right) \]

    associate-*l* [=>]99.3

    \[ \color{blue}{x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888\right)\right)} + 0.16666666666666666 \cdot \left(x \cdot x\right) \]

    *-commutative [=>]99.3

    \[ \color{blue}{\left(x \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888\right)\right) \cdot x} + 0.16666666666666666 \cdot \left(x \cdot x\right) \]

    associate-*r* [=>]99.4

    \[ \left(x \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888\right)\right) \cdot x + \color{blue}{\left(0.16666666666666666 \cdot x\right) \cdot x} \]

    distribute-rgt-out [=>]99.4

    \[ \color{blue}{x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888\right) + 0.16666666666666666 \cdot x\right)} \]

    *-commutative [=>]99.4

    \[ x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888\right) + \color{blue}{x \cdot 0.16666666666666666}\right) \]

    distribute-lft-out [=>]99.4

    \[ x \cdot \color{blue}{\left(x \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888 + 0.16666666666666666\right)\right)} \]

    associate-*l* [=>]99.4

    \[ x \cdot \left(x \cdot \left(\color{blue}{x \cdot \left(x \cdot -0.06388888888888888\right)} + 0.16666666666666666\right)\right) \]

    fma-def [=>]99.4

    \[ x \cdot \left(x \cdot \color{blue}{\mathsf{fma}\left(x, x \cdot -0.06388888888888888, 0.16666666666666666\right)}\right) \]
  7. Applied egg-rr99.4%

    \[\leadsto x \cdot \left(x \cdot \color{blue}{\left(x \cdot \left(x \cdot -0.06388888888888888\right) + 0.16666666666666666\right)}\right) \]
    Proof

    [Start]99.4

    \[ x \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot -0.06388888888888888, 0.16666666666666666\right)\right) \]

    fma-udef [=>]99.4

    \[ x \cdot \left(x \cdot \color{blue}{\left(x \cdot \left(x \cdot -0.06388888888888888\right) + 0.16666666666666666\right)}\right) \]
  8. Final simplification99.4%

    \[\leadsto x \cdot \left(x \cdot \left(x \cdot \left(x \cdot -0.06388888888888888\right) + 0.16666666666666666\right)\right) \]

Alternatives

Alternative 1
Accuracy98.7%
Cost320
\[0.16666666666666666 \cdot \left(x \cdot x\right) \]
Alternative 2
Accuracy98.7%
Cost320
\[x \cdot \left(x \cdot 0.16666666666666666\right) \]

Error

Reproduce?

herbie shell --seed 2023151 
(FPCore (x)
  :name "ENA, Section 1.4, Exercise 4a"
  :precision binary64
  :pre (and (<= -1.0 x) (<= x 1.0))

  :herbie-target
  (* 0.16666666666666666 (* x x))

  (/ (- x (sin x)) (tan x)))