Average Error: 30.3 → 0.3
Time: 29.9s
Precision: binary64
Cost: 14400
\[-1 \leq x \land x \leq 1\]
\[\frac{x - \sin x}{\tan x} \]
\[\left(0.16666666666666666 \cdot x\right) \cdot x + \left(-0.00023644179894179894 \cdot {x}^{8} + \left(-0.0007275132275132275 \cdot {x}^{6} + \left(x \cdot x\right) \cdot \left(-0.06388888888888888 \cdot \left(x \cdot x\right)\right)\right)\right) \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x)
 :precision binary64
 (+
  (* (* 0.16666666666666666 x) x)
  (+
   (* -0.00023644179894179894 (pow x 8.0))
   (+
    (* -0.0007275132275132275 (pow x 6.0))
    (* (* x x) (* -0.06388888888888888 (* x x)))))))
double code(double x) {
	return (x - sin(x)) / tan(x);
}
double code(double x) {
	return ((0.16666666666666666 * x) * x) + ((-0.00023644179894179894 * pow(x, 8.0)) + ((-0.0007275132275132275 * pow(x, 6.0)) + ((x * x) * (-0.06388888888888888 * (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.00023644179894179894d0) * (x ** 8.0d0)) + (((-0.0007275132275132275d0) * (x ** 6.0d0)) + ((x * x) * ((-0.06388888888888888d0) * (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.00023644179894179894 * Math.pow(x, 8.0)) + ((-0.0007275132275132275 * Math.pow(x, 6.0)) + ((x * x) * (-0.06388888888888888 * (x * x)))));
}
def code(x):
	return (x - math.sin(x)) / math.tan(x)
def code(x):
	return ((0.16666666666666666 * x) * x) + ((-0.00023644179894179894 * math.pow(x, 8.0)) + ((-0.0007275132275132275 * math.pow(x, 6.0)) + ((x * x) * (-0.06388888888888888 * (x * x)))))
function code(x)
	return Float64(Float64(x - sin(x)) / tan(x))
end
function code(x)
	return Float64(Float64(Float64(0.16666666666666666 * x) * x) + Float64(Float64(-0.00023644179894179894 * (x ^ 8.0)) + Float64(Float64(-0.0007275132275132275 * (x ^ 6.0)) + Float64(Float64(x * x) * Float64(-0.06388888888888888 * 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.00023644179894179894 * (x ^ 8.0)) + ((-0.0007275132275132275 * (x ^ 6.0)) + ((x * x) * (-0.06388888888888888 * (x * x)))));
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[(0.16666666666666666 * x), $MachinePrecision] * x), $MachinePrecision] + N[(N[(-0.00023644179894179894 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.0007275132275132275 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(x * x), $MachinePrecision] * N[(-0.06388888888888888 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
\left(0.16666666666666666 \cdot x\right) \cdot x + \left(-0.00023644179894179894 \cdot {x}^{8} + \left(-0.0007275132275132275 \cdot {x}^{6} + \left(x \cdot x\right) \cdot \left(-0.06388888888888888 \cdot \left(x \cdot x\right)\right)\right)\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 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)} \]
  3. Applied egg-rr0.3

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

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

Alternatives

Alternative 1
Error0.4
Cost13312
\[\mathsf{fma}\left(0.16666666666666666 \cdot x, x, -0.06388888888888888 \cdot {x}^{4}\right) \]
Alternative 2
Error0.4
Cost960
\[\left(0.16666666666666666 \cdot x\right) \cdot x + \left(x \cdot x\right) \cdot \left(-0.06388888888888888 \cdot \left(x \cdot x\right)\right) \]
Alternative 3
Error0.4
Cost832
\[x \cdot \left(x \cdot \left(-0.06388888888888888 \cdot \left(x \cdot x\right)\right) + 0.16666666666666666 \cdot x\right) \]
Alternative 4
Error0.4
Cost704
\[\left(x \cdot x\right) \cdot \left(-0.06388888888888888 \cdot \left(x \cdot x\right) + 0.16666666666666666\right) \]
Alternative 5
Error0.7
Cost448
\[\frac{\left(x \cdot x\right) \cdot 0.5}{3} \]
Alternative 6
Error0.7
Cost320
\[\left(x \cdot 0.16666666666666666\right) \cdot x \]
Alternative 7
Error0.7
Cost320
\[\frac{x \cdot x}{6} \]

Error

Reproduce

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