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 ...
随机推荐
- 中国移动物联网ONENET平台数据本地采集工具
吧从中国移动物联网平台上接收的数据 实时按天保存为CSV文件或者是SQL SERVER数据库中方便进行数据处理 还可设置显示最大值,最小值,报警值,报警推送,tts语音报警等贴心功能
- 关于wifi网络基本原理了解
对于esp32,其wifi功能还是十分强大的,为了能够良好的完成wifi的相关开发,这里需要计算机网络的结构体系进行大致的了解. 一.网络结构分层 对于计算机网络结构,大体上可以分为5层结构: 物理层 ...
- 踩了的Dockerfile的坑
1.Dockerfile VOLUME的目录,RUN命令操作该目录无效 VOLUME $APP_HOME RUN mkdir -p $APP_HOME && mkdir -p $APP ...
- APK防护——Anti_Virtual App的思路和实现
作者:HAI_i 原文来自:https://bbs.ichunqiu.com/thread-42982-1-1.html 0×00 前言 Virtual App是一个很强大的存在,破坏了Android ...
- JSON 字符串解析技巧总结
在解析JSONObject的字符数据的时候,可以考虑去使用optString 解析网络JSON数据时,获取数据的两个方法optString和getString: 使用optString获取数据时,即使 ...
- Android 开发常用版本控制命令
1. git 回退到指定版本 // 使用git log命令查看所有的历史版本,获取某个历史版本的id,假设查到历史版本的id是139dcfaa558e3276b30b6b2e5cbbb9c00bbdc ...
- Java 中的 HttpServletRequest 和 HttpServletResponse 对象
HttpServletRequest对象详解 javax.servlet.http.HttpServletRequest是SUN制定的Servlet规范,是一个接口.表示请求,“HTTP请求协议”的完 ...
- Spring webFlux:坐等spring-boot-starter-data-mysql-reactive
spring-boot-starter-data-mongodb-reactive spring-boot-starter-data-redis-reactive 坐等 spring-boot-sta ...
- EasyUI 获取展开表中行数据
var index = $('#dg').datagrid('getRowIndex', row); //为destory_user.php传递参数id var ids = $("#dg&q ...
- ubuntu下TFTP Server 的安装和使用方法
tftp是一种于1981年在RFC 783中定义的简化的文件传输协议(FTP).小型文件传输协议非常简单,通过少量存储器就能轻松实现 ——这在当时是很重要的考虑因素.所以TFTP被用于引导计算机,例如 ...