Exemple #1
0
from function import Function
import function

if __name__ == "__main__":

    print "please input the number that a,b,c,d for function"
    a, b, c, d = map(int, raw_input('input a,b,c,d=').split(","))
    func = Function(a, b, c, d)

    func.showinfo()

    while True:
        print "input l,r | l<r & f(l)*f(r)<0"
        l, r = map(float, raw_input('input l,r=').split(","))

        if (func.fnf(l) < func.fnf(r)) and (func.fnf(l) * func.fnf(r) < 0):
            print "correct"
            break
        else:
            print "wrong numbers (l>r or f(l)*f(r)>=0)"

    th = float(raw_input('please input threshold:'))

    k = 0
    results = []
    while r - l >= th:
        k += 1
        print("{0:4d},{1:8.5f},{2:8.5f},{3:8.5f}".format(k, l, r, r - l))
        center = (l + r) / 2.0
        results.append((k, center))
        if (func.fnf(l) * func.fnf(center) > 0):
Exemple #2
0
import function


if __name__=="__main__":
	
	print "please input the number that a,b,c,d for function"
	a,b,c,d = map(int, raw_input('input a,b,c,d=').split(","))
	func=Function(a,b,c,d)
	
	func.showinfo()

	while True:
		print "input l,r | l<r & f(l)*f(r)<0"
		l,r = map(float,raw_input('input l,r=').split(","))
	
		if (func.fnf(l)<func.fnf(r)) and (func.fnf(l)*func.fnf(r)<0):
			print "correct"
			break
		else:
			print "wrong numbers (l>r or f(l)*f(r)>=0)"

	th = float(raw_input('please input threshold:'))
	

	k=0
	results=[]
	while r-l >= th:
		k+=1
		print("{0:4d},{1:8.5f},{2:8.5f},{3:8.5f}".format(k,l,r,r-l))
		center = (l+r)/2.0
		results.append((k,center))
Exemple #3
0
from function import Function
import function

if __name__ == '__main__':

    print "please input the number that a,b,c,d for function"
    a, b, c, d = map(int, raw_input('input a,b,c,d=').split(","))
    func = Function(a, b, c, d)

    func.showinfo()

    while True:
        print "input x,r | x<r & f(x)*f(r)<0"
        x, r = map(float, raw_input('input x,r=').split(","))

        if (func.fnf(x) < func.fnf(r)) and (func.fnf(x) * func.fnf(r) < 0):
            print "correct"
            break
        else:
            print "wrong numbers (x>r or f(x)*f(r)>=0)"

    th = float(raw_input('please input threshold:'))

    k = 0

    print "number of process, approximation, diff"

    print("{0:4d},{1:8.5f},{2}".format(k, x, "---"))

    approximations = []
Exemple #4
0
from function import Function
import function

if __name__ == '__main__':

	print "please input the number that a,b,c,d for function"
	a,b,c,d = map(int, raw_input('input a,b,c,d=').split(","))
	func=Function(a,b,c,d)

	func.showinfo()

	while True:
		print "input x,r | x<r & f(x)*f(r)<0"
		x,r = map(float,raw_input('input x,r=').split(","))
	
		if (func.fnf(x)<func.fnf(r)) and (func.fnf(x)*func.fnf(r)<0):
			print "correct"
			break
		else:
			print "wrong numbers (x>r or f(x)*f(r)>=0)"

	th = float(raw_input('please input threshold:'))


	k=0

	print "number of process, approximation, diff"

	print("{0:4d},{1:8.5f},{2}".format(k,x,"---"))
	
	approximations=[]