axiom-developer
[Top][All Lists]

## [Axiom-developer] [#47 complexForm(log(%i) - log(-%i))]

 From: wyscc Subject: [Axiom-developer] [#47 complexForm(log(%i) - log(-%i))] Date: Sat, 16 Jul 2005 00:02:35 -0500

Changes
http://page.axiom-developer.org/zope/mathaction/47ComplexFormLogILogI/diff
--
Martin:

Thanks for pointing out my error. In coding 'myArgument', I was not aiming for
a general definition. I was experimenting to see if there is need for
'RealNumberSystem' or 'OrderedRing'.
As you proposed, it seems the error in 'myArgument' may be fixed by a two
argument version of 'atan' (which only exists for 'Float' and 'DoubleFloat'
currently). The usual sign convention will take care of the case of inputs
involving variables. But I am not convinced one way or the other that
'OrderedRing' is needed.

\begin{axiom}
myhalf: ()-> EXPR INT
myhalf()==recip(2::EXPR INT)::EXPR INT
pi1:= pi()\$(EXPR INT)
pi2 := pi1 * myhalf()
myatan2(x:EXPR INT, y: EXPR INT): EXPR INT ==
x = 0 => if y >= 0 then %pi else -%pi
-- Atan in (-pi/2,pi/2]
theta := atan(y * recip(x)::EXPR INT)
-- may create infinite loop if variables are used in input
-- in any case, why would atan give a result outside (-pi/2, pi/2]?
-- while theta <= -pi2 repeat theta := theta + pi1
-- while theta > pi2 repeat theta := theta - pi1
x >= 0 => theta      -- I or IV
if y >= 0 then
theta + pi1      -- II
else
theta - pi1      -- III
myatan2(1,-1)
myatan2(y,x)
myArgument: Complex EXPR INT -> EXPR INT
myArgument(x) ==
zero? real x =>
imag(x) > 0 => pi2
imag(x) < 0 => - pi2
error "myArgument not defined at (0,0)"
myatan2(real x, imag x)
myArgument(-%i)
myArgument(%i)
myArgument(3+5*%i)
myArgument(3-5*%i)
myArgument(-1+%i)
myArgument(2 - x*%i)
myArgument(0::Complex EXPR INT)
\end{axiom}

William
--