% Matlab script to illustrate Newton's method
% to solve a nonlinear equation % this particular script finds the square root of a number M
% (input by the user) % note that the function we are trying to zero is f(x) = x^2 - M.
% its derivative is f'(x) = 2*x.
% these functions are hard-coded in the script. format long % get user input
M = input('Please enter the number whose square root you want: ')
x0 = input('Please enter starting guess: ') % iteration counter
k = 1
% compute first Newton iterate to enter loop
x = x0 - (x0^2-M)/(2*x0)
disp('Hit return to continue')
pause while abs(x-x0) > eps*abs(x),
% reset guess to old iterate
x0 = x;
% increment iteration counter
k = k + 1
% compute and display Newton iterate
x = x0 - (x0^2-M)/(2*x0)
disp('Hit return to continue')
pause
end

matlab Newton method的更多相关文章

  1. Apply Newton Method to Find Extrema in OPEN CASCADE

    Apply Newton Method to Find Extrema in OPEN CASCADE eryar@163.com Abstract. In calculus, Newton’s me ...

  2. Matlab Newton‘s method

    定义函数 function y=f(x) y=f(x).%函数f(x)的表达式 end function z=h(x) z=h(x).%函数h(x)的表达式 end 主程序 x=X;%迭代初值 i=0 ...

  3. matlab secant method

    % Matlab script to illustrate the secant method % to solve a nonlinear equation % this particular sc ...

  4. Newton法(牛顿法 Newton Method)

               1.牛顿法应用范围                          牛顿法主要有两个应用方向:1.目标函数最优化求解.例:已知 f(x)的表达形式,,求 ,及g(x)取最小值时 ...

  5. Newton‘ method 的优缺点

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzE1Mjg5NQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...

  6. <<Numerical Analysis>>笔记

    2ed,  by Timothy Sauer DEFINITION 1.3A solution is correct within p decimal places if the error is l ...

  7. <Numerical Analysis>(by Timothy Sauer) Notes

    2ed,  by Timothy Sauer DEFINITION 1.3A solution is correct within p decimal places if the error is l ...

  8. .NET数据挖掘与机器学习开源框架

    1.    数据挖掘与机器学习开源框架 1.1 框架概述 1.1.1 AForge.NET AForge.NET是一个专门为开发者和研究者基于C#框架设计的,他包括计算机视觉与人工智能,图像处理,神经 ...

  9. 02(c)多元无约束优化问题-牛顿法

    此部分内容接<02(a)多元无约束优化问题>! 第二类:牛顿法(Newton method) \[f({{\mathbf{x}}_{k}}+\mathbf{\delta })\text{ ...

随机推荐

  1. java实现的判断括号是否成对的代码,()[]{}都可以

    本来想找找现成的,去,都写的好复杂.自己写一个吧.挺有成就感.哈哈 package com.test.jiexi; import java.util.Stack; public class Check ...

  2. opencv-flag

    http://blog.csdn.net/yiyuehuan/article/details/43701797 在Mat类中定义了这样一个成员变量: /*! includes several bit- ...

  3. Java IO(三)--字节流基本使用

    I/O流分类: InputStream和Read的子类都有read(),用来读取单个字节或字节数组 OutputStream和write的子类都有write(),用来写入单个字节或字节数组 一般都是通 ...

  4. vue全选和取消全选

    代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...

  5. Linux C下变量和常量的存储的本质

    源代码 #cat main.c #include <stdio.h> int i = 100; int main(void) { func(); return 0; } #cat func ...

  6. Linux C动态链接库实现一个插件例子

    实现一个简单的计算动态链接库:升级动态链接库后,在不重新编译主程序的情况下,直接生效. lib库: #cat math.c #include <stdio.h> int add(int x ...

  7. jquery中ajax原生代码的分析模仿

    function ajax(obj){     var defaults = {         url: "#",         data: {},         type: ...

  8. MATLAB优化——减少for的使用

    Table of Contents 1. MATLAB 2. 矩阵计算--全0行整体替换 MATLAB MATLAB作为一个强大的工具(可惜是收费的),在矩阵运算.绘制函数和数据.实现算法.创建用户界 ...

  9. mui.openWindow的html5+和web传参的兼容

    mui.openWindow兼容web&plus环境下的页面传参 背景介绍 刚刚好要写个微信公众号和html5+兼容的项目 发现总是用localStorage传参不是事啊 太不优雅了 想了想还 ...

  10. python面向对象编程实例

    1.编写程序, 编写一个学生类, 要求有一个计数器的属性, 统计总共实例化了多少个学生 class Student: """学生类""" c ...