Problem:
I wanted to program these 2 subroutines shown below and each was to return a function expression:
AnIntegrand[n0_] := Module[{n = N[n0]}, Return[6 t^2 Cos[2*n*t*Pi]];];
BnIntegrand[n0_] := Module[{n = N[n0]}, Return[6 t^2 Sin[2*n*t*Pi]];];
Before everything looked like the code above, however, I first created the first subroutine, then I copied and pasted the first subroutine below the first subroutine and changed the Cos to Sin, but I forgot to change the subroutine name from AnIntegrand to BnIntegrand. So it first looked like this:
AnIntegrand[n0_] := Module[{n = N[n0]}, Return[6 t^2 Cos[2*n*t*Pi]];];
AnIntegrand[n0_] := Module[{n = N[n0]}, Return[6 t^2 Sin[2*n*t*Pi]];];
So when I tested the output of AnIntegrand[1], it gave me the expression in sine function which defined in the second "AnIntegrand" subroutine. As I spotted my mistake, I changed the name of the second subroutine to "BnIntegrand" so that the code finally looked like the one first mentioned. Unfortunately, as I tested the output of AnIntegrand[1], it never went throught the subroutine AnIntegrand to output the cos expression, but instead it kept jumping straightly to the subroutine BnIntegrand gaving the sin expression regardless the page had been refreshed and regardless it was the AnIntegrand being called and not the BnIntegrand being called.
Next, 3 strange things also occurred as I tried to fix this annoyance. First, even with I deleted both subroutines, as I call AnIntegrand[1] again, it still gave the sine expression! I supposed since both subroutines were deleted, there should be an warning or error when I called AnIntegrand[1], but apparently it hadn't. Second, when I only deleted the BnIntegrand subroutine and called AnIntegrand[1] again, I expected to see the cos expression only, but again it gave the sin expression from the BnIntegrand! Third, the subroutine title BnIntegrand remained in blue color while the subroutine title AnIntegrand stayed normally black color and I don't know what it suggested but I believe that blue color was what caused the trouble.
Here, that's what the program can give regardless any changes I have done so far:
In[1]:=AnIntegrand[1]
Out[1]:=6 t^2 Sin[6.28319 t]
Then I opened a new notebook and copied and pasted only the AnIntegrand subroutine and called AnItegrand[1] for testing, and it gave:
6 t$10508^2 Cos[6.28319 t$10508] with $ sign after the t!
That's even more inexplicable, because for the AnIntegrand subroutine, I saw it did give 6 t^2 Cos[6.28319 t] nicely in the old notebook before I created the mess when doing the second subroutine.
Help, please.
I want: when I called AnIntegrand[1], it should give 6 t^2 Cos[6.28319 t]; when I called BnIntegrand[1], it should give 6 t^2 Sin[6.28319 t].

Returnin your function definitions. Mathematica will automatically return the value of last statement in a function. – image_doctor Jan 29 at 7:59