# Numerical Integration with Variable Parameters

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?

-

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

int /. theta -> 0

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

Update

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

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.

-
Or divergent... – Michael E2 Feb 11 '14 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 '14 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 '14 at 15:19
Let me comment that the approach depends strongly on the concrete form of the expression to be integrated. The one above, for example, admits passing to a single parameter: (x Sin[t]+y Cos[t])^5/2==x^5/2*(Sin[t]+z*Cos[t])^5/2where z=y/x. If this (or at least, something like this) is the case, the problem becomes especially simple. – Alexei Boulbitch Aug 29 '14 at 20:02
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://mathematica.stackexchange.com/questions/42085/numerical-integration-with-variable-parameters", "fetch_time": 1469765256000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2016-30/segments/1469257829970.64/warc/CC-MAIN-20160723071029-00047-ip-10-185-27-174.ec2.internal.warc.gz", "warc_record_offset": 166342264, "warc_record_length": 17996, "token_count": 718, "char_count": 2519, "score": 3.71875, "int_score": 4, "crawl": "CC-MAIN-2016-30", "snapshot_type": "latest", "language": "en", "language_score": 0.8232553601264954, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00021-of-00064.parquet"}