Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

So I want to numerically compute the integral of a long complicated expression over a specified domain (in this case an ellipse). I know how to use a Boole function to sample within the ellipse, but I want to pass a list of points within this ellipse into the function and have the integral be evaluated at each of these specific points. An example would be:

$\frac{1}{(x \cos(\theta)+y \sin(\theta))^\frac{5}{2}} $

So I want to integrate over θ from 0 to 2 π and I want to use different points (x, y) within the specified domain when integrating. Can anyone help me with this?

share|improve this question
add comment

1 Answer

Humm... This integral is zero. So the answer to your question is zero for any x, y

$$\frac{1}{(x \cos(\theta)+y \sin(\theta))^\frac{5}{2}}$$

Clear[theta, x, y];
f = 1/(x Cos[theta] + y Sin[theta])^(5/2);
int = Integrate[f, theta];

int /. theta -> 2 Pi

Mathematica graphics

int /. theta -> 0

Mathematica graphics

(int /. theta -> 2 Pi) - (int /. theta -> 0) 
(* 0  *)


From comment below that the function used was just an example, here is one way to make a function to use NIntegrate for different x,y values. Changed the original function a little bit

ClearAll[theta, x, y, f];
f[{x_?NumericQ, y_?NumericQ}, theta_?NumericQ]:= 1/(x Cos[theta]^2+y Sin[theta])^(5/2);

pts = RandomReal[{0, 1}, {5, 2}];(*10 points*)

int = NIntegrate[Evaluate@f[#, theta], {theta, 0, 2 Pi}] & /@ pts

Mathematica graphics

This is a made up function just for illustration. Replace your actual function by f above. If this still not what is being asked, please feel free to follow up.

share|improve this answer
Or divergent... –  Michael E2 Feb 11 at 4:33
I'm sorry if I was unclear, but that isn't the actual function. The actual function is honestly too long to type, how did you get mathematica output directly into your post? Once I know that I can just post the result directly –  Mr. Frobenius Feb 11 at 4:55
@Nasser Cool, that is helpful. Thank you. So does random real just choose a random set of ten points in your example? What if I want to create a grid of a specified resolution in the plane, and then evaluate the integral at each of these grid points? –  Mr. Frobenius Feb 11 at 15:19
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.