Saturday, February 11, 2006

playing with ellipse

i was trying to plot an ellipse on matlab figure window for one class homework and that problem turned out to be an interesting one..
first i started off with a basic ellipse equation and it involved little challenge.. the main task came when i was supposed to plot a tilted ellipse.. here is the code.. try it and have fun...

---------------------------------------------------------------------------------------
function [xout,yout1,yout2] = my_ellipse(x1,y1,a,b,c,rot)
%
%function [xout,yout1,yout2] = my_ellipse(x1,y1,a,b,c,rot)
%this one draws a ellipse.
%
% Input values:
% Centre = (x1,y1)
% semimajor axis = a
% semiminor axis = b
%
% 2
% covariance XY = c
%
% rot: 1 for clockwise roatition
% -1 for anti clockwise rotation.
%
% Equation of the ellipse is written as
% 2 2
% (x-x1) (y-y1) (x-x1)(y-y1)
% ------ + ----- - ------------ = 1
% 2 2 2
% a b c
%
%
%
% which uses
% 2 2
% p(X) + q(Y) - r(XY) - s = 0;
% where X = x-x1
% Y = y-y1
%
% plot : use the following
% plot(xout,yout1);hold on; plot(xout,yout2);


s = 1;
p = s/a^2;
q = s/b^2;
if nargin <6 rot =" 1;" r =" 0;" r =" rot*s/c^2;" lim =" sqrt(s/abs(p" x =" [-lim:2*lim/100:lim];" y =" b*sqrt(1" y1 =" (r*X" y2 =" (r*X" xout =" X+x1;" yout1 =" Y1+y1;" yout2 =" Y2+y1;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/648/1137/1600/1.0.jpg">

Saturday, November 19, 2005

Buffon's Needle Problem

I've come across this in my first probability class. The problem goes that there are a set of parallel lines spaced at "2b" distance apart and there is a needle of length "2a". Assuming a < b.The needle is dropped randomly and the problem is to find the probability that the needle crosses the line. Ans: (2a)/(b*pi)

There is an interesting side to this problem. Apart from probability this problem links up geometry and by this formula we can actually derive the value for pi.
pi = 2a/(b*P)
where P = measured probability. Let us use the relative frequency method to calculate P. Assume N needles are thrown once(which is equivalent to saying one needle is thrown N times.) and say Nr of them cross the lines. Hence P = Nr/N.

It is interesting to know that for a small number like N = 100, the calculated value of pi deviates from the standard value for pi by 1%....

I was really astonished to see something(the experiment) which is probabilistic to actually use to measure something deterministic(pi) :-)

Thursday, September 15, 2005

why did we create numbers

I mugged up tables in school without actually knowing what they meant. I did the mathematical operations on numbers without actually knowing what I was doing.

Lets say why we had to create negative numbers?
I could relate the answer to the daily problem in trading world. Person A borrows X units of money from B and so person A has -X money. And hence all the math in the money trade becomes easier.

Why did we have to create "i" - the complex number?
X^2 - 1 = 0 is a second order equation and it has clearly two roots
X = 1 and X = -1..

but how about X^2+1 = 0 ... we come up with a number "i" and say X = +i and X = -i are the two roots.

If we get back to the conceptual level it is basically X =1 and X = -1 on the imaginary line. Why did we have to have an imaginary line. It is because we would like to describe two systems (one corresponding to real axis and other to imaginary axis) at the same time.
That is when we write e^(jx) = cos(x) + i sin (x)... we would like to analyse cos(x) and sin(x) at the same time. in other words we would like to analyze the property of a general sinusoid signal measuring its phase from a cosine of same frequency and sine of the same frequency. [remember any sinusoid can be perfectly reconstructed if we know the amplitude, frequency and phase]

*********************************
more on the number "e" in the future posts.

Thursday, September 08, 2005

142857

this is a fundoo number. thx to sms forwards i got my eyes on this. check out the interesting stuff about this number below

1 × 142,857 = 142,857
2 × 142,857 = 285,714
3 × 142,857 = 428,571
4 × 142,857 = 571,428
5 × 142,857 = 714,285
6 × 142,857 = 857,142

the resulting numbers are anagrams of the initial number.

it is derived from 1⁄7 = 0 . 142857 142857 14...

can we build any relation?
are there any more similar numbers?
does it have any physical significance to the universe?

Wednesday, July 06, 2005

pythagoras theorem



a simple proof of this wonderful basic theorem ... its usage is ubiquitous

a+b the whole cube





extending the same idea to the power three

Sunday, July 03, 2005

a+b the whole square



starting off with the basic rectangle area.