Matlab实现——Differentiation Using Limits
来源:互联网 发布:刹车片 知乎 编辑:程序博客网 时间:2024/06/05 11:01
difflim.m
%Program 6.1 (Differentiation Using Limits). To approximate %f'(x) numerically by generating the sequencef'(x)≈Dk=%[f(x+(10^-k)*h)-f(x-(10^-k)*h]/[2*(10-k)*h] for k=0,… ,n%until |Dn+1-Dn| > |Dn-Dn-1| or |Dn-Dn-1| < tolerance, %which is an attempt to find the best approximation f’(x)≈Dn.function [L,n]=difflim(f,x,toler)%Input - f is the function input as a string 'f '% - x is the differentiation point% - toler is the desired tolerance%Output - L=[H' D' E']: % H is the vector of step sizes% D is the vector of approximate derivatives% E is the vector of error bounds% - n is the coordinate of the "best approximation"max1=15;h=1;H(1)=h;D(1)=(feval(f,x+h)-feval(f,x-h))/(2*h);E(1)=0;R(1)=0;for n=1:2 h=h/10; H(n+1)=h; D(n+1)=(feval(f,x+h)-feval(f,x-h))/(2*h); E(n+1)=abs(D(n+1)-D(n)); R(n+1)=2*E(n+1)/(abs(D(n+1))+abs(D(n))+eps);endn=2;while((E(n)>E(n+1))&(R(n)>toler))&n<max1 h=h/10; H(n+2)=h; D(n+2)=(feval(f,x+h)-feval(f,x-h))/(2*h); E(n+2)=abs(D(n+2)-D(n+1)); R(n+2)=2*E(n+2)/(abs(D(n+2))+abs(D(n+1))+eps); n=n+1;endn=length(D)-1;L=[H' D' E'];
fun.m
function f=fun(x)f=sin(cos(1/x));
untitled.m
x=1/sqrt(2);toler=10e-13;f='fun';[L,n]=difflim(f,x,toler)
- Matlab实现——Differentiation Using Limits
- Matlab实现——Adaptive Quadrature Using Simpson’s Rule
- C 标准库 —— limits.h
- White matter hyperintensity and stroke lesion segmentation and differentiation using cnn_part1_2017
- White matter hyperintensity and stroke lesion segmentation and differentiation using cnn_part2_2017
- limits
- Automatic differentiation
- Differentiation Rules
- C++标准库——cmath,climits,limits
- Matlab adjust axis tick labels, limits, and tick locations
- 混淆矩阵 Using Matlab
- Matlab实现——Euler's Method
- Matlab实现——Recursive Trapezoidal Rule
- Matlab实现——Lagrange approximation
- Matlab实现——Clamped Cubic Spline
- Matlab实现——Adams-Bashforth-Method
- Matlab实现——Forward-substitution
- Matlab实现——Newton-Raphson Iteration
- 循环链表按条件分割_C++实现
- 从汇编简要分析c语言函数调用栈
- 信息化基础知识
- WScript.SendKeys
- 我喜欢现在的生活
- Matlab实现——Differentiation Using Limits
- 关于online judge系统
- 经典十五课
- 深入理解 C++ 指针(三)---运算符&和*
- Teamcenter 入门开发系列问答(4)
- 后台执行命令
- 2011软件设计师知识点:Java EE开发四大常用框架
- 大素数的检验
- C++引用深入探讨