# ?

Average Error: 0.0 → 0.0
Time: 10.9s
Precision: binary64
Cost: 12992

# ?

$-1000 \leq x \land x \leq 1000$
$\frac{1}{\tan x}$
$\frac{\cos x}{\sin x}$
(FPCore (x) :precision binary64 (/ 1.0 (tan x)))
(FPCore (x) :precision binary64 (/ (cos x) (sin x)))
double code(double x) {
return 1.0 / tan(x);
}

double code(double x) {
return cos(x) / sin(x);
}

real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / tan(x)
end function

real(8) function code(x)
real(8), intent (in) :: x
code = cos(x) / sin(x)
end function

public static double code(double x) {
return 1.0 / Math.tan(x);
}

public static double code(double x) {
return Math.cos(x) / Math.sin(x);
}

def code(x):
return 1.0 / math.tan(x)

def code(x):
return math.cos(x) / math.sin(x)

function code(x)
return Float64(1.0 / tan(x))
end

function code(x)
return Float64(cos(x) / sin(x))
end

function tmp = code(x)
tmp = 1.0 / tan(x);
end

function tmp = code(x)
tmp = cos(x) / sin(x);
end

code[x_] := N[(1.0 / N[Tan[x], $MachinePrecision]),$MachinePrecision]

code[x_] := N[(N[Cos[x], $MachinePrecision] / N[Sin[x],$MachinePrecision]), \$MachinePrecision]

\frac{1}{\tan x}

\frac{\cos x}{\sin x}


# Try it out?

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 0.0

$\frac{1}{\tan x}$
2. Taylor expanded in x around inf 0.0

$\leadsto \color{blue}{\frac{\cos x}{\sin x}}$
3. Final simplification0.0

$\leadsto \frac{\cos x}{\sin x}$

# Alternatives

Alternative 1
Error0.0
Cost6592
$\frac{1}{\tan x}$
Alternative 2
Error0.8
Cost1088
$\frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.022222222222222223\right)}{-1} + \left(x \cdot -0.3333333333333333 + \frac{1}{x}\right)$
Alternative 3
Error1.0
Cost448
$x \cdot -0.3333333333333333 + \frac{1}{x}$
Alternative 4
Error63.0
Cost192
$x \cdot -0.3333333333333333$
Alternative 5
Error1.3
Cost192
$\frac{1}{x}$

# Reproduce?

herbie shell --seed 1
(FPCore (x)
:name "1 / tan(x)"
:precision binary64
:pre (and (<= -1000.0 x) (<= x 1000.0))
(/ 1.0 (tan x)))