Skip to main content
added 63 characters in body
Source Link
cvgmt
  • 84.1k
  • 6
  • 97
  • 179

RegionMember work for Interval.

  • RegionMember work for Interval.
f = Piecewise[{{1, RegionMember[Interval[{0, 1}]]@{x}}}, 0];
g = Piecewise[{{1, 0 < x < 1}}, 0];
 
Plot[{f, g}, {x, 0, 2}, 
 PlotStyle -> {Directive[Red, Opacity[.2], AbsoluteThickness[10]], 
   Blue}]

enter image description here

When we want to use Element, we need to write such as Element[{1/2}, Interval[{0, 1}]] (*True *).

  • When we want to use Element, we need to write such as Element[{1/2}, Interval[{0, 1}]] (*True *).
h = Piecewise[{{1, Element[{x}, Interval[{0, 1}]]}}, 0];
Plot[h, {x, 0, 2}]

enter image description here

RegionMember work for Interval.

f = Piecewise[{{1, RegionMember[Interval[{0, 1}]]@{x}}}, 0];
g = Piecewise[{{1, 0 < x < 1}}, 0];
 
Plot[{f, g}, {x, 0, 2}, 
 PlotStyle -> {Directive[Red, Opacity[.2], AbsoluteThickness[10]], 
   Blue}]

enter image description here

When we want to use Element, we need to write such as Element[{1/2}, Interval[{0, 1}]] (*True *).

h = Piecewise[{{1, Element[{x}, Interval[{0, 1}]]}}, 0];
Plot[h, {x, 0, 2}]

enter image description here

  • RegionMember work for Interval.
f = Piecewise[{{1, RegionMember[Interval[{0, 1}]]@{x}}}, 0];
g = Piecewise[{{1, 0 < x < 1}}, 0];
Plot[{f, g}, {x, 0, 2}, 
 PlotStyle -> {Directive[Red, Opacity[.2], AbsoluteThickness[10]], 
   Blue}]

enter image description here

  • When we want to use Element, we need to write such as Element[{1/2}, Interval[{0, 1}]] (*True *).
h = Piecewise[{{1, Element[{x}, Interval[{0, 1}]]}}, 0];
Plot[h, {x, 0, 2}]

enter image description here

added 63 characters in body
Source Link
cvgmt
  • 84.1k
  • 6
  • 97
  • 179

RegionMember work for Interval.

f = Piecewise[{{1, RegionMember[Interval[{0, 1}]]@{x}}}, 0];
g = Piecewise[{{1, 0 < x < 1}}, 0]; 

Plot[{f, g}, {x, 0, 2}, 
 PlotStyle -> {Directive[Red, Opacity[.2], AbsoluteThickness[10]], 
   Blue}]

enter image description here

When we want to use Element, we need to write such as Element[{1/2}, Interval[{0, 1}]] (*True *).

h = Piecewise[{{1, Element[{x}, Interval[{0, 1}]]}}, 0];
Plot[h, {x, 0, 2}]

enter image description here

RegionMember work for Interval.

f = Piecewise[{{1, RegionMember[Interval[{0, 1}]]@{x}}}, 0];
g = Piecewise[{{1, 0 < x < 1}}, 0];
Plot[{f, g}, {x, 0, 2}, 
 PlotStyle -> {Directive[Red, Opacity[.2], AbsoluteThickness[10]], 
   Blue}]

enter image description here

RegionMember work for Interval.

f = Piecewise[{{1, RegionMember[Interval[{0, 1}]]@{x}}}, 0];
g = Piecewise[{{1, 0 < x < 1}}, 0]; 

Plot[{f, g}, {x, 0, 2}, 
 PlotStyle -> {Directive[Red, Opacity[.2], AbsoluteThickness[10]], 
   Blue}]

enter image description here

When we want to use Element, we need to write such as Element[{1/2}, Interval[{0, 1}]] (*True *).

h = Piecewise[{{1, Element[{x}, Interval[{0, 1}]]}}, 0];
Plot[h, {x, 0, 2}]

enter image description here

Source Link
cvgmt
  • 84.1k
  • 6
  • 97
  • 179

RegionMember work for Interval.

f = Piecewise[{{1, RegionMember[Interval[{0, 1}]]@{x}}}, 0];
g = Piecewise[{{1, 0 < x < 1}}, 0];
Plot[{f, g}, {x, 0, 2}, 
 PlotStyle -> {Directive[Red, Opacity[.2], AbsoluteThickness[10]], 
   Blue}]

enter image description here