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. python3之time、datetime、random

    UTC:协调世界时,又称世界统一时间.世界标准时间.国际协调时间.由于英文(CUT)和法文(TUC)的缩写不同,作为妥协,简称UTC. 中国属于东八区,领先世界时间8小时 time模块 time.ti ...

  2. WOW

    WOW http://bbs.ngacn.cc/read.php?tid=4992959  http://ngasave.us/popcn/?t=gems  地精科技:国服最流行 http://bbs ...

  3. linux 僵尸进程查看方式

    ps -A -ostat,ppid,pid,cmd |grep -e '^[Zz]' # 结果 Z 169925 49893 [sw] <defunct> Z 169925 120690 ...

  4. Swift 通过运行时获取属性名列表

    import UIKit //必须要有@objcMembers修饰符,否则获取到的成员属性为0 @objcMembers class Person: NSObject { var name: Stri ...

  5. push() 方法将一个或多个元素添加到数组的末尾,并返回新数组的长度

    var numbers = [1, 2, 3]; numbers.push(4); console.log(numbers); // [1, 2, 3, 4] numbers.push(5, 6, 7 ...

  6. MySQL的show profile(已过时)简介以及该功能在MySQL 5.7中performance_schema中的替代

    本文出处:http://www.cnblogs.com/wy123/p/6979499.html show profile 命令用于跟踪执行过的sql语句的资源消耗信息,可以帮助查看sql语句的执行情 ...

  7. jquery中的 deferred之 deferred对象 (一)

    案例: var def=$.Deferred(); console.log(def);//答案见 图1 图1: deferred就是一个有这些方法的对象. 看源码分析: Deferred: funct ...

  8. 洛谷P1169 棋盘制作(悬线法)

    题目链接:https://www.luogu.org/problemnew/show/P1169 #include<bits/stdc++.h> #define fi first #def ...

  9. java学习笔记(四):import语法

    Import 语法是给编译器寻找特定类的适当位置的一种方法. 创建一个Employee 类,包括四个实体变量姓名(name),年龄(age),职位(designation)和薪水(salary). p ...

  10. java程序的三种结构

    从结构化程序设计角度出发,程序有三种结构:   顺序结构: JAVA的基本结构就是顺序结构,除非特别指明,否则就按照顺序一句一句执行顺序结构是最简单的算法结构,语句与语句之间,框与框之间是按从上到下的 ...