help-octave
[Top][All Lists]

## Re: Complex Integral

 From: Dirk Laurie Subject: Re: Complex Integral Date: Tue, 5 May 1998 09:43:55 +0200 (SAT)

```address@hidden wrote:
>
> Does anyone know how to representive the following in octave:
>
> the integral from x to 0 of ((1-cos(t))/t dt.
>
It's not an elementary function.  In the "Handbook of Mathematical
it is called Cin(x).  You can calculate it by numerical
integration.  For that purpose it is better
to write it as

Cin(t) = 2 integral    sin(t/2)^2/t   dt

The Handbook has a table of Cin(t) for x=0:pi/10:10*pi  on p244,
which you can use to check.

I've just spent a few minutes trying out the idea.  It's a good idea
to collapse full intervals of length 2*pi into one: since sin(t/2)^2
vanishes with its first derivatives at both endpoints, numerical
integration is easier.  I've also made a tiny substitution to
make the integrand simpler (u=t/2).

Here is a test run:

» type longpart
longpart is a user-defined function:

function y = longpart (u)
global n
y = sin (u) ^ 2 * sum (1 ./ (u + (0:n - 1) * pi));
endfunction
» type shortpart
shortpart is a user-defined function:

function y = shortpart (u)
global n
y = sin (u) ^ 2 / (u + n * pi);
endfunction
» global n; x=3.6*pi; n=fix(x/(2*pi)), r=rem(x,2*pi)/2,
n = 1
r = 2.51327412287183
ans = 3.08807509702346
» x=9.4*pi; n=fix(x/(2*pi)), r=rem(x,2*pi)/2,
n = 4
r = 2.19911485751286
ans = 3.99443579621003
»

The Handbook gives 3.0880751 and 3.9944358 respectively.

Dirk

```