?

Average Error: 30.3 → 0.3
Time: 24.7s
Precision: binary64
Cost: 26816

?

\[-1 \leq x \land x \leq 1\]
\[\frac{x - \sin x}{\tan x} \]
\[\left({x}^{6} \cdot -0.0007275132275132275 + {x}^{8} \cdot -0.00023644179894179894\right) + \left(0.16666666666666666 \cdot {x}^{2} + {x}^{4} \cdot -0.06388888888888888\right) \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x)
 :precision binary64
 (+
  (+
   (* (pow x 6.0) -0.0007275132275132275)
   (* (pow x 8.0) -0.00023644179894179894))
  (+
   (* 0.16666666666666666 (pow x 2.0))
   (* (pow x 4.0) -0.06388888888888888))))
double code(double x) {
	return (x - sin(x)) / tan(x);
}
double code(double x) {
	return ((pow(x, 6.0) * -0.0007275132275132275) + (pow(x, 8.0) * -0.00023644179894179894)) + ((0.16666666666666666 * pow(x, 2.0)) + (pow(x, 4.0) * -0.06388888888888888));
}
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 ** 6.0d0) * (-0.0007275132275132275d0)) + ((x ** 8.0d0) * (-0.00023644179894179894d0))) + ((0.16666666666666666d0 * (x ** 2.0d0)) + ((x ** 4.0d0) * (-0.06388888888888888d0)))
end function
public static double code(double x) {
	return (x - Math.sin(x)) / Math.tan(x);
}
public static double code(double x) {
	return ((Math.pow(x, 6.0) * -0.0007275132275132275) + (Math.pow(x, 8.0) * -0.00023644179894179894)) + ((0.16666666666666666 * Math.pow(x, 2.0)) + (Math.pow(x, 4.0) * -0.06388888888888888));
}
def code(x):
	return (x - math.sin(x)) / math.tan(x)
def code(x):
	return ((math.pow(x, 6.0) * -0.0007275132275132275) + (math.pow(x, 8.0) * -0.00023644179894179894)) + ((0.16666666666666666 * math.pow(x, 2.0)) + (math.pow(x, 4.0) * -0.06388888888888888))
function code(x)
	return Float64(Float64(x - sin(x)) / tan(x))
end
function code(x)
	return Float64(Float64(Float64((x ^ 6.0) * -0.0007275132275132275) + Float64((x ^ 8.0) * -0.00023644179894179894)) + Float64(Float64(0.16666666666666666 * (x ^ 2.0)) + Float64((x ^ 4.0) * -0.06388888888888888)))
end
function tmp = code(x)
	tmp = (x - sin(x)) / tan(x);
end
function tmp = code(x)
	tmp = (((x ^ 6.0) * -0.0007275132275132275) + ((x ^ 8.0) * -0.00023644179894179894)) + ((0.16666666666666666 * (x ^ 2.0)) + ((x ^ 4.0) * -0.06388888888888888));
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[(N[Power[x, 6.0], $MachinePrecision] * -0.0007275132275132275), $MachinePrecision] + N[(N[Power[x, 8.0], $MachinePrecision] * -0.00023644179894179894), $MachinePrecision]), $MachinePrecision] + N[(N[(0.16666666666666666 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * -0.06388888888888888), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
\left({x}^{6} \cdot -0.0007275132275132275 + {x}^{8} \cdot -0.00023644179894179894\right) + \left(0.16666666666666666 \cdot {x}^{2} + {x}^{4} \cdot -0.06388888888888888\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original30.3
Target0.8
Herbie0.3
\[0.16666666666666666 \cdot \left(x \cdot x\right) \]

Derivation?

  1. Initial program 30.3

    \[\frac{x - \sin x}{\tan x} \]
  2. Taylor expanded in x around inf 30.3

    \[\leadsto \color{blue}{\frac{\cos x \cdot x}{\sin x} + -1 \cdot \cos x} \]
  3. Simplified30.4

    \[\leadsto \color{blue}{\cos x \cdot \left(-1 + \frac{x}{\sin x}\right)} \]
    Proof

    [Start]30.3

    \[ \frac{\cos x \cdot x}{\sin x} + -1 \cdot \cos x \]

    rational_best-simplify-2 [=>]30.3

    \[ \frac{\color{blue}{x \cdot \cos x}}{\sin x} + -1 \cdot \cos x \]

    rational_best-simplify-47 [=>]30.4

    \[ \color{blue}{\cos x \cdot \frac{x}{\sin x}} + -1 \cdot \cos x \]

    rational_best-simplify-51 [=>]30.4

    \[ \color{blue}{\cos x \cdot \left(-1 + \frac{x}{\sin x}\right)} \]
  4. Taylor expanded in x around 0 0.3

    \[\leadsto \color{blue}{0.16666666666666666 \cdot {x}^{2} + \left(-0.00023644179894179894 \cdot {x}^{8} + \left(-0.0007275132275132275 \cdot {x}^{6} + -0.06388888888888888 \cdot {x}^{4}\right)\right)} \]
  5. Simplified0.3

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

    [Start]0.3

    \[ 0.16666666666666666 \cdot {x}^{2} + \left(-0.00023644179894179894 \cdot {x}^{8} + \left(-0.0007275132275132275 \cdot {x}^{6} + -0.06388888888888888 \cdot {x}^{4}\right)\right) \]

    rational_best-simplify-43 [=>]0.3

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

    rational_best-simplify-43 [=>]0.3

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

    rational_best-simplify-2 [=>]0.3

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

    rational_best-simplify-2 [=>]0.3

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

    rational_best-simplify-1 [<=]0.3

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

    rational_best-simplify-2 [=>]0.3

    \[ \left({x}^{6} \cdot -0.0007275132275132275 + {x}^{8} \cdot -0.00023644179894179894\right) + \left(0.16666666666666666 \cdot {x}^{2} + \color{blue}{{x}^{4} \cdot -0.06388888888888888}\right) \]
  6. Final simplification0.3

    \[\leadsto \left({x}^{6} \cdot -0.0007275132275132275 + {x}^{8} \cdot -0.00023644179894179894\right) + \left(0.16666666666666666 \cdot {x}^{2} + {x}^{4} \cdot -0.06388888888888888\right) \]

Alternatives

Alternative 1
Error0.3
Cost26816
\[\left(-0.06388888888888888 \cdot {x}^{4} + -0.0007275132275132275 \cdot {x}^{6}\right) + \left(0.16666666666666666 \cdot {x}^{2} + -0.00023644179894179894 \cdot {x}^{8}\right) \]
Alternative 2
Error0.3
Cost20096
\[-0.06388888888888888 \cdot {x}^{4} + \left(0.16666666666666666 \cdot {x}^{2} + -0.0007275132275132275 \cdot {x}^{6}\right) \]
Alternative 3
Error0.4
Cost13376
\[0.16666666666666666 \cdot {x}^{2} + -0.06388888888888888 \cdot {x}^{4} \]
Alternative 4
Error0.8
Cost6656
\[0.16666666666666666 \cdot {x}^{2} \]
Alternative 5
Error61.3
Cost6592
\[\frac{x}{\tan x} \]
Alternative 6
Error61.3
Cost64
\[1 \]

Error

Reproduce?

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