3
$\begingroup$

I'm trying to find the list of x values not included in my domain of $0$ to $2\pi$. My current code is:

f[x_] := Cot[x]/Sin[x]
dom = FunctionDomain[{f[x], 0 <= x <= 2 π}, x, Reals]

domain

NumberLinePlot[{f[x] > 0, f[x] < 0, f[x] == 0}, {x, 0, 2 π}, 
  Ticks -> {{0, π/2, π, 3 π/2, 2 π}}]

Thr above does give me the domain and a broken up plot, but it would be even better to just get the complement of the domain. Is this possible?

$\endgroup$
3
$\begingroup$
domcomplement = Reduce[Not @ dom, x, Reals]

x < 0 || x > 2 Pi || Element[x / Pi, Integers]

Show[Plot[ConditionalExpression[f[x], dom], {x, -π, 3 π}, 
  Frame -> True, Axes -> False, 
  FrameTicks -> {{Automatic, Automatic}, {{0, π/2, π, 3 π/2, 2 π}, Automatic}}], 
 NumberLinePlot[domcomplement, {x, -π, 3 π}, PlotStyle -> Red, Spacings -> {-15, 1, 1, 1}], 
 PlotRangePadding -> Scaled[.1]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.