?

Average Error: 29.6 → 0.4
Time: 18.6s
Precision: binary64
Cost: 7424

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.6
Target0.8
Herbie0.4
\[0.16666666666666666 \cdot \left(x \cdot x\right) \]

Derivation?

  1. Initial program 29.6

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

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

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

    [Start]0.4

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

    unpow2 [=>]0.4

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

    fma-def [=>]0.4

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

    metadata-eval [<=]0.4

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

    pow-sqr [<=]0.4

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

    fma-def [=>]0.4

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

    pow-sqr [=>]0.4

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

    metadata-eval [=>]0.4

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

    \[\leadsto \mathsf{fma}\left(0.16666666666666666, x \cdot x, \color{blue}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.06388888888888888 + -0.0007275132275132275 \cdot {x}^{4}\right)}\right) \]
  5. Applied egg-rr0.4

    \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \left(0.16666666666666666 + \mathsf{fma}\left(x, x \cdot -0.06388888888888888, -0.0007275132275132275 \cdot {x}^{4}\right)\right)} \]
  6. Applied egg-rr0.4

    \[\leadsto \left(x \cdot x\right) \cdot \left(0.16666666666666666 + \color{blue}{\left(x \cdot \left(x \cdot -0.06388888888888888\right) + -0.0007275132275132275 \cdot {x}^{4}\right)}\right) \]
  7. Final simplification0.4

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

Alternatives

Alternative 1
Error0.5
Cost704
\[\left(x \cdot x\right) \cdot \left(0.16666666666666666 + x \cdot \left(x \cdot -0.06388888888888888\right)\right) \]
Alternative 2
Error0.8
Cost320
\[\left(x \cdot x\right) \cdot 0.16666666666666666 \]

Error

Reproduce?

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