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 ...
随机推荐
- Learning WCF:Fault Handling
There are two types of Execptions which can be throwed from the WCF service. They are Application ex ...
- Variables and Arithmetic Expression
Notes from The C Programming Language A decimal point in a constant indicates that it is floating po ...
- 833. Find And Replace in String
To some string S, we will perform some replacement operations that replace groups of letters with ne ...
- 《分布式Java应用与实践》—— 后面两章
failover? NAT IP-tunneling DSR vrrp gossip 什么是2PC? 什么是3PC? 什么是Pasox? sna? dal? mpi?
- 国外青少年最喜爱的聊天 app,竟然是 Google Docs
简评: 这还真不是标题党,Google Docs 的协作中内置了实时聊天的功能,也可以进行 comments,颇有种现代「传纸条」的既视感.其实国内的石墨文档.腾讯文档等协作工具也有类似的效果,本文很 ...
- spring boot -thymeleaf-遍历list和map
遍历 list如下 th:each th:each 状态变量 var 遍历map如下(需要双层遍历) controller代码如下
- Python模块练习题
练习题: 1.logging模块有几个日志级别? #INFO,WARNING,DEBUG,CRITICAL,ERROR 2.请配置logging模块,使其在屏幕和文件里同时打印以下格式的日志 2017 ...
- Apache Commons Digester 三(规则注解)
前言 Digester规则的定义除了可以在代码中直接new规则添加到 Digester对象外,还可以用xml配置规则,如下所示: <digester-rules> <pattern ...
- 【Java基本功】很多人经常忽视的Java基础知识点
*.Java文件 问题:一个".java"源文件中是否可以包括多个类(不是内部类)?有什么限制? 答案:可以有多个类,但只能有一个public的类,并且public的类名必须与文件 ...
- Hadoop项目实战-用户行为分析之编码实践
1.概述 本课程的视频教程地址:<用户行为分析之编码实践> 本课程以用户行为分析案例为基础,带着大家去完成对各个KPI的编码工作,以及应用调度工作,让大家通过本课程掌握Hadoop项目的编 ...