1
$\begingroup$

If I have three criteria for the domain of $m\in\{1,2,3,4,5,6,...,22\}$ as

$$f(m)= \cos \left(\frac{\pi ^5 m}{4}\right)\quad for \quad m=3,6,12,15,21$$ $$g(m)=\frac{1}{\sin \left(\frac{\pi m}{3}\right)}\quad for \quad m=1,2,4,5,7,8,10,11,13,14,16,17,19,20,22$$ $$h(m)=10\quad for \quad m=9,18$$

then how can I have one DiscretePlot for all $m\in\{1,2,3,4,5,6,...,22\}$, and then join the adjacent numbers.

f[m_] = Cos[(m (\[Pi]^5) )/4] for m = 3, 6, 12, 15, 21

g[m_] = Sin[(m \[Pi] )/3]^-1   for    m = 
  1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22

h[m_] = 10 for m = 9, 18

$\endgroup$

2 Answers 2

1
$\begingroup$
{domf, domg, domh} = {{3, 6, 12, 15, 21}, {1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16,
     17, 19, 20, 22}, {9, 18}};

pw[m_] := Piecewise[{{Cos[(m (π^5))/4], MemberQ[m]@domf},
     {Sin[(m π)/3]^-1, MemberQ[m]@domg},
     {10, MemberQ[m]@domh}}]

DiscretePlot[pw[m], {m, Range[22]}, PlotRange -> All]

enter image description here

Alternatively,

fgh[m : Alternatives @@ domf] := Cos[(m (π^5))/4]
fgh[m : Alternatives @@ domg] := Sin[(m π)/3]^-1
fgh[m : Alternatives @@ domh] := 10

DiscretePlot[fgh[m], {m, Range[22]}, PlotRange -> All]
same picture
$\endgroup$
1
$\begingroup$
list1 = {3, 6, 12, 15, 21};
list2 = {1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22};
list3 = {9, 18};
list = Union[list1, list2, list3];
f[m_ /; MemberQ[list1, m]] = Cos[(π^5 m)/4];
g[m_ /; MemberQ[list2, m]] = 1/Sin[(π m)/3];
h[m_ /; MemberQ[list3, m]] = 10;
DiscretePlot[{f[m], g[m], h[m]}, {m, list}, 
 PlotStyle -> {Red, Green, Blue}, PlotRange -> All]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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