-2

My assingment is to write a progmar which chechs wether certain function defined as f(a,b,c) works. The function returns 0j if the given points on a complex plain (complex(a,b)) are in the same circle which center is 0.

I can create the random points on the circle which center is at 0 and radius is 1, but for some reason the values dont work in the function. Any ideas why? and what am I doing wrong?

Here is my code:

http://pastebin.com/EcVqBFNb

And it should print all values as 0j, but for some reason I get something like this evety time with random ammount of 0j.

Test: 0j

Points: a: (-0.325568154457-0.945518575599j) b: (-0.990268068742+0.13917310096j) c: (-0.615661475326-0.788010753607j)

Function value: 0j

Points: a: (0.999390827019-0.0348994967025j) b: (-0.857167300702+0.51503807491j) c: (-0.173648177667+0.984807753012j)

Function value: (-4.44783940763e-17-1.77913576305e-16j)

Points: a: (-0.838670567945+0.544639035015j) b: (-0.0523359562429-0.998629534755j) c: (0.838670567945-0.544639035015j)

Function value: (-1.28197512426e-16-3.20493781064e-17j)

Points: a: (-0.374606593416-0.927183854567j) b: (-0.819152044289+0.573576436351j) c: (-0.5+0.866025403784j)

Function value: (-3.64618690079e-16-9.11546725196e-17j)

Points: a: (-0.809016994375-0.587785252292j) b: (0.224951054344+0.974370064785j) c: (0.173648177667-0.984807753012j)

Function value: 0j

Points: a: (-0.788010753607+0.615661475326j) b: (0.0523359562429+0.998629534755j) c: (0.956304755963-0.292371704723j)

Function value: (-3.87896960155e-17-1.55158784062e-16j)

Points: a: (0.0697564737441-0.99756405026j) b: (0.961261695938+0.275637355817j) c: (0.104528463268+0.994521895368j)

Function value: -6.41123604394e-17j

Points: a: (0.945518575599-0.325568154457j) b: (-0.2419218956-0.970295726276j) c: (0.5-0.866025403784j)

Function value: (1.56579962351e-16-2.45172846099e-32j)

Points: a: (0.642787609687-0.766044443119j) b: (0.920504853452-0.390731128489j) c: (-0.224951054344-0.974370064785j)

Function value: (2.07271721875e-16+1.03635860938e-16j)

Oliver
  • 19
  • 5

1 Answers1

0

http://floating-point-gui.de/

Your results are as close to zero as you can expect after performing a long chain of floating point operations. All is well.

Lutz Lehmann
  • 25,219
  • 2
  • 22
  • 51