How to do a double integral on matlab?

In summary: My bad, I forgot to include the denominator of (xy^2 + 1)^2 in the integrand. So my definition of fun is correct.
  • #1
Lucas94
7
0
Hey! I want to do a double integral calculation of this problem##∫∫ xy/(xy^2 +1)^2##

over the region bounded by 2 ≤ x ≤ 3 and 2*sqrt(1+x) ≤ y ≤ 2*sqrt(2+4x)
on MATLAB and i have tried the following syntax:

clc

clear all

fun=@(x,y) x*y./((x*y.^2+1).^2);

ymax=@(x) 2*sqrt(2+4*x);
q=integral2(fun,2,3,2*sqrt(1+x),ymax);But its doesn't work, can someone see what I am doing wrong?
 
Last edited:
Physics news on Phys.org
  • #2
Lucas94 said:
Hey! I want to do a doubble integral calculation on MATLAB and i have tried the following syntax:

clc

clear all

fun=@(x,y) x*y./((x*y.^2+1).^2);

ymax=@(x) 2*sqrt(2+4*x);
q=integral2(fun,2,3,2*sqrt(1+x),ymax);But its doesn't work, can someone see what I am doing wrong?
It's not clear which double (only one 'b' in double) integral you are trying to evaluate.

If you would provide the actual integral using calculus notation, that would be a big help. Also, specify the region of integration or the limits, as required.
 
  • #3
SteamKing said:
It's not clear which double (only one 'b' in double) integral you are trying to evaluate.

If you would provide the actual integral using calculus notation, that would be a big help. Also, specify the region of integration or the limits, as required.
##∫ ∫ xy/(xy^2 +1)^2##

over the region bounded by 2 ≤ x ≤ 3 and 2*sqrt(1+x) ≤ y ≤ 2*sqrt(2+4x)
 
Last edited:
  • #4
Lucas94 said:
##∫ ∫ xy/(xy^2 +1)##

over the region bounded by 2 ≤ x ≤ 3 and 2*sqrt(1+x) ≤ y ≤ 2*sqrt(2+4x)

The denominator of the integrand above is (xy2 + 1)

Lucas94 said:
clc

clear all

fun=@(x,y) x*y./((x*y.^2+1).^2);

ymax=@(x) 2*sqrt(2+4*x);

In the definition fun above, the denominator appears to be (xy2 + 1)2. See the difference?
 
  • #5
SteamKing said:
The denominator of the integrand above is (xy2 + 1)
In the definition fun above, the denominator appears to be (xy2 + 1)2. See the difference?
My bad i forgot to write it on the integrand , the denominator should be ##(xy^2 + 1)^2## soo my definition of fun is correct
 

1. How do I define the limits of integration in a double integral on matlab?

To define the limits of integration, you will need to use the 'integral2' function in matlab. This function takes in the integrand as well as the limits of integration in the form of a vector [xmin, xmax, ymin, ymax]. For example, if you want to integrate over the region x from 0 to 2 and y from 0 to 3, you would use the following syntax: integral2(@(x,y) x+y, 0, 2, 0, 3).

2. How do I specify the function to be integrated in a double integral on matlab?

In matlab, you can use the 'integral2' function to specify the function to be integrated. This function takes in the integrand as the first argument and the limits of integration as the following arguments. For example, if you want to integrate over the function x+y, you would use the syntax: integral2(@(x,y) x+y, xmin, xmax, ymin, ymax).

3. Can I use a variable as the limits of integration in a double integral on matlab?

Yes, you can use a variable as the limits of integration in matlab. You will need to define the variable beforehand and then use it in the 'integral2' function. For example, if you want to integrate over the function x+y with limits of integration specified by the variables xmin, xmax, ymin, and ymax, you would use the syntax: integral2(@(x,y) x+y, xmin, xmax, ymin, ymax).

4. How do I display the result of a double integral on matlab?

In matlab, the 'integral2' function will return the numerical value of the double integral. If you want to display the result, you can use the 'disp' function. For example, if you want to display the result of integrating over the function x+y with limits of integration xmin=0, xmax=2, ymin=0, and ymax=3, you would use the syntax: disp(integral2(@(x,y) x+y, 0, 2, 0, 3)).

5. Can I use nested functions in a double integral on matlab?

Yes, you can use nested functions in a double integral on matlab. You will need to define the nested function and then use it as the integrand in the 'integral2' function. For example, if you want to integrate over the function x+y^2, you can define the nested function as f=@(x,y) x+y^2 and then use it in the 'integral2' function as integral2(f, xmin, xmax, ymin, ymax).

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
995
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
123
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
27
Views
3K
Back
Top