# r squared trendline - How does it actually function?

Greetings all,

I would like to have a deeper understanding on how the r² is actually calculated.

On wikipedia, https://en.wikipedia.org/wiki/Coeffic..., it presents a calculation routine:

- r²=1-SSres/SStot, where SSres is the sum of (real y - adjusted y) and SStot is the sum of (real y - average real y).

By doing this, I have got a quite different different number from the one coming with the automatic trendline option. During my bachelor years I remember being there different ways to calculate the r². Is there a way for me to dig into the functions code that returns this r² value? I believe it might be possible to do, but I have never ventured myself into these dark waters.

Looking forward a concise answer. Thanks in advance, Community.

Juliano Finck