Skip to content

Instantly share code, notes, and snippets.

@gceylan
Created March 27, 2012 17:33
Show Gist options
  • Select an option

  • Save gceylan/2218234 to your computer and use it in GitHub Desktop.

Select an option

Save gceylan/2218234 to your computer and use it in GitHub Desktop.
yeni pc ubuntu yokken :(
# -*- coding: cp1254 -*-
import math
import time
def f(x, sbt):
return math.e ** x - sbt
def regulaFalsi(sbt=5, a=1, b=2, iterasyon=100, epsilon=10 ** -9):
t1 = time.clock()
ind = 0
#regula falsi yöntemini uygulamaya başlıyoruz...
while ind < iterasyon:
c = (a * f(b, sbt) - b * f(a, sbt)) / (f(b, sbt) - f(a, sbt))
if abs(c) < epsilon:
print "KÖK:", c
break
if f(a, sbt) * f(c, sbt) < 0:
b = c
else:
a = c
ind += 1
t2 = time.clock()
print "KÖK:", c
print "time:", t2 - t1
regulaFalsi()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment