# start waarden a = 1.0 b = 10.0 # zet de tolerantie tol = 0.0001 # zet initiele loopconditie gadoor = True #4 loop while gadoor: #1 creeer punt c c = (a + b)/2 #2a bereken f(a), f(b) en f(c) Fa = (0.5 * (a ** 2)) -10 Fb = (0.5 * (b ** 2)) -10 Fc = (0.5 * (c ** 2)) -10 #2b kijk of we dicht bij nul zitten if abs(Fc) < 0.0001: gadoor = False #3 check het teken van fa en fc if abs(Fc) == Fc: b = c else: a = c # print het resultaat print 'eindoplossing voor c is: ', c
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question