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 ...
随机推荐
- Redis C客户端API - God's blog - 博客频道 - CSDN.NET
Redis C客户端API - God's blog - 博客频道 - CSDN.NET Redis安装步骤: 1.redis server安装 wget http://redis.googlecod ...
- js获取当前日期,网页头部用
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- SDUTOJ 1489 求二叉树的先序遍历
<img src="http://img.blog.csdn.net/20141014212549703?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi ...
- oracle 主键删除,联合主键的创建
1,主键的删除 ALTER TABLE TABLENAME DROP PRIMARY_KEY 运行上面的SQL能够删除主键:假设不成功能够用 ALTER TABLE TABLENAME DROP C ...
- Swift - 复杂数据类型说明(数组,字典,结构体,枚举)
1,数组 - Array 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 var types ...
- 绘制FastMM内存分配流程图(小块内存分配)
http://blog.csdn.net/henreash/article/details/38751353
- XML SelectSingleNode的使用 根据节点属性获取该节点
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Form ...
- Automatic logon configuration on Linux OS
Automatic logon configuration on Linux OS 1. Regarding to DSA: a) ssh-keygen -t dsa b) cat ~/.ssh/i ...
- 依据不同的操作系统读取配置文件/java读取属性文件代码
package cn.com.css.common.util; /** * @brief OSEnum.java 操作系统的枚举 * @attention * @author 涂作权 * @d ...
- 检查java class的版本号
补丁总是会一遍又一遍的打,越打越多 有时候,就担心有人不小心把高版本的class打到低版本jre运行的环境中 简单写了点代码,检查文件夹中class的版本号 package org.wee.cv; i ...