Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wpforms-lite domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/ragipunal.com/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the businext domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/ragipunal.com/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/ragipunal.com/wp-includes/functions.php on line 6114
Python While Döngüsü ile Karakök Bulma - RAGIP ÜNAL

Blog

Python While Döngüsü ile Karakök Bulma

Aşağıda özetle √× hesaplamak için kullanılabilecek bir yaklaşımın adımlarını göreceksiniz.

  • r0=x/2 şeklinde bir yaklaşımla başlayalım.
  • Başlangıç tahmini yeterli değilse bunu izleyen r1, r2, r3 yaklaşımlarını izleyelim.

ri=(1/2)(ri+x/ri-1) şeklinde hesaplamaya devam edelim ve herhangi bir aşamadaki kök tahminimizin değeri r ise ve |x-r2|≤0.0001 ise işlemi durdurarak r’nin köke yeterince yakın olduğunu kabul edebiliriz.

Program:

x=input("Kare Kökü Hesaplanmasını istediğiniz sayıyı giriniz.")
x=float(x)
eps=input("Hassasiyet...")
eps=float(eps)
import math

r0=x/2
r=r0
while math.fabs(x-r*r)>eps:
    r0=r
    r=1.0/2.0*(r0+x/r0)
print(x, " Sayısının Katekökü ", r , " dir.")

Çıktı:

Kare Kökü Hesaplanmasını istediğiniz sayıyı giriniz.144
Hassasiyet...0.0001
144.0  Sayısının Katekökü  12.000000010666378  dir.

008_while.py

Leave A Comment

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir