matlab secant method
% Matlab script to illustrate the secant 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.
% this function is hard-coded in the script.
g=9.8065;
k=0.00341;
% f(x)=log(cosh(t*srt(g*k)))/k;
format long
% get user input
M = input('Please enter the number whose square root you want: ')
t0 = input('Please enter the first of two starting guesses: ')
t1 = input('Please enter the second of two starting guesses: ')
% iteration counter
k = 1
% compute first secant iterate to enter loop
s = (((log(cosh(t1*sqrt(g*k)))/k)-M)-((log(cosh(t0*sqrt(g*k)))/k)-M) )/(t1-t0);
% s = ( (x1^2-M) - (x0^2-M) ) / (x1 - x0);
t = t1 - (((log(cosh(t1*sqrt(g*k)))/k)-M))/s
% x = x1 - (x1^2-M)/s
disp('Hit return to continue')
pause
while abs(t-t1) > eps*abs(t),
% reset guesses
t0 = t1;
t1 = t;
% increment iteration counter
k = k + 1
% compute and display secant iterate
s = (((log(cosh(t1*sqrt(g*k)))/k)-M)-((log(cosh(t0*sqrt(g*k)))/k)-M) )/(t1-t0);
% s = ( (x1^2-M) - (x0^2-M) ) / (x1 - x0);
% x = x1 - (x1^2-M)/s
t = t1 - (((log(cosh(t1*sqrt(g*k)))/k)-M))/s
disp('Hit return to continue')
pause
end
matlab secant method的更多相关文章
- Secant Method (Website)
Secant Method: https://www.youtube.com/watch?v=qC9xnsfOd30 Secant Method : http://mathworld.wolfram ...
- matlab Newton method
% Matlab script to illustrate Newton's method % to solve a nonlinear equation % this particular scri ...
- The Secant Method(正割法、弦截法) 附C语言代码
弦截法是一种求方程根的基该方法,在计算机编程中经常使用. 他的思路是这种:任取两个数x1.x2,求得相应的函数值f(x1).f(x2).假设两函数值同号,则又一次取数.直到这两个函数值异号为止. 连接 ...
- Todd's Matlab讲义第6讲:割线法
割线法 割线法求解方程\(f(x)=0\)的根需要两个接近真实根\(x^\*\)的初值\(x_0\)和\(x_1\),于是得到函数\(f(x)\)上两个点\((x_0,y_0=f(x_0))\)和\( ...
- 牛顿方法(Newton-Raphson Method)
本博客已经迁往http://www.kemaswill.com/, 博客园这边也会继续更新, 欢迎关注~ 牛顿方法是一种求解等式的非常有效的数值分析方法. 1. 牛顿方法 假设\(x_0\)是等式的 ...
- 非线性方程(组):一维非线性方程(二)插值迭代方法 [MATLAB]
一般而言,方程没有能够普遍求解的silver bullet,但是有几类方程的求解方法已经非常清晰确凿了,比如线性方程.二次方程或一次分式.一次方程可以直接通过四则运算反解出答案,二次方程的求根公式也给 ...
- Secant 方法求方程多个根
Secant 方法介绍 Secant Method 函数 Secant_Methods 简介 1.函数定义 [c, errColumn] = Secant_Method(f, a, b, N, con ...
- <<Numerical Analysis>>笔记
2ed, by Timothy Sauer DEFINITION 1.3A solution is correct within p decimal places if the error is l ...
- <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 ...
随机推荐
- 学习javascript语言精粹的笔记
1.枚举: 用for in 语句来遍历一个对象中所有的属性名,该枚举过程将会列出所有的属性也包括涵数和方法,如果我们想过滤掉那些不想要的值,最为常用的过滤器为hasOwnProperty方法,以及使用 ...
- TCP/IP笔记 二.网络层(1)
1. IP 1.1 配套协议 IP 是 TCP/IP 体系中两个最主要的协议之一 . 与 IP 协议配套使用的还有四个协议: (1)ARP (Address Resolution Protocol ...
- Ubuntu 安装和配置minicom
Ubuntu 安装和配置minicom 1 . 安装 Minicom 用新立得软件管理器下载minicom 2.配置Minicom shell下输入 minicom -s 打开配置界面 进入Seria ...
- 每天一个JavaScript实例-推断图片是否载入完毕
<!doctype html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- 断剑重铸之日,席卷朗朗乾坤之时--PHP学习一月漫记
传说中阿尔萨斯王子沉沦堕落之后,被巫妖王安置在冰冷的城堡中,静静地等待重出天日,它随身携带的宝剑也埋没与尘土之间,暗淡无光.他想起宝剑伴身,东征西战的峥嵘岁月,忆及如今身陷囹圄,一股怨念由心底升起,许 ...
- Attach()函数和Detach()函数的作用
基本就是把一个句柄绑定和解绑定于一个类对象上,是其可以使用MFC的函数而不是API 首先,你要明白Windows对象和MFC对象的区别.MFC对象实际上并没有把整个Windows对象都包装在其中,它只 ...
- 积累的VC编程小技巧之工具条和状态条
1.工具条和状态条中控件的添加: 方法⑴.只能在ToolBar里创建控件:首先,在ToolBar中创建一个Button,其ID为ID_TOOL_COMBO(我们要将创建的控件放在该Button的位置上 ...
- 让AllocateHwnd接受一般函数地址作参数(105篇博客)
http://www.xuebuyuan.com/1889769.html Classes单元的AllocateHWnd函数是需要传入一个处理消息的类的方法的作为参数的,原型: function Al ...
- "Invalid username/password or database/scan listener not up"
文档 ID … 11.2 RAC DBconsole Creation Fails With Error: "Invalid username/password or ...
- QQ圈子降级为“应用”后应关注其隐私设置
在之前的QQ版本中,QQ圈子的权限设置在“系统设置”对话框的“权限设置”中,如图所示. 但是在更新后的2013SP1版本中,“系统设置”对话框中的“权限设置”已经没有了“圈子权限” QQ圈子成了应用管 ...