# Math-gasm

Have you been in a place where you are so frustrated that you didn’t get a solution for a math problem in school? And wondered where in the hell we would use calculus or linear algebra?

I know I have been there!

Today, I was just trying to pick up a new programming language. After some basics of how to declare variables, basic loops and conditional statements. I reached a point where I was given an exercise to write a program in to find the square root of a number.

There was an explanation of an algorithm on how to do the same, which was pretty straight forward.

Assume we are trying to figure out the square root of a number ‘x’

- Pick an arbitrary value, let’s say ‘z’.
- Keep iterating and apply the formula z = z-((z*z)-x)/(2*z)).
- There will be a point where the value of ‘z’ will hardly change, meaning you are close enough to the square root.

Here is a draft piece of code for this, if you are interested:

I implemented the algorithm and got the desired output, but my curiosity was kindled on what exactly it is and how it worked?

I looked it up, it was called **‘****Newton’s method****’. **To be honest, I did not understand anything of it initially, but then I started digging for more information.

I am not going to explain the method. I found a nice video explaining it in general (not just for square root, but to figure out the root of an equation).

I read the wikipedia article after going through this video again and it all made sense. I was just flabbergasted of the usage of calculus. I never thought I would use calculus after school/college, I was wrong. I loved it.

I am just math-gasm-ed.

Thanks for reading! Please clap if you were also math-gasm-ed! :)