How to perform this summation in Julia

    Kint  = b*((2*(lB+mB+nB))+3)*Sxyz(RA, RB, a, b, lA, lB, mA, mB, nA, nB)
    #print("$Kint \n")

    Kint -= (2*(b^2))*Sxyz(RA, RB, a, b, lA, lB+2, mA, mB, nA, nB)
    Kint -= (2*(b^2))*Sxyz(RA, RB, a, b, lA, lB, mA, mB+2, nA, nB)
    Kint -= (2*(b^2))*Sxyz(RA, RB, a, b, lA, lB, mA, mB, nA, nB+2)

    Kint -= (1/2)*(lB*(lB-1))*Sxyz(RA, RB, a, b, lA, lB-2, mA, mB, nA, nB)
    Kint -= (1/2)*(mB*(mB-1))*Sxyz(RA, RB, a, b, lA, lB, mA, mB-2, nA, nB)
    Kint -= (1/2)*(nB*(nB-1))*Sxyz(RA, RB, a, b, lA, lB, mA, mB, nA, nB-2)

    return Kint
end

I was trying to perform a summation using this function, but when evaluating Kint, I noticed that the value I get was the initial Kint (Kint = b*((2*(lB+mB+nB))+3)*Sxyz(RA, RB, a, b, lA, lB, mA, mB, nA, nB)).

There’s nothing obviously wrong about those computations. If you’re not getting the expected result my advise is to print the value after each term to track down where things go wrong.

1 Like

For what it’s worth, you can use println("abc") instead of print("abc\n").