[ccan] Mathematics Module

Rupinder Singh plitanium at gmail.com
Fri Feb 6 14:26:53 EST 2009


Hello,

  I think your original code was in fact optimal.  For example, it takes
> about 7.1 seconds to figure out that 36028797018963971 is prime on my
> 64 bit machine here.



The original routine (is_prime) is still there. I had expressed in my
previous mail
> but is_prime should be used for that due to its superior efficiency.

It takes less than a second to determine the primality of 36028797018963971
by is_prime. is_prime2 is the implementation of Sieve of Eratosthenes to
determine the prime numbers, not very efficient to determine primality, as
you just said.

Here are a few additions :

1) nCr - A Memory and Time efficient routine to calculate n! / (n-r)! r! .

2) newton_raphson - Determination of root, Newton-Raphson method. The user
has to overload the function fn(x) & fnd(x)  [its derivative] to implement
his given function.

3) ivp - Solution to the Initial Value Problem dy/dx = fnd2(x,y) , Given
y(x0) = y0, y(x1) = ?

4) romberg_integral - Definite Integration within closed limits [a, b],
Romberg's Method. fn(x) has to be overloaded.


Thanks,
Rupinder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20090206/c28fd548/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: numeric.h
Type: application/txt
Size: 6034 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20090206/c28fd548/attachment.bin>


More information about the ccan mailing list