### Computing in comfort

At the moment I'm lying in a hammock on our front porch, enjoying the weather. It's warm and sunny but the trees provide some nice shade. The birds are chirping, and except for a lawnmower running across the street, it's quite relaxing.

Internet connectivity is provided to my laptop via an open wireless access point. It must be from one of our neighbours, but I don't even know which one. Until I get my own access point, this will do. :)

Security is provided via openvpn, which I'm using to connect back into my own LAN.

Posted by Jason Hildebrand <jason@opensky.ca> Saturday Jul 9, 2005 at 0:00 PMI have a question that I think relates to arctan. I have two points on a circle, I know the radius of the circle and I know the coordinates of each of the two points. How do I find the midpoint of the arc between the 2 points.

Posted by:**antoine**on Saturday Jul 23, 2005 at 8:28 AM

Well, there are two of those points obviously, because the center
of the circle can lie either way of the connection between the points
(that's assuming you're working in a plane, i.e. 2d. You have an
infinite number of such points in 3d, and I don't want to think about
what happens if you've got more dimensions :-)

I'll call the points on the circle A and B (I'll use capital letters
for vectors and lower case otherwise).
Then the middle between them is (A+B)/2. I'll call that one M.
The distance of M to the center of the circle (call it C) is

dist = sqrt(r^2-(A-B)^2/4)

with r being the radius of the circle
(simple Pythagoras on the triangle A,M,C). I made a drawing, that
makes it much easier to see.

The distance of M to the circle is then r-dist. You now need
a normalized vector orthogonal to (B-A) to go from M to the
two points you're looking for:

N = 1 / sqrt((ay-by)^2+(bx-ax)^2) * [(ay-by), (bx-ax)]

and your two points are then M+dist*N and M-dist*N

So, there's a lot of squares and square roots in there, but no
arctan :-)

Regards,
Torsten

**Torsten**on Sunday Jul 24, 2005 at 7:17 AM

I have a question... I know it is possible to find Pi EXACTLY by using 4xArcTan(1). However, I am fairly convinced that it is possible to do this, or a slightly different method pertaining to the same thing, without using a calculator. I have tried, but ended up attempting to integrate [between the limits 1 and 0] sprt(1-X^2) and that didn't work so well. Help?

Posted by:**Justin**on Tuesday Jul 26, 2005 at 2:44 AM

sqrt(1-x^2) is the semi-circle function (radius 1), so yes, if you integrate that from 0 to 1, you get pi/4. But I'm afraid that won't take you anywhere - if there is a closed expression for that integral, it will be arctan(1) again or something similar, like arcsin(1/sqrt(2)).

The arctan(1) method would work as an approximation, I guess. I don't have the Taylor expansion for arctan ready, but you could use

arcsin(x) = x + 1/2 x^3/3 + (1/2)(3/4) x^5/5 + (1/2)(3/4)(5/6) x^7/7 + ...and evaluate arcsin(1/sqrt(2)) which gives you pi/4:

pi*sqrt(2)/4 = 1 + 1/2*(1/2^1/3) + 1/2*3/4*(1/2^2/5) + 1/2*3/4*5/6*(1/2^3/7) + ...

which you can compute e.g. like that (C snippet):

int step; double y=1, factor=1, count=1; for( step=0; step<50; ++step ) { factor *= 0.5 * count / (count+1); count += 2; y += factor / count; printf("step %i: pi is approximately %.20g\n", step, y*4.0/sqrt(2)); }

This doesn't converge very fast, though. I know there are lots of much better algorithms for calculating pi. The fastest I've heard of quintuples the number of correct digits in every step, but I don't know how it works.

Regards, Torsten Posted by:**Torsten**on Tuesday Jul 26, 2005 at 0:39 PM

nice soduku service. What about the solution of the puzzle. Is it possible to add the feature inn the generator? Nice work! Regards! :)

Posted by:**Michael**on Thursday Aug 25, 2005 at 4:37 AM

Yes, it probably wouldn't be much work to add the solutions as well (optionally). I will look into it if I can find the time.

Posted by:**Jason**on Friday Aug 26, 2005 at 0:59 PM