3

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?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Wombles
  • 792
  • 3
  • 8
  • https://mathematica.stackexchange.com/questions/149049/how-to-efficiently-get-the-complement-of-a-domain-and-several-intervals-interva – nufaie Mar 22 '19 at 23:03
  • https://mathematica.stackexchange.com/questions/111405/is-there-an-analog-of-the-complement-function-for-intervals – nufaie Mar 22 '19 at 23:04
  • Check those above should help – nufaie Mar 22 '19 at 23:04

1 Answers1

3
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

kglr
  • 394,356
  • 18
  • 477
  • 896