# Getting Integrate to perform numerical integration

I am trying to calculate the mutual impedance of two antennas which is just a big integral. I defined my function in terms of my variable, but when I execute it, Mathematica runs for a while and then just gives back my original equation, just a little bit expanded. It does not show any errors, just runs for a while and spits out my unintegrated equation. My exact code is below:

(* this part is just setting up the equations I will be using in my integral *)
Sza[s_, θ_]            := s*Cos[θ]
Sya[s_, θ_, φ_]        := s*Sin[θ]*Sin[φ]
Sxa[s_, θ_, φ_]        := s*Sin[θ]*Cos[φ]
ρa[Sx_, y0_, Sy_]      := Sqrt[Sx^2 + (y0 + Sy)^2]
ra[ρ_, z0_, Sz_]       := Sqrt[ρ^2 + (z0 + Sz)^2]
r1a[ρ_, z0_, Sz_, L1_] := Sqrt[ρ^2 + (z0 + Sz + L1/2)^2]
r2a[ρ_, z0_, Sz_, L1_] := Sqrt[ρ^2 + (z0 + Sz - L1/2)^2]

(* Defining the integral equation *)
R21[ρ_, r1_, Sz_, z0_, L1_, r2_, r_, Sx_, y0_, Sy_, L2_] := -30*
Integrate[
(((1/ρ^2)*(Sin[2*Pi*r1]*((Sz + z0 + L1/2)/r1) +
Sin[2*Pi*r2]*((Sz + z0 - L1/2)/r2) -
2*Cos[Pi*L1]*Sin[2*Pi*r]*((Sz + z0)/r))*(Sx^2 + y0*Sy +
Sy^2)) + ((2*Sin[2*Pi*r]*Cos[Pi*L1]/r - Sin[2*Pi*r1]/r1 -
Sin[2*Pi*r2]/r2)*Sz))*(Sin[2*Pi*(L2/2 - Abs[s])]/s),
{s, -L2/2, L2/2}]

(*Calculating constants *)
Sz = Sza[s, 1/4*Pi]
Sy = Sya[s, 1/4*Pi, 1/4*Pi]
Sx = Sxa[s, 1/4*Pi, 1/4*Pi]
ρ  = ρa[Sx, .6175, Sy]
r  = ra[ρ, .103, Sz]
r1 = r1a[ρ, .103, Sz, .395]
r2 = r2a[ρ, .103, Sz, .395]

(*Executing the integration equation, with constants plugged in *)
R21[ρ, r1, Sz, .103, .395, r2, r, Sx, .6175, Sy, 1.63]


After that, it ran for about 2 hours, and then just spit out R21 in its integration form.

What I am doing wrong?

Use NIntegrate to perform numerical integration (simply replace Integrate with NIntegrate in the definition of R21). On my laptop, it spits out the numerical value of the result in 0.3 s (and the result is 9.46643, by the way).
• So did you use Timing or AbsoluteTiming to figure out how long it took for the code to run? – dearN Apr 2 '12 at 22:52
• @DNA AbsoluteTiming, why? – F'x Apr 3 '12 at 7:01