Gauss-Laguerre quadrature rule
% matlab script to derive the 2-point Gauss-Laguerre quadrature rule
% and use it on an example % inelegantly set up equations from method of undetermined coefficients
% and solve clear all
close all
format long eq1 = 'w1*1 + w2*1 = 1'; eq2 = 'w1*x1 + w2*x2 = 1'; eq3 = 'w1*x1^2 + w2*x2^2 = 2'; eq4 = 'w1*x1^3 + w2*x2^3 = 6'; [w1,w2,x1,x2] = solve(eq1,eq2,eq3,eq4)
pause % note: there are two solutions
% we pick the one where x1 < x2 [x1,index] = min(double(x1))
w1 = double(w1(index)) x2 = double(x2(index))
w2 = double(w2(index)) % define the integrand f = @(x) exp(x).*log(1+exp(-x)); % use Gauss-Laguerre quadrature to approximate it glq = w1*feval(f,x1) + w2*feval(f,x2) % now let's find the exact answer and see what the error is ... syms x
I = double(int(log(1+exp(-x)),0,Inf)) error = I - glq
pause % or we can estimate the neglected tail
% trying integral(f,0,Inf) or integral(f,0,realmax)
% won't work! f = @(x) log(1+exp(-x));
Q10 = integral(f,0,10)
Q20 = integral(f,0,20)
Q30 = integral(f,0,30)
% from here we see that we have convergence to 8 decimal places % we can also perform a change of variable to make the interval finite
F = @(t) log(1+t)./t;
integral(F,0,1) % check for problems at t=0
ezplot(F,0,1)
integral(F,realmin,1)
Gauss-Laguerre quadrature rule的更多相关文章
- Matlab Gauss quadrature
% matlab script to demonstrate use of Gauss quadrature clear all close all % first derive the 2-poin ...
- Fortran与C/C++混合编程示例
以下例子均来自网络,只是稍作了编辑,方便今后查阅. 子目录 (一) Fortran调用C语言 (二) C语言调用Fortran (三) C++ 调用Fortran (四) Fortran 调用 C++ ...
- 双二次Lagrange 有限元计算特征值程序(基于iFEM)
function lambda = c0P2(h) %% Mesh [node,elem] = squarequadmesh([,,,],h); elem = elem(:,[,,,]); showm ...
- QuantLib 金融计算——数学工具之数值积分
目录 QuantLib 金融计算--数学工具之数值积分 概述 常见积分方法 高斯积分 如果未做特别说明,文中的程序都是 Python3 代码. QuantLib 金融计算--数学工具之数值积分 载入模 ...
- OpenCASCADE Gauss Integration
OpenCASCADE Gauss Integration eryar@163.com Abstract. Numerical integration is the approximate compu ...
- Matlab adaptive quadrature
% script to perform adaptive quadrature clear all, close all global pts % function to be integrated ...
- Salesforce的sharing Rule 不支持Lookup型字段解决方案
Salesforce 中 sharing rule 并不支持Look up 字段 和 formula 字段.但在实际项目中,有时会需要在sharing rule中直接取Look up型字段的值,解决方 ...
- yii2权限控制rbac之rule详细讲解
作者:白狼 出处:http://www.manks.top/yii2_rbac_rule.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留 ...
- RBAC中 permission , role, rule 的理解
Role Based Access Control (RBAC)——基于角色的权限控制 permission e.g. creating posts, updating posts role A ro ...
随机推荐
- 2019swpuj2ee作业3
静态页面: 在网站设计中,纯粹html格式的网页通常被称为“静态网页”,早期的网站一般都是由静态网页制作的.静态网页是相对于动态网页而言,是指没有后台数据库.不含程序和不可交互的网页.你编的是什么它显 ...
- xml to xsd ; xsd to xml
xml to xsd 工具网站 https://www.freeformatter.com/xsd-generator.html 示例xml <?xml version="1.0&qu ...
- TortoiseSVN与TortoiseGit
TortoiseSVN与TortoiseGit 功能:版本控制+备份处理 差异:SVN二段式,没有中间存储点,直接提交后到达了远程存储点:要想对本地的修改进行记录,必须要与SVN服务器进行通讯,无法只 ...
- 《Pro git》
可以通过阅读 CODING 工程师参与翻译的 <Pro Git> 进一步掌握 Git 版本控制系统. https://git-scm.com/book/zh/v2
- WPF触发器(Trigger) - DataTrigger
官方文档中对DataTrigger的介绍 Represents a trigger that applies property values or performs actions when the ...
- HTML5之FileReader文件读取接口
FileReader用来把文件读入内存,并且读取文件中的数据.FileReader接口提供了一个异步API,使用该API可以在浏览器主线程中异步访问文件系统,读取文件中的数据. 1.FileReade ...
- 通过shell快速配置J2EE运行环境
虽然可以通过已经配置好的docker镜像来快速运行相关环境, 但是 现实往往就是这么残酷+有钱很任性的时候 就是给出了一个装好系统的电脑让配置环境,每次的配置环境变量真的很烦 纯体力活 就简单的写个脚 ...
- static加载顺序简介
1.先执行父类的静态代码块和静态变量初始化,并且静态代码块和静态变量的执行顺序只跟代码中出现的顺序有关. 2.执行子类的静态代码块和静态变量初始化. 3.执行父类的实例变量初始化 4.执行父类的构造函 ...
- js设计模式小结
1 构造函数模式 var Person = function(name){ this.name = name; this.getName = function(){ console.log(this. ...
- 测试工具之Jmeter(使用badboy录制脚本)
前面使用badboy工具时说过,badboy是可以录制Jmeter的测试脚本,这样省去了自己设计测试用例的麻烦 Jmeter主要是一个性能测试工具,不光在web和http,现在扩展很多功能都可以在Jm ...