# How to perform this summation in Julia

**URL:** <https://discourse.julialang.org/t/how-to-perform-this-summation-in-julia/81746>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 26, 2022, 8:24pm UTC](https://discourse.julialang.org/t/how-to-perform-this-summation-in-julia/81746 "2022-05-26T20:24:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leticia-maria](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leticia-maria/32/30981_2.png) [@Leticia-maria](https://discourse.julialang.org/u/Leticia-maria)\
**Post date:** [May 26, 2022, 8:24pm UTC](https://discourse.julialang.org/t/how-to-perform-this-summation-in-julia/81746/1 "2022-05-26T20:24:39Z")

</div>

```nohighlight
    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`)).

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [May 26, 2022, 8:36pm UTC](https://discourse.julialang.org/t/how-to-perform-this-summation-in-julia/81746/2 "2022-05-26T20:36:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Post date:** [May 27, 2022, 1:34am UTC](https://discourse.julialang.org/t/how-to-perform-this-summation-in-julia/81746/3 "2022-05-27T01:34:53Z")

</div>

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