Plot is empty (probably) due to poor function definition

I am trying to plot my response $x(t)$ as a function of system parameter $M_0$. Here is my code to regenerate my problem

ω0 = Sqrt[kn/Jn];

β[j_] = 1/
Sqrt[(1 - ((j 2 Pi)/(τ ω0))^2)^2 + (2 δ (
j 2 Pi)/(τ ω0))^2];

ϕ[j_] =
ArcTan[(2 δ (j 2 Pi)/(τ ω0))/(
1 - ((j 2 Pi )/(τ ω0))^2)];
kn = 47000

ajj[j_, M0_] = -((
M0 (-2 j Cos[(j π)/2]^2 - Sin[j π] + j^2 Sin[j π] +
3 Sin[2 j π] - 3 j^2 Sin[2 j π]))/(j (-1 + j^2) π));
bjj[j_, M0_] = (
M0 (-2 + 2 j^2 - Cos[j π] + j^2 Cos[j π] +
3 Cos[2 j π] - 3 j^2 Cos[2 j π] + j Sin[j π]))/(
j (-1 + j^2) π);

xAmp[t_, M0_,
num_] := (-2 M0 τ + 5 M0 π τ)/(π τ)/(2 kn) +
Sum[ajj[j, M0]/kn β[j] Cos[j 2 Pi t/τ - ϕ[j]], {j,
1, num}] +
Sum[bjj[j, M0]/kn β[j] Sin[j 2 Pi t/τ - ϕ[j]], {j,
1, num}]


Now xAmp should be a periodic function and my goal is to find out how the amplitude changes varying parameters M0 and kn. Yet the definition above leaves my plot for fixed value of M0

Plot[xAmp[t, 270, 100], {t, 0, \[Tau]}, PlotRange -> All]


completely empty saying that an infinite expression 1/0 was encountered. I don't know where that infinite expression comes from because i calculated limits for all many many cases separately and none of them seemed problematic to me. So, how should I correct my xAmp definition in order to get at least something out and what is wrong with my definition?

• Your ajj and bjj functions have a (j (-1 + j^2) π) in the denominator, which is zero when you sum from j=1 – Jason B. Apr 22 '16 at 8:14
• @JasonB yes, but limits: Limit[ajj[j,210],j->1] and Limit[bjj[j,210],j->1] are both finite and real. – skrat Apr 22 '16 at 8:26
• aha, but you didn't ask for the Limit did you? – Jason B. Apr 22 '16 at 8:28

Your ajj and bjj functions have a (j (-1 + j^2) π) in the denominator, which is zero when you sum from j=1. Consider this term,

x = ajj[j, 40]
(* -((40 (-2 j Cos[(j π)/2]^2 - Sin[j π] + j^2 Sin[j π] +
3 Sin[2 j π] - 3 j^2 Sin[2 j π]))/(j (-1 + j^2) π)) *)


Now if you simply substitute 1 for j in the above, the system will see that zero in the denominator and complain.

x /. j -> 1

During evaluation of Power::infy: Infinite expression 1/0 encountered. >>

During evaluation of Infinity::indet: Indeterminate expression (0 ComplexInfinity)/π encountered. >>
(* Indeterminate *)


But if you take the Limit instead,

Limit[x, j -> 1]
(* 0 *)


there is no problem. So redefine your functions,

ajj[j_, M0_] :=
Limit[-((M0 (-2 jj Cos[(jj π)/2]^2 - Sin[jj π] +
j^2 Sin[jj π] + 3 Sin[2 jj π] -
3 jj^2 Sin[2 jj π]))/(jj (-1 + jj^2) π)), jj -> j];
bjj[j_, M0_] :=
Limit[(M0 (-2 + 2 jj^2 - Cos[jj π] + jj^2 Cos[jj π] +
3 Cos[2 jj π] - 3 jj^2 Cos[2 jj π] +
jj Sin[jj π]))/(jj (-1 + jj^2) π), jj -> j];


and you can now evaluate the functions just fine,

ajj[1, 40]
(* 0 *)

• Ok that explains my questions. Tthank you. I was thinking about using Limits but I got completely confused when limits ajj[j] anf bjj[j] were both finite and real. – skrat Apr 22 '16 at 8:47
• Glad to help, but be careful in using the Limit function, since it doesn't fully localize the variable. I had first tried it with ajj[jj_, M0_]:= Limit[......., j->jj] and it ran into trouble since the summation variable is also j. – Jason B. Apr 22 '16 at 8:50