学习newton raphson and back eluer
% % time step https://ww2.mathworks.cn/matlabcentral/answers/184200-newton-raphson-loop-for-backward-euler
% h = (t_final - t_init)/n; % with n number of time steps
% % vectors
% t = [tinit zeros(,n)]; % time
% y = [yinit zeros(,n)]; % solution
% % Backward Euler loop
% for i = :n
% t(i+) = t(i) + h;
% y_temp = y(i) + h(f(t(i), y(i)));
% y(i+) = y(i) + h*f(t(i+), y_temp);
% end
% for i = :n
% error = ;
% tolerance = 1e-;
% t(i+) = t(i) + h;
% y_temp = y(i) + h*(f(t(i), y(i)));
% while error >= tolerance
% y(i+) = y(i) + h*f(t(i+), y_temp);
% error = abs(y(i+) - y_temp) % (local) absolute error
% y_temp = y(i+);
% end
% end % yold = y(i)+h*f(t(i),y(i));
% while error >= tolerance
% ynew = yold-(yold-(y(i)+h*f(t(i+),yold)))/(-h*df(t(i+),yold));
% error = abs(ynew-yold);
% yold=ynew;
% end
% y(i+) = ynew; %y'=y+2*x/y^2 x=[0,2] y(0)=1 https://wenku.baidu.com/view/d18cdaa10b4c2e3f5627632f.html
t_final=;
t_init=;
n=;
tolerance=0.0000001
h = (t_final - t_init)/n;
ti=t_init+h;
yold=+h*f(,);% yold = y(i)+h*f(t(i),y(i));
while error >= tolerance
ynew = yold-(yold-(y(i)+h*f(t(i+),yold)))/(-h*df(t(i+),yold));
error = abs(ynew-yold);
yold=ynew;
end
y(i+) = ynew;
上面代码应该怎样修改?
学习newton raphson and back eluer的更多相关文章
- Jacobian矩阵、Hessian矩阵和Newton's method
在寻找极大极小值的过程中,有一个经典的算法叫做Newton's method,在学习Newton's method的过程中,会引入两个矩阵,使得理解的难度增大,下面就对这个问题进行描述. 1, Jac ...
- Newton's method Drawback and advantage
Newton Raphson Method: Advantages and Drawbacks: v=QwyjgmqbR9s" target="_blank"& ...
- Boosting(提升方法)之GBDT
一.GBDT的通俗理解 提升方法采用的是加法模型和前向分步算法来解决分类和回归问题,而以决策树作为基函数的提升方法称为提升树(boosting tree).GBDT(Gradient Boosting ...
- C++函数式编程实现牛顿法
In numerical analysis, Newton's method (also known as the Newton–Raphson method), named after Isaac ...
- Generalized normal distribution and Skew normal distribution
Density Function The Generalized Gaussian density has the following form: where (rho) is the " ...
- Tree - XGBoost with parameter description
In the previous post, we talk about a very popular Boosting algorithm - Gradient Boosting Decision T ...
- Tree - Gradient Boosting Machine with sklearn source code
This is the second post in Boosting algorithm. In the previous post, we go through the earliest Boos ...
- OpenCASCADE解非线性方程组
OpenCASCADE解非线性方程组 eryar@163.com Abstract. 在科学技术领域里常常提出求解非线性方程组的问题,例如,用非线性函数拟合实验数据问题.非线性网络问题.几何上的曲线曲 ...
- 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 ...
随机推荐
- 转:细说ASP.NET Windows身份认证
转自:https://www.cnblogs.com/fish-li/archive/2012/05/07/2486840.html 细说ASP.NET Windows身份认证 阅读目录 开始 认识A ...
- C++环境的配置( windows)
方法一.——VS: 使用windows开发神器visio studio.这种方法比较简单,直接下载一个最新的vs安装就行.不单单是C++,C.C#.VB等都可以开发. 方法二.——只安装C++编译器: ...
- IDLE的GUI交互模式下完美清屏
IDLE的GUI交互模式下完美清屏==============================================================================1.首先把 ...
- python class的创建
def f(): class a(): a=5 def f2(): pass Disassembly of f: 14 0 LOAD_CONST 1 ('a') 3 LOAD_CONST 3 (()) ...
- git保存用户名和密码
git保存用户名和密码 简介:tortoiseGit(乌龟git)图形化了git,我们用起来很方便,但是我们拉取私有项目的时候,每次都要输入用户名和密码很麻烦,这里向大家介绍怎么避免多少输入 试验环境 ...
- Connection reset by peer原理解析
“Connection reset by peer”代表什么?“Connection reset by peer”表示当前服务器接受到了通信对端发送的TCP RST信号,即通信对端已经关闭了连接,通过 ...
- 电商项目中使用Redis实现秒杀功能
参与过抢购活动就知道,很明显的一点是商即便商品实际没有了也是可以下单成功的,但是在支付的时候会提示你商品没有了. 实现原理:list双向链表 使用redis队列,因为pop操作是原子的,即使有很多用户 ...
- html常用代码合集
<!>字体效果 <h1>...</h1>标题字(最大) <h6>...</h6>标题字(最小) <b>...</b> ...
- 【ESP8266】、ESP8266通讯使用的AT指令
一.AT指令介绍 AT(Attention), AT指令一般应用于终端设备和PC应用之间建立连接.通过AT指令来控制. 二.常用AT指令 AT指令主要分为: 基础AT指令,WIFI功能AT指令,TCP ...
- 框架和内嵌框架--->frameset 和 iframe 的文档对象
框架和内嵌框架分别用 HTMLFrameElemnt 和 HTMLIFrameElement 表示,它们在 DOM2 中有一个新属性----->contentDocument,是一个指针,表示框 ...