?

Average Error: 29.9 → 0.4
Time: 17.1s
Precision: binary64
Cost: 960

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Initial program 29.9

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

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

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

    [Start]0.4

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

    unpow2 [=>]0.4

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

    fma-def [=>]0.4

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

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

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

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

Alternatives

Alternative 1
Error0.8
Cost448
\[x \cdot \frac{1}{\frac{6}{x}} \]
Alternative 2
Error0.8
Cost320
\[0.16666666666666666 \cdot \left(x \cdot x\right) \]

Error

Reproduce?

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