?

Average Accuracy: 53.3% → 99.5%
Time: 19.8s
Precision: binary64
Cost: 20096

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Initial program 53.3%

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

    \[\leadsto \frac{\color{blue}{0.16666666666666666 \cdot {x}^{3} + \left(-2.7557319223985893 \cdot 10^{-6} \cdot {x}^{9} + \left(0.0001984126984126984 \cdot {x}^{7} + -0.008333333333333333 \cdot {x}^{5}\right)\right)}}{\tan x} \]
  3. Taylor expanded in x around 0 99.5%

    \[\leadsto \color{blue}{0.16666666666666666 \cdot {x}^{2} + \left(-0.0007275132275132275 \cdot {x}^{6} + -0.06388888888888888 \cdot {x}^{4}\right)} \]
  4. Final simplification99.5%

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

Alternatives

Alternative 1
Accuracy99.4%
Cost7040
\[-0.06388888888888888 \cdot {x}^{4} + x \cdot \left(0.16666666666666666 \cdot x\right) \]
Alternative 2
Accuracy99.0%
Cost6848
\[\frac{x}{\mathsf{fma}\left(x, 2, \frac{6}{x}\right)} \]
Alternative 3
Accuracy98.9%
Cost704
\[\frac{x}{x \cdot 2 + 6 \cdot \frac{1}{x}} \]
Alternative 4
Accuracy98.8%
Cost320
\[0.16666666666666666 \cdot \left(x \cdot x\right) \]
Alternative 5
Accuracy98.8%
Cost320
\[x \cdot \left(0.16666666666666666 \cdot x\right) \]
Alternative 6
Accuracy98.9%
Cost320
\[\frac{x}{\frac{6}{x}} \]
Alternative 7
Accuracy4.2%
Cost64
\[1 \]

Error

Reproduce?

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