computing with a complex number
Moderators:Administrator, Global Moderator
how can i use i the square root of -1 in a qb programme
john
john
imaginary numbers
Not handled by qb. Probably fortran would be the best bet unless someone else has an idea.
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.
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
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..
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..
computing with complex numbers
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
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
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.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
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
Ralph. Running QuickBASIC Version 4.5, Windows XP Home Edition, Version 2002, Service Pack 2, and HP LaserJet 4L printer.
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
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