Page 1 of 1

computing with a complex number

Posted: Wed Aug 23, 2006 5:58 pm
by john
how can i use i the square root of -1 in a qb programme

john

imaginary numbers

Posted: Thu Aug 24, 2006 1:41 am
by buff1
Not handled by qb. Probably fortran would be the best bet unless someone else has an idea.

Posted: Thu Aug 24, 2006 3:30 am
by Guest
It all depends on how you want to use the square root of -1, or i, as it is usually called. If you post a few mathematical examples of what results you are looking for, I'm sure we can help you.

For instance, in ac electricity, i is used o define a complex number that can also be handled as a vector with an angle.

computing wth complex numbers

Posted: Thu Aug 24, 2006 11:05 am
by john page
thank you for your replies, I'm looking at fractal images, from what I read last night in 'fractal cosmos' by Lifesmith you use the size or nomal value of
the term containing i plotted on the complex plane which is the distance from the Nul point in the the complex plane. I'm still trying to get my head round it. The size or norm is the length of the hypotenuse of the triangle outlined by the points plotted by the complex variable & the origin. As this length involves souares i becomes some value K*-1 & is always a real number..

Posted: Fri Aug 25, 2006 9:52 pm
by Guest
If you can post a few examples of your complex numbers, and what you expect as a result, I'm sure we can help you.

computing with complex numbers

Posted: Sat Aug 26, 2006 2:36 pm
by john page
If I have a function say f(z)= z^2+c
where z=2+3i & c = 4+5i, i=(-1)^0.5
I would like to evaluate f(z) & plot the results
on the complex plane Thanks John

Re: computing with complex numbers

Posted: Sat Aug 26, 2006 9:13 pm
by Ralph
john page wrote:If I have a function say f(z)= z^2+c
where z=2+3i & c = 4+5i, i=(-1)^0.5
I would like to evaluate f(z) & plot the results
on the complex plane Thanks John
First of all, please note that, in complex numbers, the imaginary square root of -1 is used as a special symbol to indicate a 90-degree direction of the y component, from the x component. Its use is as follows.

To evaluate your function, you would enter each of te two components of z and c, from z = x+iy, and c = a+ib, thus:

Code: Select all

x=2:y=3
a=4:b=5
z=sqr(x^2+y^2)
c=sqr(a^2+b^2)
Fz=z^2+c
'and, to show the final result
PRINT "F(z) =";Fz

Posted: Sun Aug 27, 2006 2:20 pm
by Guest
Thank you Ralph I'm very grateful John

Posted: Wed Aug 30, 2006 3:24 pm
by Guest
Ok I've tried this before and the process is

c=a+ib
f(0)=c
f(1)=f(0)^2+c

so real f(1)=a^2-b^2+a
imag f(1) = 2*a*b +b

f(2)=f(1)^2+c

and you keep on doing this to see how quickly the function diverges.

Then choose a different value for c and repeat

Code: Select all

SCREEN 12
DEFINT I-K
FOR ix = 1 TO 640
FOR iy = 1 TO 480
cr = ix / 220 - 2
ci = iy / 160 - 1.5
WHILE (ABS(zoi) - ABS(ci) + ABS(zor) - ABS(cr) < 25) AND k < 128
znr = zor * zor - zoi * zoi + cr
zni = 2 * zoi * zor + ci
zor = znr: zoi = zni
k = k + 1
WEND
IF k < 8 THEN k = 1
k = k MOD 16
PSET (ix, iy), k
zoi = 0: zor = 0: k = 0
NEXT iy
NEXT ix
SLEEP