File:Examples for calculating the square root of 2 with Heron's method.svg

Summary

Description
English: First elements of the sequence we get, when we calculate with Heron's Method via the recursion with the starting points , and .
Date
Source Own work
Author Stephan Kulla (User:Stephan Kulla)
SVG development
InfoField
Source code
InfoField

Python code

import numpy as np
import matplotlib.pyplot as plt

n_max = 5.0

def square_root_seg(a, x_0):
    x_n = x_0

    while True:
        yield x_n
        x_n = (x_n + a / x_n) / 2.0

ns = np.arange(0, n_max + 0.01, 1.)

plt.plot([0,n_max],[np.sqrt(2),np.sqrt(2)], color="black")

for x_0 in [ 2.0, 4.0, 8.0 ]:
    xs = np.fromiter(square_root_seg(2.0, x_0), np.float, ns.size)
    plt.plot(ns, xs, "o", label="$x_0=%d$" % int(x_0))

plt.text(7.2, np.sqrt(2)-0.1, "$\sqrt{2}$")
plt.legend(loc='upper right')
plt.savefig("Examples for calculating the square root of 2 with Heron's method.svg")

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Category:CC-Zero#Examples%20for%20calculating%20the%20square%20root%20of%202%20with%20Heron's%20method.svgCategory:Self-published work
Category:Heron's method
Category:CC-Zero Category:Heron's method Category:Self-published work Category:Valid SVG created with Matplotlib code