1. % % time step https://ww2.mathworks.cn/matlabcentral/answers/184200-newton-raphson-loop-for-backward-euler
  2. % h = (t_final - t_init)/n; % with n number of time steps
  3. % % vectors
  4. % t = [tinit zeros(,n)]; % time
  5. % y = [yinit zeros(,n)]; % solution
  6. % % Backward Euler loop
  7. % for i = :n
  8. % t(i+) = t(i) + h;
  9. % y_temp = y(i) + h(f(t(i), y(i)));
  10. % y(i+) = y(i) + h*f(t(i+), y_temp);
  11. % end
  12. % for i = :n
  13. % error = ;
  14. % tolerance = 1e-;
  15. % t(i+) = t(i) + h;
  16. % y_temp = y(i) + h*(f(t(i), y(i)));
  17. % while error >= tolerance
  18. % y(i+) = y(i) + h*f(t(i+), y_temp);
  19. % error = abs(y(i+) - y_temp) % (local) absolute error
  20. % y_temp = y(i+);
  21. % end
  22. % end
  23.  
  24. % yold = y(i)+h*f(t(i),y(i));
  25. % while error >= tolerance
  26. % ynew = yold-(yold-(y(i)+h*f(t(i+),yold)))/(-h*df(t(i+),yold));
  27. % error = abs(ynew-yold);
  28. % yold=ynew;
  29. % end
  30. % y(i+) = ynew;
  31.  
  32. %y'=y+2*x/y^2 x=[0,2] y(0)=1 https://wenku.baidu.com/view/d18cdaa10b4c2e3f5627632f.html
  33. t_final=;
  34. t_init=;
  35. n=;
  36. tolerance=0.0000001
  37. h = (t_final - t_init)/n;
  38. ti=t_init+h;
  39. yold=+h*f(,);% yold = y(i)+h*f(t(i),y(i));
  40. while error >= tolerance
  41. ynew = yold-(yold-(y(i)+h*f(t(i+),yold)))/(-h*df(t(i+),yold));
  42. error = abs(ynew-yold);
  43. yold=ynew;
  44. end
  45. y(i+) = ynew;

上面代码应该怎样修改?

学习newton raphson and back eluer的更多相关文章

  1. Jacobian矩阵、Hessian矩阵和Newton's method

    在寻找极大极小值的过程中,有一个经典的算法叫做Newton's method,在学习Newton's method的过程中,会引入两个矩阵,使得理解的难度增大,下面就对这个问题进行描述. 1, Jac ...

  2. Newton's method Drawback and advantage

     Newton Raphson Method: Advantages and Drawbacks:   v=QwyjgmqbR9s" target="_blank"& ...

  3. Boosting(提升方法)之GBDT

    一.GBDT的通俗理解 提升方法采用的是加法模型和前向分步算法来解决分类和回归问题,而以决策树作为基函数的提升方法称为提升树(boosting tree).GBDT(Gradient Boosting ...

  4. C++函数式编程实现牛顿法

    In numerical analysis, Newton's method (also known as the Newton–Raphson method), named after Isaac ...

  5. Generalized normal distribution and Skew normal distribution

    Density Function The Generalized Gaussian density has the following form: where  (rho) is the " ...

  6. Tree - XGBoost with parameter description

    In the previous post, we talk about a very popular Boosting algorithm - Gradient Boosting Decision T ...

  7. 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 ...

  8. OpenCASCADE解非线性方程组

    OpenCASCADE解非线性方程组 eryar@163.com Abstract. 在科学技术领域里常常提出求解非线性方程组的问题,例如,用非线性函数拟合实验数据问题.非线性网络问题.几何上的曲线曲 ...

  9. 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 ...

随机推荐

  1. Linux安装rz/sz,htop插件

    Linux下rz/sz安装及使用方法 sz: 将选定的文件发送(send)到本地机器; rz:运行该命令会弹出 一个文件选择窗口, 从本地选择文件上传到服务器(receive). 下载安装包 lrzs ...

  2. shell :将标准输出及标准错误输出写到指定文件

    shell 脚本如下: logFile=/usr/local/log/$today.txt exec >> $logFile 2>&1 1为标准输出stdout.2为标准错误 ...

  3. shell脚本(一)

     shell脚本(一) 定义:脚本就是一条条命令的堆积.常见脚本有:js asp,jsp,php,python Shell特点:简单易用高效 Shell分类:图形界面(gui shell) 命令行界面 ...

  4. android 开发 View _16 自定义计步器View、自定义柱状图View

    /** *@content:实现计步的环形View *@time:2018-7-30 *@build: */ public class CountStepsAnnularView extends Vi ...

  5. 20165205 2017-2018-2 《Java程序设计》课程总结

    20165205 2017-2018-2<Java程序设计>课程总结 每周作业链接总结 预备作业一: 简述了我认为好的师生关系,展望了未来学习java的日子 预备作业二:总结了C语言的学习 ...

  6. leetcode448

    public class Solution { public IList<int> FindDisappearedNumbers(int[] nums) { Dictionary<i ...

  7. VUE - 相对路径

    background-image背景图片路径问题可以这样解决:1.先在data里面导入这张图片,例如:                bg:require('./openIndexBG2.jpg')2 ...

  8. html 跳转页面传参、点击获取DOM参数

    虽然现在前端框架已经很多,尤其是几大流行框架,比如Vue,React,Angular 等,已经去DOM化,但是还是有很多公司仍在使用 HTML + CSS + JS . 这里记载一下用到的HTML传参 ...

  9. SVG绘制太极图

    思路:先画一整个圆,填充颜色为黑色,再用一个边框和填充颜色均为白色的长方形覆盖右半边的半圆,再以同一个圆心,相同半径绘制一整个圆,该圆的边线颜色为黑色,没有填充颜色,最后常规操作再画四个小圆 源代码: ...

  10. Lua 和 C++ 交互

    step1.搭建好vs和lua相交互的环境: 1.下载一个lua5.3的源码: 2.有Lua_lib.lib这个文件: 3.开始配置: 鼠标放在工程名那: 右键选属性: 把包含目录点开进行编辑: 地址 ...