iteraciones.py - import math from sympy import def bisecciones(f,xl,xu,n,maxit x=symbols\"x es=.5*10(2-n ea=100 itera=1 print\"itera xl xu while ea>es and

# iteraciones.py - import math from sympy import def...

• 1

This preview shows page 1 out of 1 page.

import math from sympy import * def bisecciones(f,xl,xu,n,maxit): x=symbols("x") es=.5*10**(2-n) ea=100 itera=1 print("itera xl xu") while ea>es and itera<maxit: xm=(xl+xu)/2 fxl=float(f.subs(x,xl)) fxm=float(f.subs(x,xm)) mult=fxl*fxm if itera>1: ea=abs((xm-xm_ant)/xm)*100 #print(itera,xl,"\t",xm,"\t",ea,"\t",fxl,"\t",fxm) print( "{:7.4f} {:7.4f} {:6.4f} {:7.4f} {:7.4f} %".format(itera,xl,xu,fxl,xm,fxm,ea)) mult=fxl*fxm if mult>0: xu=xm elif mult<0: xu=xm xm_ant=xm itera=itera+1 return xm,ea,itera-1 def main():

#### You've reached the end of your free preview.

Want to read the whole page?

• Fall '19
• Xiaomi Navares

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern