% 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的更多相关文章

  1. Matlab Gauss quadrature

    % matlab script to demonstrate use of Gauss quadrature clear all close all % first derive the 2-poin ...

  2. Fortran与C/C++混合编程示例

    以下例子均来自网络,只是稍作了编辑,方便今后查阅. 子目录 (一) Fortran调用C语言 (二) C语言调用Fortran (三) C++ 调用Fortran (四) Fortran 调用 C++ ...

  3. 双二次Lagrange 有限元计算特征值程序(基于iFEM)

    function lambda = c0P2(h) %% Mesh [node,elem] = squarequadmesh([,,,],h); elem = elem(:,[,,,]); showm ...

  4. QuantLib 金融计算——数学工具之数值积分

    目录 QuantLib 金融计算--数学工具之数值积分 概述 常见积分方法 高斯积分 如果未做特别说明,文中的程序都是 Python3 代码. QuantLib 金融计算--数学工具之数值积分 载入模 ...

  5. OpenCASCADE Gauss Integration

    OpenCASCADE Gauss Integration eryar@163.com Abstract. Numerical integration is the approximate compu ...

  6. Matlab adaptive quadrature

    % script to perform adaptive quadrature clear all, close all global pts % function to be integrated ...

  7. Salesforce的sharing Rule 不支持Lookup型字段解决方案

    Salesforce 中 sharing rule 并不支持Look up 字段 和 formula 字段.但在实际项目中,有时会需要在sharing rule中直接取Look up型字段的值,解决方 ...

  8. yii2权限控制rbac之rule详细讲解

    作者:白狼 出处:http://www.manks.top/yii2_rbac_rule.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留 ...

  9. RBAC中 permission , role, rule 的理解

    Role Based Access Control (RBAC)——基于角色的权限控制 permission e.g. creating posts, updating posts role A ro ...

随机推荐

  1. [solution] JZOJ3493 三角形

    [solution] JZOJ3493 三角形 Description 平面上有n个点,求出用这些点可以构成的三角形数. Input 第一行一个整数n. 接下来n行,每行两个整数,表示点的坐标. Ou ...

  2. yum-Remi源配置

    Remi repository 是包含最新版本 PHP 和 MySQL 包的 Linux 源,由 Remi 提供维护. 有个这个源之后,使用 YUM 安装或更新 PHP.MySQL.phpMyAdmi ...

  3. SQL Server PageIOLatch和PageLatch

    Latch是轻量级的锁,它是SQL Server内部用来同步资源访问的一个数据结构,使数据的访问同步有序,这意味着,当一个线程获得资源R的Latch的独占使用权时,如果其他的线程也想访问这个Latch ...

  4. python 使用 sorted 对 列表嵌套元组的数据进行排序

    在开发的过程可能会遇到这么一个需求,存在一个列表嵌套元组的数据: data = [(1, 'a'),(2, 'b'),(5, 'c'),(3, 'd'),(4, 'e')] 需要将这个列表按照元组的第 ...

  5. 移动端IM开发者必读(一):通俗易懂,理解移动网络的“弱”和“慢”

    本系列文章引用了腾讯技术专家樊华恒<海量之道系列文章之弱联网优化>的部分章节,感谢原作者. 1.前言 随着移动互联网的高速发展,移动端IM以移动网络作为物理通信载体早已深入人心,这其中的成 ...

  6. Java 代码需要使用转义符的地方

    1.正则表达式特殊字符 Java 代码中使用到正则表达式里的特殊字符需要使用转义符 \ 进行转义 . ? * + ! ^ $ [ ] ( ) \ 因为反斜线 \ 也是特殊字符,所以转义需双反斜线 \\ ...

  7. 【BJOI2019】删数 线段树

    题目大意:一个数列若能在有限次数内删空,则称这个数列可以删空,一次删除操作定义如下: 记当前数列长度为$k$,则删掉数列中所有等于$k$的数. 现在有一个长度为$n$的数列$a$,有$m$次修改操作, ...

  8. [EXP]CVE-2018-2628 Weblogic GetShell Exploit

    漏洞简介 漏洞威胁:RCE--远程代码执行 漏洞组件:weblogic 影响版本:10.3.6.0.12.1.3.0.12.2.1.2.12.2.1.3 代码: # -*- coding: utf-8 ...

  9. Apache多站点配置(ubuntu)(原创)

      1,先进入Apaches2的目录下 cd /etc/apache2   2,进入sites-available中 cd sites-available vi 000-default.conf   ...

  10. selenium的chromedriver对应的chrome版本

    chromedriver下载地址:http://chromedriver.storage.googleapis.com/index.html chromedriver版本 支持的Chrome版本 v2 ...