?

Average Accuracy: 53.4% → 99.3%
Time: 19.4s
Precision: binary64
Cost: 704

?

\[-1 \leq x \land x \leq 1\]
\[\frac{x - \sin x}{\tan x} \]
\[\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888 + 0.16666666666666666\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(Float64(x * x) * Float64(Float64(Float64(x * 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[(N[(x * x), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * -0.06388888888888888), $MachinePrecision] + 0.16666666666666666), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888 + 0.16666666666666666\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Initial program 53.4%

    \[\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} \]

    unpow2 [=>]99.3

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

    fma-def [=>]99.3

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

    \[\leadsto \color{blue}{\left(0.16666666666666666 \cdot x\right) \cdot x + -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}} \]

    associate-*r* [=>]99.4

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

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

    [Start]99.4

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

    +-commutative [=>]99.4

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

    *-commutative [=>]99.4

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

    add-sqr-sqrt [=>]99.4

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

    associate-*l* [=>]99.4

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

    sqrt-pow1 [=>]99.4

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

    metadata-eval [=>]99.4

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

    unpow2 [=>]99.4

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

    associate-*l* [=>]99.3

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

    *-commutative [=>]99.3

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

    distribute-lft-out [=>]99.3

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

    sqrt-pow1 [=>]99.3

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

    metadata-eval [=>]99.3

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

    unpow2 [=>]99.3

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

    *-commutative [=>]99.3

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

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

Alternatives

Alternative 1
Accuracy99.4%
Cost704
\[x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888 + 0.16666666666666666\right)\right) \]
Alternative 2
Accuracy98.7%
Cost320
\[\left(x \cdot x\right) \cdot 0.16666666666666666 \]
Alternative 3
Accuracy98.8%
Cost320
\[x \cdot \frac{x}{6} \]

Error

Reproduce?

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