Monday, October 19, 2009

SQUARE ROOT OF IOTA

SQUARE ROOT OF COMPLEX NUMBERS

i, the square root of -1 the fundamental complex number. Working out the square-root of i;


ON MATLAB

Trying it on Matlab


Fig 1. Matlab 1



Fig 2. Matlab 2

Matlab gives very precise result both by 'power of 0.5' and 'sqrt function'.

USING CMATH

Using cmath module in Python;


Fig 3. cmath 1


Fig 4. cmath 2

cmath also gives wonderful results, however it is worth noting that the real and complex parts are different in the last 2 digits ( 0.70710678118654757 in the real part while 0.70710678118654746 in the complex part); which should not be so as they both represent the same number !

USING SCIPY

Using Scipy, scientific and numerical module in python



Fig 5. Using Scipy

Similar results to that of cmath.

SQUARING THE ROOT !

Squaring the square root often confirms to the accuracy and resolution of the software.


Fig 6. Squaring the root in Matlab


Fig 7. Squaring the root in cmath


Fig 8. Squaring the root in scipy

SOME OBSERVATIONS

Matlab on squaring the root, gives precise results

cmath and scipy on squaring the root gives precise results for the complex part but odd results for the real part (2.2204460492503131e-16 for scipy and -2.2204460492503131e-16 for cmath).

Using (1j)**0.5 and sqrt(1j) in scipy yields different results in real parts (2.2204460492503131e-16 for (1j)**0.5 and -2.2204460492503131e-16 for sqrt(1j)).


For developing scipy there should be a sense of consistency with cmath and the resolution (digits in the answer) should be controlled at the discretion of the user( It really looks sleek in Matlab). Further it looks odd and conveys a sense of inconsistency if the complex part tallies completely with the expected result while the real part has an inconsistency.

Sunday, October 11, 2009

EULER'S GAMMA !

EULER'S GAMMA

Once again ! .... we meet Leonhard Euler ... a constant named after him. Euler-Mascheroni constant which runs as .... 0.57721 … called 'gamma' ,denoted by the Greek alphabet 'gamma' and is one of the important constants of mathematics.

From an abinitio, 'gamma' is defined as;

IN SCIPY

Trying it out in scipy
yields a very accurate gamma.....

Fig 1. gamma in scipy

Should gamma be build into scipy as pi and e ?

Fig 2. pi and e in scipy

IN MATLAB

Trying it in MATLAB


MATLAB recognises the integral as a special integral ! ...... with a vpa, the value is obtained.

Gamma and other mathematical constants should be build into Scipy and Scipy should be intelligent enough to identify these expressions and integrals.







REFERENCES
(1) Murray Spiegel

Thursday, October 1, 2009

AN EXOTIC INTEGRAL IN SCIPY

ADVENTURES IN SCIPY

Scipy is a module in python which allows for mathematical and scientific functions and tools. Trying to evaluate an exotic integral , using contour integration and complex analysis it can be shown that ;


Trying out the integral in scipy,
the function is introduced using lambda and the scipy.integrate.quad is used over 0 to infinity to obtain the results. The result comes up with a warning on infinite recursions and a recommendation to use a special-purpose integrator and the numeric value is 1.5708678849453777, which is with 0.0015587759422623915 of the correct value (~0.025% accurate).

Fig 1. The integral in scipy






REFERENCES
(1) Scipy
(2) Scipy mini anthology