Babylonian Method!

Last week the teacher gave us another problem to work on. As the title suggests, we had to create a function that would return the approximate square root of a number, using the Babylonian Method.

First I had to understand exactly how  the method works, so I watched this video:

However, I still didn’t understand how I would know when it was accurate enough. My classmate Elu explained it to me, telling me that it should be when the difference between two successive answers gotten from the formula differed only by 0.0001 or less.

Having fully understood the mathematics, I proceeded to write my code:

babylonianbabylonian_run

2 thoughts on “Babylonian Method!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s