% 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. 开源一个一个NodeJS 代理服务器扫描工具,可以用来***

    鉴于我朝很多网站访问不了,google等就是大悲剧,之前一直在用VPN,但是公司内网VPN被封,诸多工具也惨遭毒手..我辈怎能容忍. 目前只有代理没有被封,于是搞了个代理扫描工具并开源: https: ...

  2. Jmeter中的参数化常用的几种方式

    Jmeter中的参数化常用的几种方式,这里讲一下前两个方式,最后一个在csv参数化里已详细讲解. 1.用户参数 2.函数助手 3.CSV Data Set Config  一.用户参数 位置:添加-前 ...

  3. sosoapi的安装

    sosoapi简介及其用户手册:http://www.sosoapi.com/pass/help/manual.htm 该随笔的大概分为: 1.sosoapi的基础安装  2.sosoapi使用域名访 ...

  4. OracleService類

    using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Lin ...

  5. 17Web服务器端控件

    Web服务器端控件 Web服务器端控件 ASP.Net提供了两类服务器端控件:Html服务器端控件和Web服务器端控件.由于Web服务器端控件功能更强大,和Windows应用程序的控件使用方法类似,容 ...

  6. Linux命令学习(4):gzip压缩与解压

    版权声明:本文为博主原创文章,未经允许不得转载 引子 gzip是Linux系统中最常用也是高效的压缩压缩命令.早期Linux系统中主要使用compress命令压缩,得到后缀为“.Z”的压缩文件,但是后 ...

  7. assert.throws()函数详解

    assert.throws(block[, error][, message]) Node.js FS模块方法速查 期望 block 函数抛出一个错误. 如果指定 error,它可以是一个构造函数.正 ...

  8. MySQL-----用户和授权管理

    用户管理: 创建用户:  create user '用户名'@'用户pc的ip地址(ip可以写精准点的,也可以是网段的,也可以写一个‘’%‘’提所有)' identified(设置密码) by '密码 ...

  9. MySQL简单查询和单表查询

    MySQL记录操作 概览 MySQL数据操作: DML 在MySQL管理软件中,可以通过SQL语句中的DML语言来实现数据的操作,包括 使用INSERT实现数据的插入 UPDATE实现数据的更新 使用 ...

  10. pandas的合并、连接、去重、替换

    import pandas as pd import numpy as np # merge合并 ,类似于Excel中的vlookup df1 = pd.DataFrame({'key': ['K0' ...