IANAM, so this is more of a "inclination by a mathematically challenged member" ...
The 'remainder' for two numbers 'a' & 'b' is 'x=a%b' with the sign of 'a' preserved in 'x'. The 'modulus' OTOH, preserves the sign of 'b'. It's not clear to me how that information would be preserved with imaginary operands. Could we simply declare that the '//' operator on complex numbers would be the "modulus"? Then it becomes relatively easy: x + yi = (a + bi) % (c + di) m = sqrt( x**2, y**2 ) I can see no way that the operation could return the quadrant in which the imaginary point lies, however. -Chip- On 6/10/2014 11:25 AM Rick McGuire said: > This is a challenge for the mathematically inclined members of our > audience: Now would you define a remainder operation on complex numbers? > > I decided I would update some of the ooRexx samples for some of the > newer language features, since many of these samples are are 20+ years > old. I started with the complex number one, and during my ad hoc > testing, I was surprised to see that > > 5+0i // 2+0i was giving a result of 2+0i. This is clearly wrong. The > method implementing // just took the algorithm for division and > changed the operator to //. This worked for the % operation, but > fails badly for //. The code is this: > > a=real/* get real and imaginaries for */ > b=imaginary/* both numbers */ > c=divisor~real > d=divisor~imaginary > qr=((b*d)+(a*c))//(c**2+d**2)/* generate the new result values */ > > qi=((b*c)-(a*d))//(c**2+d**2) > > For both imaginary values zero, this results in a*c//c**2, or in my > example 10//4, which is off by a factor of 2. I'm inclined to just > delete this method, but if somebody can come up with a reliable > algorithm, I'd consider putting it in. > > Rick > > > ------------------------------------------------------------------------------ > HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions > Find What Matters Most in Your Big Data with HPCC Systems > Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. > Leverages Graph Analysis for Fast Processing & Easy Data Exploration > http://p.sf.net/sfu/hpccsystems > > > > _______________________________________________ > Oorexx-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > ------------------------------------------------------------------------------ HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions Find What Matters Most in Your Big Data with HPCC Systems Open Source. Fast. Scalable. Simple. Ideal for Dirty Data. Leverages Graph Analysis for Fast Processing & Easy Data Exploration http://p.sf.net/sfu/hpccsystems _______________________________________________ Oorexx-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/oorexx-devel
