Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I need to integrate the following between x = $-1$ and $1$: $$ f(x) =x (\cos(x)/\sin(x))$$ As far as I know it is not possible to obtain exact integration to this integral. I was trying to solve using a Gaussian quadrature method. So I used Gauss-Legendre Quadrature with two integration points as follows: $$\int_{-1}^{1}{f(x)}=\underset{i=1}{\overset{2}{\sum}}w_i \, f(z_i)$$ where $w_1=w_2=1$ and $z_1 = -1/\sqrt(3)$ and $z_2 = 1/\sqrt(3)$
and I got some results but they seem to be somewhat greater that what I should be getting. I was wondering if someone could verify that what I am doing is correct. Thank you in advance!

share|improve this question
    
Can you be more precise about what you are doing? For example, what are your results, and what were you expecting? –  Ron Gordon Feb 20 '13 at 11:07
    
Also, I edited your expression of the G-L sum for clarity. –  Ron Gordon Feb 20 '13 at 11:27
    
Thanks, Basically, I need to evaluate the integral of a function g(z) at a set of points that are not equally spaced. Let's assume f(x) is the weighted function I got when I transformed g(z) into global coordinates. So I then have a function the second equation ... (I hope that is clear enough) –  Hooman Feb 20 '13 at 14:02
    
I know what you are talking about. It is not accurate, though, to speak of the weights being a function of the coordinate; rather, they and the coordinates are a function of the weighting function, interval, and number of sample points. That said, pretty amazing how few points you need to get within 1% of the exact result! (Because of the symmetry, that was one function evaluation.) –  Ron Gordon Feb 20 '13 at 19:30

1 Answer 1

Using the two-point Gauss-Legendre as you illustrated, I get a value of about $1.77268$ for the integral. The exact value, evaluated out to this many digits, is $1.76823$. This is not bad for a two-point evaluation.

By the way, the exact value of the integral is

$$\int_{-1}^1 dx \: x \cot{x} = 2 \Re{[\log{(1-\cos{2} + i \sin{2})}]} + \Im{\mathrm{Li}_2(\cos{2} + i \sin{2})}$$

share|improve this answer
    
thanks, I need to avoid imaginary numbers. –  Hooman Feb 20 '13 at 13:49
    
Are you writing this in code? The log can be rewritten to avoid any mention of imaginary numbers. As for the polylog term, I'm not sure how to attack that. In any case, I evaluated this in Mathematica and I am sure it is doable in Wolfram Alpha. Getting an exact result is extremely useful here in order to gauge how well your quadrature schemes are working. –  Ron Gordon Feb 20 '13 at 19:32

Your Answer

 
discard

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.