Hi
this is my first post here
please don't shoot if i do something wrong ;)
This is what i'm doing:
I'm trying to write a method that solves for the powers of complex numbers. I know that there are modules available for this, but for my current situation, using those modules aren't practical, so I am forced to write my own.
this is my code:
#FINDS THE COMPLEX ARGUMENT
#PRETTY SURE THIS WORKS TOO
sub argComplex {
my $value1, $real1, $complex1;
$value1 = @_[0];
@construct = &constructComplex($value1);
$real1= @construct[0];
$complex1 = @construct[2];
return atan2($complex1, $real1);
}
$real1 = 1;
$z = 1 + i;
#LOOK HERE
#RETURNS ZERO
#I DON'T KNOW WHY
#BY ITSELF, argComplex($z) RETURNS 0.7854, WHICH IS RIGHT ACCORDING TO
+ MATLAB
print $real1 * argComplex($z);
when the print function goes through, it prints 0 instead of the right answer. I'm convinced there is some weird rule in Perl that I'm not following.
If you get it to print $real1, it prints 1
If you get it to print argComplex($z), it prints .7854
but if you get it to print $real1 * argComplex($z), it prints Zero
Please Help
Thanks,
Donnell