matlab二重定积分_matlab求二重积分
计算量不小 区间不宜过大
zlabel('f5')
title('f5')
......................
...........................
matlab求二重积分
g = @(x,y)
1.*((x-2.5).^2+(y-1).^2<=1)+0.*((x-2.5).^2+(y-1).^2>1);
f = @(x,y)
1.*((x-2).^2+(y-1).^2<=1)+0.*((x-2).^2+(y-1).^2>1);
z = @(x,y) f(x,y)+g(x,y)
Q = dblquad(z,0,4,-1,3)
...........
% 以下代码在7.1版以上均可运行。
r=1;
a=2; % 输入a的值
Phi=3; % 输入Phi的值
f1 = @(Theta_2,Phi_2) sin(Theta_2).*sin(Theta_2).*cos(Phi_2);
f2 = @(Theta_2,Phi_2) sqrt(r^2+a^2-2*r*a.*sin(Theta_2).*cos(Phi-Phi_2));
f3 = @(Theta_2,Phi_2) f1(Theta_2,Phi_2)./f2(Theta_2,Phi_2);
f5 = dblquad(f3,0,pi,0,pi)
......................
...........................
..................
dblquad-
Numerically evaluate double
integral over rectangle
Syntax
q = dblquad(fun,xmin,xmax,ymin,ymax)
q = dblquad(fun,xmin,xmax,ymin,ymax,tol)
q = dblquad(fun,xmin,xmax,ymin,ymax,tol,method)
Description
q = dblquad(fun,xmin,xmax,ymin,ymax)
callsthe quad
function to evaluatethe double integral fun(x,y) over the
rectangle xmin<= x <= xmax,
ymin <=y <= ymax.
fun isa function handle. See Function
Handles in the MATLAB Programming documentationfor more
information. fun(x,y) must accept a vector x anda
scalar y and return a vector of values of
theintegrand.
Parameterizing
Functions, in the MATLAB Mathematicsdocumentation, explains how
to provide additional parameters to thefunction fun, if
necessary.
q = dblquad(fun,xmin,xmax,ymin,ymax,tol)
usesa tolerance tol instead of the default, which is
1.0e-6.
q =
dblquad(fun,xmin,xmax,ymin,ymax,tol,method) usesthe
quadrature function specified as method, insteadof the
default quad. Valid values for method are
@quadl orthe function handle of a user-defined quadrature
method that has thesame calling sequence as quad and
quadl.
Examples
Pass function handle @integrnd to dblquad:
Q = dblquad(@integrnd,pi,2*pi,0,pi);
where the function integrnd.m is:
function z = integrnd(x, y)
z = y*sin(x)+x*cos(y);
Pass anonymous function handle F to
dblquad:
F = @(x,y)y*sin(x)+x*cos(y);
Q = dblquad(F,pi,2*pi,0,pi);
The integrnd function integrates
y*sin(x)+x*cos(y) overthe square pi <=
x <= 2*pi, 0 <= y
<= pi. Note that the integrand can be evaluated
with a vector x anda scalar y.
Nonsquare regions can be handled by setting the integrand tozero
outside of the region. For example, the volume of a
hemisphereis:
dblquad(@(x,y)sqrt(max(1-(x.^2+y.^2),0)), -1, 1, -1, 1)
or
dblquad(@(x,y)sqrt(1-(x.^2+y.^2)).*(x.^2+y.^2<=1), -1, 1, -1, 1)
See Also
...............
quad2d-
Numerically evaluate double
integral over planar region
Syntax
q = quad2d(fun,a,b,c,d)
[q,errbnd] = quad2d(...)
q = quad2d(fun,a,b,c,d,param1,val1,param2,val2,...)
Description
q = quad2d(fun,a,b,c,d) approximates
theintegral of fun(x,y) over the planar region
and . fun is afunction handle,
c and d mayeach be a scalar or a function
handle.
All input functions must be vectorized. The function
Z=fun(X,Y) mustaccept 2-D matrices X and
Y ofthe same size and return a matrix Z of
correspondingvalues. The functions ymin=c(X) and
ymax=d(X) mustaccept matrices and return matrices of the
same size with correspondingvalues.
[q,errbnd] = quad2d(...). errbnd
isan approximate upper bound on the absolute error, |Q -
I|,where I denotes the exact value of the
integral.
q =
quad2d(fun,a,b,c,d,param1,val1,param2,val2,...)
performsthe integration as above with specified values of optional
parameters:
AbsTol
absolute error tolerance
RelTol
relative error tolerance
quad2d
attempts to satisfy ERRBND<=
max(AbsTol,RelTol*|Q|). This is absolute error controlwhen
|Q| is sufficiently small and relative errorcontrol when
|Q| is larger. A default tolerancevalue is used when a
tolerance is not specified. The default valueof AbsTol is
1e-5. The default value of RelTol is
100*eps(class(Q)).This is also the minimum value of
RelTol. Smaller RelTol valuesare automatically
increased to the default value.
MaxFunEvals
Maximum allowed number of evaluations of
fun reached.
The MaxFunEvals parameter limits the numberof
vectorized calls to fun. The default is 2000.
FailurePlot
Generate a plot if MaxFunEvals is
reached.
Setting FailurePlot to true generatesa
graphical representation of the regions needing further
refinementwhen MaxFunEvals is reached. No plot is
generatedif the integration succeeds before reaching
MaxFunEvals.These (generally) 4-sided regions are mapped
to rectangles internally.Clusters of small regions indicate the
areas of difficulty. The defaultis false.
Singular
Problem may have boundary singularities
With Singular set to true, quad2d
will employ transformations to weaken boundary singularities for
better performance. The defaultis true. Setting
Singular to false willturn these transformations
off, which may provide a performance benefiton some smooth
problems.
Examples
Example 1
Integrate over , . The true value of the integralis
.
Q = quad2d(@(x,y) y.*sin(x)+x.*cos(y),pi,2*pi,0,pi)
Example 2
Integrate over the triangle and . The integrand is infinite
at(0,0). The true value of the integral is .
fun = @(x,y) 1./(sqrt(x + y) .* (1 + x + y).^2 )
In Cartesian coordinates:
ymax = @(x) 1 - x;
Q = quad2d(fun,0,1,0,ymax)
In polar coordinates:
polarfun = @(theta,r) fun(r.*cos(theta),r.*sin(theta)).*r;
rmax = @(theta) 1./(sin(theta) + cos(theta));
Q = quad2d(polarfun,0,pi/2,0,rmax)
Limitations
quad2d
begins by mappingthe region of integration to a rectangle.
Consequently, it may havetrouble integrating over a region that
does not have four sides orhas a side that cannot be mapped
smoothly to a straight line. Ifthe integration is unsuccessful,
some helpful tactics are leaving Singular set to its
default value of true, changing betweenCartesian and polar
coordinates, or breaking the region of integrationinto pieces and
adding the results of integration over the pieces.
For example:
fun = @(x,y)abs(x.^2 + y.^2 - 0.25);
c = @(x)-sqrt(1 - x.^2);
d = @(x)sqrt(1 - x.^2);
quad2d(fun,-1,1,c,d,'AbsTol',1e-8,...
'FailurePlot',true,'Singular',false)
Warning: Reached the maximum number of function ...
evaluations (2000). The result fails the ...
global error test.
The failure plot shows twoareas of difficulty, near the points
(-1,0) and (1,0) andnear the circle
:
Changing the value of Singular to true
willcope with the geometric singularities at (-1,0) and
(1,0).The larger shaded areas may need refinement but are
probably not areasof difficulty.
Q = quad2d(fun,-1,1,c,d,'AbsTol',1e-8, ...
'FailurePlot',true,'Singular',true)
Warning: Reached the maximum number of function ...
evaluations (2000). The result passes the ...
global error test.
From here youcan take advantage of symmetry:
Q = 4*quad2d(fun,0,1,0,d,'Abstol',1e-8,...
'Singular',true, 'FailurePlot',true)
However, the code is still working very hard near the
singularity.It may not be able to provide higher accuracy:
Q = 4*quad2d(fun,0,1,0,d,'Abstol',1e-10,...
'Singular',true,'FailurePlot',true)
Warning: Reached the maximum number of function ...
evaluations (2000). The result passes the ...
global error test.
At higher accuracy, a change in coordinates may work better.
polarfun = @(theta,r) fun(r.*cos(theta),r.*sin(theta)).*r;
Q = 4*quad2d(polarfun,0,pi/2,0,1,'AbsTol',1e-10)
It is best to put the singularity on the boundary by
splittingthe region of integration into two parts:
Q1 = 4*quad2d(polarfun,0,pi/2,0,0.5,'AbsTol',5e-11);
Q2 = 4*quad2d(polarfun,0,pi/2,0.5,1,'AbsTol',5e-11);
Q = Q1 + Q2
References
[1] L.F. Shampine, "Matlab Program for Quadraturein
2D."Applied Mathematics and Computation. Vol.
202,Issue 1, 2008, pp. 266–274.
See Also
matlab二重定积分_matlab求二重积分相关推荐
- matlab二重定积分_怎样用matlab求二重积分?
怎样求二重积分,其中二重积分的积分区间为[-inf,Xij]其中,i=1,2;j=1,2,...,100.Xij为2*100矩阵X = Columns 1 through 8 -0.4326 0 ...
- c语言编求二重积分_如何用C语言求二重定积分?
展开全部 按二重积分的定义做. 我的这32313133353236313431303231363533e59b9ee7ad9431333330333631个出错,一起讨论下吧: #include #i ...
- 【Matlab】复化梯形公式求积分、求二重积分
目录 一.复化梯形公式求积分 1.1 题目 1.2 程序 1.3 运行结果 二.复化梯形公式求二重积分 2.1 题目 2.2 程序 2.2.1 二重积分通用程序 2.2.2 主函数程序 2.3 运行结 ...
- 高斯公式积分matlab,三用MATLAB实现定积分计算.PPT
令用式计算我们不妨只考虑二高斯求积公式各种近似求积公式都可以表示为若对于都有而当时则称的代数精度为梯形公式代数精度为辛甫森公式的代数精度为下面介绍的是取消对区间等分的限制给定后同时确定节点和系数使代数 ...
- matlab定积分怎么输入,Matlab计算定积分的操作内容讲解
许多伙伴还不晓得Matlab计算定积分的操作,而下面笔者就分享了Matlab计算定积分的操作内容,希望有需要的朋友都来共同学习哦. 打开Matlab,找到Matlab的命令窗口,点击进入,如图,当然也 ...
- MATLAB新手简明使用教程(七)——使用matlab建立多项式以及求导,商求导乘积求导等——新手来看,保证看懂。
前期回顾 上一期中,我们学了下面的知识: 定积分的基本概念和一些简单的几何意义. 使用 int 函数计算不定积分. 使用 int 函数计算定积分. 本期内容 本期我打算给大家介绍一下使用matlab对 ...
- Matlab求解定积分/不定积分/微分
使用Matlab求解定积分/不定积分 https://blog.csdn.net/qq_34374664/article/details/79186465 用MATLAB求定积分 https://bl ...
- 求拉格朗日多项式matlab,拉格朗日插值多项式积分求圆周率近似Matlab实现
Lagrange 插值多项式积分求圆周率近似 摘要: 公式1:y1=4/(1+x^2) 公式2:y2=4*sqrt(1-x^2) 分别对公式1.公式2求其拉格朗日插值多项式,再对其求0-1上的定积分来 ...
- matlab fix函数_Matlab课后答案第四章
" m文件是matlab程序的容器." 01 - 学会使用函数m文件,程序m文件: 区别:函数m文件调用需要传入参数 函数m文件可以在命令行调用,也可以在程序m文件中调用 02 - ...
- 中南大学 科学计算与MATLAB语言 11矩阵求值
中南大学 科学计算与MATLAB语言 11矩阵求值 矩阵求值主要包括 矩阵的行列式值 矩阵的秩 矩阵的迹 矩阵的范数 矩阵的条件数 把一个方阵看作一个行列式,并对其按行列式的规则求值,这个值就称方阵所 ...
最新文章
- 德勒报告:2018年全球生命科学发展趋势
- 原创哈希数据导出算法
- 7个Python特殊技巧,助力你的数据分析工作之路
- 刚刚出炉的Asp.net网站部署视频教程
- C++ 高级篇(三)—— 出错处理
- 信息检索IR评价中常见的评价指标-MAP\NDCG\ERR\P@10等
- bp神经网络预测未来五年数据_基于小波神经网络的数据中心KPI预测
- 计算机二级考试改错题技巧
- linux mkdir基础命令总结
- Win7如何修改开机动画
- 有哪些让程序员受益终生的建议
- 这程序还厉害的。。。
- 世界金融发展史:从资产证券化到STO
- 海思SD3403开发板学习(一)
- HTML有2种路径的写法:绝对路径和相对路径
- sparrow图标素材
- 曲线救国--为Chrome安装Edge浏览器插件
- 如何在 Mathtype中输入空格
- VS---不允许 dllimport 静态数据成员的定义
- Visual Studio 开发工具下载安装教程
热门文章
- iOS13 暗黑模式(Dark Mode)适配之OC版
- C语言书籍推荐从入门到进阶再到封神全套(2021年整理)
- 人人商城生成app教程_人人商城打包app教程 方法 hbuilder打包支持支付宝微信原生支付...
- 【工业机器人】全球工业机器人详细产业链梳理!
- python常用函数及用法
- 解读Depth Map Prediction from a Single Image using a Multi-Scale Deep Network (1)
- Eclipse配置Hadoop开发环境
- mybatis 之 parameterType=list
- 大学计算机信息技术实验与测试教程第2版,大学信息技术实验指导
- 马士兵Python基础版2020教程P98-P134 PPT笔记+课堂代码