MIT 6.00.1X --Week 3
来源:互联网 发布:win10系统优化固态 编辑:程序博客网 时间:2024/06/09 20:03
NEWTON-RAPHSON ROOT FINDING
- General approximation algorithm to find roots of a
polynomial in one variable
- Want to find r such that p(r) = 0
- Newton showed that if g is an approximation to the
root, theng−p(g)/p′(g)
is a better approximation; where p’ is derivative of p.
# Lecture 3.7, slide 3# Newton-Raphson for square rootepsilon = 0.01y = 24.0guess = y/2.0while abs(guess*guess - y) >= epsilon: guess = guess - (((guess**2) - y)/(2*guess)) print(guess)print('Square root of ' + str(y) + ' is about ' + str(guess))
Bisection search
# lecture 3.6, slide 2# bisection search for square rootx = 12345epsilon = 0.01numGuesses = 0low = 0.0high = xans = (high + low)/2.0while abs(ans**2 - x) >= epsilon: print('low = ' + str(low) + ' high = ' + str(high) + ' ans = ' + str(ans)) numGuesses += 1 if ans**2 < x: low = ans else: high = ans ans = (high + low)/2.0print('numGuesses = ' + str(numGuesses))print(str(ans) + ' is close to square root of ' + str(x))
普通迭代
x = 25epsilon = 0.01step = 0.1guess = 0.0while guess <= x: if abs(guess**2 -x) < epsilon: break else: guess += stepif abs(guess**2 - x) >= epsilon: print 'failed'else: print 'succeeded: ' + str(guess)
FLOATING POINT ACCURACY
浮点数的二进制表示与还原
先挖个坑。。。
参考《计算机专业导论之思维与系统》
阅读全文
0 0
- MIT 6.00.1X --Week 3
- MIT 6.00.1x 笔记
- MIT-6.00.1x-L11-P6
- [MIT 6.00.1X]学习地址
- MIT 6.00 1x Lecture 3 - Simple Algorithms 简单算法 学习笔记
- MIT 6.00.1x 计算机科学和Python编程导论 Set 3
- MIT 6.00 1x Lecture 4 - Functions 学习笔记
- MIT 6.00 1x Lecture 5 Recursion 递归 学习笔记
- MIT 6.00 1x Lecture 6 Objects 对象 学习笔记
- MIT 6.00 1X Lecture 7 Debugging 学习笔记
- MIT 6.001.x学习笔记-1A
- MIT 6.001.x 学习笔记-1B
- MIT 6.00.1x 计算机科学和Python编程导论 Set 1
- MIT 6.00.1x 计算机科学和Python编程导论 Set 2
- MIT 6.00.1x 计算机科学和Python编程导论 Set 4
- MIT 6.00.1x 计算机科学和Python编程导论 Set 6
- 600x笔记(week-3 递归与对象)
- Algorithms - Week 3-1 Quicksort
- floyd算法
- 2017第十七届全国秋季食品添加剂和配料展(FIC秋季展)
- 运行WEB项目时访问路径后一直处于等待状态,网页无法显示出
- python datetime模块相关 mysql 时间戳等
- 数学建模基础
- MIT 6.00.1X --Week 3
- sh handle_data.sh: 2: handle_data.sh: Syntax error: Bad for loop variable
- redis安装
- String对象两种初始化方式的区别
- Shell_NotifyIcon 修改托盘图标失败的问题
- java输出utf-8的csv文件时,文件中有中文,excel打开文件乱码问题解决
- python IndexError: list assignment index out of range
- linux环境变量总结
- JRebel使用错误记录