COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Help with numerical integration

• Email
• Follow

Hi all,

I have never been particularly fond of numerical integration and
generally do it pretty infrequently these days.  Nevertheless, I am
trying to do a 'quick-and-dirty' atmospheric refraction/ray-trace
calculation and I'm stumped on the integration.  The integral reads:

s = \int_{r1}^{r2}  ( n(r) * r * dr ) / sqrt( n(r)^2 - c^2 )

where c is a constant.  The trouble I'm having is that n is a function
of r.  Thus, I have a set of discrete points for r:

0.00000      1.00000      2.00000      3.00000      4.00000
5.00000      6.00000
7.00000      8.00000      9.00000      10.0000      11.0000
12.0000      13.0000
14.0000      15.0000      16.0000      17.0000      18.0000
19.0000      20.0000
21.0000      22.0000      23.0000      24.0000      25.0000
26.0000      27.0000
28.0000      29.0000      30.0000      31.0000      32.0000
33.0000      34.0000
35.0000      36.0000      37.0000      38.0000      39.0000
40.0000      41.0000
42.0000      43.0000      44.0000      45.0000      46.0000
47.0000      48.0000
49.0000      50.0000      51.0000      52.0000      53.0000
54.0000      55.0000
56.0000      57.0000      58.0000      59.0000      60.0000
61.0000      62.0000
63.0000      64.0000      65.0000      66.0000      67.0000
68.0000      69.0000
70.0000      71.0000      72.0000      73.0000      74.0000
75.0000      76.0000
77.0000      78.0000      79.0000      80.0000      81.0000
82.0000      83.0000
84.0000      85.0000      86.0000      87.0000      88.0000
89.0000      90.0000
91.0000      92.0000      93.0000      94.0000      95.0000
96.0000      97.0000
98.0000      99.0000      100.000      101.000      102.000
103.000      104.000
105.000      106.000      107.000      108.000      109.000
110.000      111.000
112.000      113.000      114.000      115.000      116.000
117.000      118.000
119.000      120.000

and a set of corresponding points for n(r):

3210.0997       1915.7633       1031.6773       492.45952
253.87699       125.97528
60.358510       28.798265       14.395186       7.6860971
3.7610915       1.4102413
1.0227767       1.0044470       1.0012146       1.0003848
1.0001596       1.0001319
1.0001193       1.0001084       1.0001147       1.0001217
1.0001248       1.0001266
1.0001274       1.0001257       1.0001244       1.0001259
1.0001277       1.0001302
1.0001338       1.0001371       1.0001398       1.0001418
1.0001443       1.0001467
1.0001496       1.0001525       1.0001557       1.0001591
1.0001626       1.0001662
1.0001701       1.0001742       1.0001787       1.0001837
1.0001883       1.0001915
1.0001952       1.0001991       1.0002034       1.0002080
1.0002133       1.0002177
1.0002231       1.0002281       1.0002309       1.0002338
1.0002362       1.0002342
1.0002335       1.0002329       1.0002331       1.0002304
1.0002273       1.0002229
1.0002154       1.0002079       1.0002032       1.0001983
1.0001917       1.0001836
1.0001748       1.0001659       1.0001570       1.0001472
1.0001364       1.0001261
1.0001162       1.0001071       1.0000989       1.0000926
1.0000869       1.0000819
1.0000777       1.0000739       1.0000705       1.0000671
1.0000638       1.0000605
1.0000570       1.0000535       1.0000501       1.0000466
1.0000432       1.0000401
1.0000372       1.0000344       1.0000319       1.0000295
1.0000272       1.0000251
1.0000232       1.0000213       1.0000195       1.0000177
1.0000159       1.0000143
1.0000127       1.0000112       1.0000097       1.0000083
1.0000072       1.0000060
1.0000052       1.0000044       1.0000039       1.0000034
1.0000030       1.0000026
1.0000024

I have three similar integrals to evaluate but I'm pretty lost at the
moment.  Sadly, I suspect this isn't as difficult as I am making it.

Any ideas?

Cheers,
Dave


 0
Reply 12/4/2006 10:31:47 PM

See related articles to this posting

While it probably doesn't matter too much, the integral should have

s = \int_{r1}^{r2}  ( n(r) * r * dr ) / sqrt( n(r)^2 * r^2 - c^2 )


 0
Reply 12/4/2006 10:39:52 PM

In article <1165271507.802034.200410@j72g2000cwa.googlegroups.com>, "Dave" <Confused.Scientist@gmail.com> writes:
>Hi all,
>
>I have never been particularly fond of numerical integration and
>generally do it pretty infrequently these days.  Nevertheless, I am
>trying to do a 'quick-and-dirty' atmospheric refraction/ray-trace
>calculation and I'm stumped on the integration.  The integral reads:
>
>  s = \int_{r1}^{r2}  ( n(r) * r * dr ) / sqrt( n(r)^2 - c^2 )
>
>where c is a constant.  The trouble I'm having is that n is a function
>of r.  Thus, I have a set of discrete points for r:
>
>      0.00000      1.00000      2.00000      3.00000      4.00000
>5.00000      6.00000
>      7.00000      8.00000      9.00000      10.0000      11.0000
>12.0000      13.0000
>      14.0000      15.0000      16.0000      17.0000      18.0000
>19.0000      20.0000
>      21.0000      22.0000      23.0000      24.0000      25.0000
>26.0000      27.0000
>      28.0000      29.0000      30.0000      31.0000      32.0000
>33.0000      34.0000
>      35.0000      36.0000      37.0000      38.0000      39.0000
>40.0000      41.0000
>      42.0000      43.0000      44.0000      45.0000      46.0000
>47.0000      48.0000
>      49.0000      50.0000      51.0000      52.0000      53.0000
>54.0000      55.0000
>      56.0000      57.0000      58.0000      59.0000      60.0000
>61.0000      62.0000
>      63.0000      64.0000      65.0000      66.0000      67.0000
>68.0000      69.0000
>      70.0000      71.0000      72.0000      73.0000      74.0000
>75.0000      76.0000
>      77.0000      78.0000      79.0000      80.0000      81.0000
>82.0000      83.0000
>      84.0000      85.0000      86.0000      87.0000      88.0000
>89.0000      90.0000
>      91.0000      92.0000      93.0000      94.0000      95.0000
>96.0000      97.0000
>      98.0000      99.0000      100.000      101.000      102.000
>103.000      104.000
>      105.000      106.000      107.000      108.000      109.000
>110.000      111.000
>      112.000      113.000      114.000      115.000      116.000
>117.000      118.000
>      119.000      120.000
>
>and a set of corresponding points for n(r):
>
>       3210.0997       1915.7633       1031.6773       492.45952
>253.87699       125.97528
>       60.358510       28.798265       14.395186       7.6860971
>3.7610915       1.4102413
>       1.0227767       1.0044470       1.0012146       1.0003848
>1.0001596       1.0001319
>       1.0001193       1.0001084       1.0001147       1.0001217
>1.0001248       1.0001266
>       1.0001274       1.0001257       1.0001244       1.0001259
>1.0001277       1.0001302
>       1.0001338       1.0001371       1.0001398       1.0001418
>1.0001443       1.0001467
>       1.0001496       1.0001525       1.0001557       1.0001591
>1.0001626       1.0001662
>       1.0001701       1.0001742       1.0001787       1.0001837
>1.0001883       1.0001915
>       1.0001952       1.0001991       1.0002034       1.0002080
>1.0002133       1.0002177
>       1.0002231       1.0002281       1.0002309       1.0002338
>1.0002362       1.0002342
>       1.0002335       1.0002329       1.0002331       1.0002304
>1.0002273       1.0002229
>       1.0002154       1.0002079       1.0002032       1.0001983
>1.0001917       1.0001836
>       1.0001748       1.0001659       1.0001570       1.0001472
>1.0001364       1.0001261
>       1.0001162       1.0001071       1.0000989       1.0000926
>1.0000869       1.0000819
>       1.0000777       1.0000739       1.0000705       1.0000671
>1.0000638       1.0000605
>       1.0000570       1.0000535       1.0000501       1.0000466
>1.0000432       1.0000401
>       1.0000372       1.0000344       1.0000319       1.0000295
>1.0000272       1.0000251
>       1.0000232       1.0000213       1.0000195       1.0000177
>1.0000159       1.0000143
>       1.0000127       1.0000112       1.0000097       1.0000083
>1.0000072       1.0000060
>       1.0000052       1.0000044       1.0000039       1.0000034
>1.0000030       1.0000026
>       1.0000024
>
>I have three similar integrals to evaluate but I'm pretty lost at the
>moment.  Sadly, I suspect this isn't as difficult as I am making it.
>
>Any ideas?
>
Equally spaced data, any variant on Simpson will do well here.  I'm
using my own, INTEG, you can find it in Midl_lib on the users
contributions page of RSI.  but, as I said, any Simpson will do.

Mati Meron                      | "When you argue with a fool,
meron@cars.uchicago.edu         |  chances are he is doing just the same"

 0
Reply mmeron (89) 12/4/2006 11:13:42 PM

On 4 Dec 2006 14:31:47 -0800, "Dave" <Confused.Scientist@gmail.com>
wrote:

>Hi all,
>
>I have never been particularly fond of numerical integration and
>generally do it pretty infrequently these days.  Nevertheless, I am
>trying to do a 'quick-and-dirty' atmospheric refraction/ray-trace
>calculation and I'm stumped on the integration.  The integral reads:
>
>  s = \int_{r1}^{r2}  ( n(r) * r * dr ) / sqrt( n(r)^2 - c^2 )
>
>where c is a constant.  The trouble I'm having is that n is a function
>of r.  Thus, I have a set of discrete points for r:

I'm not sure why "n is a function of r" would be a problem for
numerical integration. As long as you can evaluate it, as you clearly
can, there is no problem. Or am I missing something?

You can for example use IDL's  INT_TABULATED where
X=r and F = ( n(r) * r) / sqrt( n(r)^2 * r^2 - c^2 )


 0
Reply nomail37 (266) 12/5/2006 9:28:32 AM

On Tue, 05 Dec 2006 10:28:32 +0100, Wox <nomail@hotmail.com> wrote:

>You can for example use IDL's  INT_TABULATED where
>X=r and F = ( n(r) * r) / sqrt( n(r)^2 * r^2 - c^2 )

Maybe QROMB or QSIMP are better, I don't know. Check the manual and
try them out :-).


 0
Reply nomail37 (266) 12/5/2006 9:41:14 AM

4 Replies
52 Views

Similar Articles

12/13/2013 12:30:54 AM
[PageSpeed]

Similar Artilces:

A routine for numerical integration over the unit sphere. HELP ME!
Hi all, I'm trying to compile a fortran program (RDSTY-E-CEN.f) that requires a routine called QUADS2(arg1, arg2). Because the author has included all the needed files (and others) in the attached archive (available at http://www.math.uiowa.edu/ftp/atkinson/bie.package/version%232/bie.tar.Z), I don't understand why I can't find the QUADS2 routine too! I'm new in fortran so I thought that it could be a well known routine, but I don't found it on the net. The author comments said only: "Note that the routine QUADS2 is used to numerically integrate the function F(xi,eta,z...

Help for an integral
Help needed : I can't - and Mathematica 5.0 can't either - integrate this : In[1]:= Integrate[x^2 / E^(a*(1 - 2*x^2)^2), {x, 0, 1}, Assumptions -> a >= 0] Out[1]= (2*IntegrateTableDumpc$70*E^IntegrateTableDumpc$70^2 - Sqrt[Pi]*Erfi[IntegrateTableDumpc$70])/E^(5*a)/ (4*IntegrateTableDumpc$70^3) Thanks in advance for any hint. v.a. Not even simple e^-x^2 can be integrated exactly between finite intervals. You could try writing a function of a that will return a numerical value of the integral (just use NIntegrate). Sebastjan Hi, at...

Help to solve an integral by using Mathematica Integrate[Sqrt[t
Could anybody help me to implement this integral in Mathematica? Integrate[Sqrt[t (1-t) (z-t)],{t,0,z}] where z and t are real with intervals 0<t<1 and 0<z<1. I'd really appreciate any help for this problem. ...

help for an integration
I'm in trouble with an integration. The function is: y = ((1.45921*10^15)*(169.282026-x)^(-9)); I need to integrate it between -inf and 108. I tried every function I know and find, but can't find the result. can anyone help me? Hi Ipek, Try this int('(1.45921*10^15)*(169.282026-x)^(-9)',-inf,108) This calculates the integral with a small error. ipek wrote: > > > I'm in trouble with an integration. The function is: > y = ((1.45921*10^15)*(169.282026-x)^(-9)); > > I need to integrate it between -inf and 108. I tried every function > I > know and...

Solve integral numerically
Hello evryone, I am trying to solve an integral numerically. The examples below explain my problem. Ra=[2:0.25:4]'; for i=1:length(Ra) h2=exp(-x.^2/Ra(i,1)); F=inline(h2); Q(i,2) = quad(F,-100000,Ra(i,1)); end for i=1:length(Ra) h2=normcdf((x/Ra),0,1); F=inline(h2); Q(i,2) = quad(F,-100000,Ra(i,1)); end While in the first case the code works, in the second it doesn't. In other words, I would like normcdf to accept two parameters. Thanks evrybody for the help "mariodif di Filippo" <mariodifi@yahoo.it> wrote in message <gn28ht$23j$1@fred...

Help, defined integral...
Hello.... Somebody can follow the links of this discussion and to help me... http://www.adictoshp.org/modules/newbb/viewtopic.php?topic_id=3401&forum=12&post_id=21844#forumpost21844 ...

Optimizing a numerical integration
Dear all, I have an optimization problem that takes the following form Min integation f(x) (the limits of integration are from 0 to a) s.t. g(x)=b where a, b are known constants. Suppose that f(x) and g(x) have no closed forms but they are computed using the simulation or markov chain technique that involve certain loops, could this be done using SAS? Regards, Aya Yes, SAS is just like any programming language and you can use loops. "aly omara" wrote in message news:832dc452-8153-4baf-9baf-bc54cdb61d63@l7g2000vbj.googlegroups.com... Dear all, I have an...

Help with numerical differentiation
I am really confused and stuck at doing this numerical computation. I have searched the archives of this group and tried what was suggested with no solution---Thanks to all in advance. Here is what I am trying to do, elaborated with comments: LPDF[mu_, sigma_, z_] = PDF[LogisticDistribution[mu, sigma], z] UU = U[mu_, sigma_, a_, b_, S_] := NIntegrate[LPDF[mu, sigma, y]*(b ( a + y) + S), {y, -(a + S/b), =E2=88=9E}] - a^2 **defining a function using the logistic distribution and then numerically integrating it over some range... everything seems to work so far** SetSystem...

Nested numerical integration
Hi, I'd like to compute a nested integral like, NIntegrate[ w^2 * NIntegrate[1/(s-w), {s, 1, 5}], {w, -5, -1}] Unfortunately, mathematica gives me an error (NIntegrate::inumr) and it also outputs the wrong value. Is there a way to do these types of integrals? On 4/28/09 at 4:45 AM, tsg.moore@googlemail.com wrote: >Hi, I'd like to compute a nested integral like, >NIntegrate[ w^2 * NIntegrate[1/(s-w), {s, 1, 5}], {w, -5, -1}] >Unfortunately, mathematica gives me an error (NIntegrate::inumr) and >it also outputs the wrong value. Is there a way to do these...

Numeric Integration Methods
A couple of weeks ago, a few people mentioned wanting programs for evaluating integrals via Riemann Sums, Trapezoid Rule, Simpson's Rule, etc... I teach calculus and over the past couple of years that I've had my 49G+, I've written such a set of programs to use in class. Reading the messages a couple of weeks ago got me to thinking that perhaps someone else might benefit using them. The main advantage my programs have over others I've seen is that they use a similar syntax and interface as the built-in integration. For example, to use the built-in definite integral, you wou...

Mathematica Integration help
Hi I'm new to Mathematica, I don't know if there are other help forums beside this one. I need help estimating the integrated likelihood function with mathematica 6. My function is below(all equations below are in mathematica raw input form, pls convert to standard form to see how they really look like): Integrate[Product[1/(E^((Subscript[x, i] - \[Mu])^2/(2*\[Sigma]^2))* Sqrt[2*Pi*\[Sigma]^2]), {i, 1, n}], \[Mu]] The result that it's giving me is the following: -(2^(-(1/2) - n/2)* E^((n*(-\[Mu] + Subscript[x, i])^2)/(2*\[Sigma]^2))* Pi^(1/2 - n/...

Numerical or Analytical integration
Dear all, 1- I have an S-Function written in C within my Simulation. There is an integration done somewhere that I could not figure out within the C coded S-function? any thoughts of how the integration could be perfromed implicitly? Could it be done analytically and then just being coded somehow!!!???? I would be Extremely grateful if you could give me hint, Thanks so much for answering me. Hi, When you say S - function do you mean a Laplace function, in the the S domain? Integration can be done by using one of the following techniques: * Gauss-Legendre Quadrature and the generat...

Numerical Integration #2
Hello: Has anyone done numerical integration in SAS, other than routines like FFT? What about Gauss-Laguerre etc.? Look forward to your input, or your trials & tribulations. Many thanx, OR Stats On Mar 10, 6:22=A0am, stats...@GMAIL.COM (OR Stats) wrote: > Hello: > > Has anyone done numerical integration in SAS, other than routines like FF= T? > What about Gauss-Laguerre etc.? =A0Look forward to your input, or your tr= ials > & tribulations. > > Many thanx, > OR Stats You can define your own numerical integration with SAS/IML call quad routine. Here is the w...

numerical integration #26
Hi I need your help! I have measurement of acceleration in axis X,Y,Z (cca 6000 measurement with spet 0.02sec). I want to get final position with using Numerical Integration in Matlab. Can anybody help me? please mail me: jankozavodny@gmail.com Timestamp Accelerometer-X (mg) Accelerometer-Y (mg) Accelerometer-Z (mg) Gyroscope-X Gyroscope-Y Gyroscope-Z 0 -47 -4 1001 6 7 19 0.02 -49 -7 1001 1 7 20 0.04 -48 -6 998 2 6 17 0.06 -49 -6 1001 4 5 20 0.08 -49 -7 999 7 5 18 0.1 -50 -8 997 4 10 17 0.12 -49 -8 997 8 3 20 0.14 -47 -7 997 2 6 17 0.16 -44 -5 1001 6 9 19 0.18 -51 -6 996 8 ...

Numerical Integration for Matrix
Is there built in function for MATLAB that can do numerical integration for matrix? Equation in the matrix is so complex that the symbolic integration in MATLAB cannot give the answer..I have used QUADV function but its for vector & furthermore you have to write your equation as function for the QUADV to be able to solve. . ...

Help- I need to Integrate with hp49g+!
Hello everybody: Please I want to integrate X, sin(X) or any expression with my new calculator but I am getting always, but always the same error message Error: Undefined Name I have tried 3 months using DERVX(X) for example, but I cannot integrate. I spent my money with this calculator and I don't know how to get just a basic integration. Also where is the old library of small programs that the old hp 48 has built-it, like Mohr's circle or so...? RPN: 'x' 'ENTER' 'SIN' 'INTVX' 'ENTER' JuanP wrote: > Hello everybody: > Please I wa...

Numerical integration and list of points
Hello everyone, I have a function which I read as a list of points. I want then to estimate its integral. I do more or less this : data={{x1,y1},{x2,y2},...,{xN,yN}} f=Interpolation[data] NIntegrate[f[x],{x,x1,xN}] Is it the correct way ? Because Mathematica hangs without giving me an answer although it seems a pretty straightforward thing to do... Thanks for any suggestions. HI, what you describe sounds reasonable and should work. Did you check for syntax errors? How many pints are there? Try it with a few points and you may find the bug. hope this helps, ...

Help needed with a numeric more than function.
I want to show a figure based on an numeric entry that more than 20 (or 21and higher). If Number value is 21 or higher then the amount returned is Number value * 120 (�) * 10 (%) to give a discount on 21 and higher. How to I add that function to this line of code. SAmt0 = Math.round(eval(form.Number.value * 12000 * 0.1)); form.Amt0.value = AddDecimal(SAmt0); Thanks. : If Number value is 21 or higher then the amount returned is Number : value * 120 (�) * 10 (%) to give a discount on 21 and higher. input_number = eval(form.Number.value); input_price_pounds = 120.00; input_price_pennies ...

2-d numerical integration
hi, i have a question about 2-d integral. i have a matrix for x,y,data and i can't express my data as a function. how can i do an integral on the data with respect to the x,y points? thanks for the helpers "Tomer Alon" <tomeralon112@gmail.com> wrote in message <is0cmq$fbf$1@newscl01ah.mathworks.com>... > hi, i have a question about 2-d integral. > i have a matrix for x,y,data and i can't express my data as a function. > how can i do an integral on the data with respect to the x,y points? > thanks for the helpers You cannot integrate points. Points, s...

Question about double numerical integral
I have a trouble to do numerical integration. The function is: exp((-x^2-y^2)/r^2)dxdy; the interval of x and y is arbitary. Anybody can help me out? Thanks a lot! Adam Try the "dblquad" function. Follow this link. http://www.mathworks.com/access/helpdesk/help/techdoc/ref/dblquad.html "Adam" <nirvana_wz@hotmail.com> wrote in message news:ef0abe9.-1@webx.raydaftYaTP... >I have a trouble to do numerical integration. The function is: > exp((-x^2-y^2)/r^2)dxdy; the interval of x and y is arbitary. Anybody > can help me out? > Thanks a lot! > Adam In ...