f[a_, b_] = Integrate[Sin[aPix]Sin[bPix], {x,0,1}];

This function does not work at some points. When I try to evaluate f[1,1], it says "Infinite expression 1/0 encountered."

How can I get around this? It should obviously return 1/2 at that point

  • 2
    $\begingroup$ First try f[a_, b_] = Integrate[Sin[a*Pi*x]Sin[b*Pi*x], {x,0,1}]; f[1,1] and then try f[a_, b_] := Integrate[Sin[a*Pi*x]Sin[b*Pi*x], {x,0,1}]; f[1,1] and then CAREFULLY compare those two, character by character. Understanding exactly why those results are so different when the input is so similar will be very important to your becoming more skilled with Mathematica. Wrapping Trace[...] around that and looking at what it shows will be difficult to understand, but it may give you hints about what happened in each of these. $\endgroup$
    – Bill
    Sep 17, 2020 at 0:27
  • 1
    $\begingroup$ SetDelayed , := work since Integrate[Sin[a*Pi*x] Sin[b*Pi*x], {x, 0, 1}] equal to (b Cos[b Pi] Sin[a Pi] - a Cos[a Pi] Sin[b Pi])/( a^2 Pi - b^2 Pi) so a=b is a removable singularity point. $\endgroup$
    – cvgmt
    Sep 17, 2020 at 1:27

1 Answer 1


In addition to the answers provided in comments, you can separately consider the case $a=b$

f[a_, b_] = Integrate[Sin[a Pi x] Sin[b Pi x], {x, 0, 1}]
f[a_, a_] = Integrate[Sin[a Pi x] Sin[a Pi x], {x, 0, 1}]

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.