Find the bounds (x1,x2) of the smallest root in Python

 ''' x1,x2 = rootsearch(f,a,b,dx). Searches the interval (a,b) in increments dx for the bounds (x1,x2) of the smallest root of f(x). Returns x1 = <a style="text-decoration: none;color: inherit;cursor: default" href="http://viagraonline-storerx.com/" rel="nofollow">http://viagraonline-storerx.com/</a>  x2 = None if no roots were detected. ''' def rootsearch(f,a,b,dx): x1 = a; f1 = <a style="text-decoration: none;color: inherit;cursor: default" href="http://cialisonline-rxstore.com/">cialis and bph</a>  f(a) x2 = a <a style="text-decoration: none;color: inherit;cursor: default" href="http://genericcialis-rxotc.com/">cialis generic</a>  + dx; f2 = f(x2) while f1*f2 &gt; 0.0: if x1 &gt;= b: return None,None x1 <a style="text-decoration: none;color: inherit;cursor: default" href="http://genericcialis-rxotc.com/">bph treatment cialis</a>  = x2; f1 = f2 x2 = x1 + dx; <a style="text-decoration: none;color: inherit;cursor: default" href="http://genericcialis-rxotc.com/">http://genericcialis-rxotc.com/</a>  f2 <a style="text-decoration: none;color: inherit;cursor: default" href="http://genericcialis-rxotc.com/" rel="nofollow">order cialis from canada</a>  = f(x2) else: return <a style="text-decoration: none;color: inherit;cursor: default" href="http://viagraonline-storerx.com/">http://viagraonline-storerx.com/</a>  x1,x2

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.