Algorithm problem

i am getting nan as theta by this algorithm
link for algo: https://ide.codingblocks.com/s/130887