Raised to block in operators category

Report bugs. Post bug workarounds or fixes

Moderator: MSandro

Post Reply
vickiS
Posts: 7
Joined: Oct 5th, '17, 16:26
Contact:

Raised to block in operators category

Post by vickiS » Nov 19th, '17, 17:43

If first operand in (raised to) block is negative the block returns nan in Ubuntu and -1.#INF in Windows 10. I can work around with (-1) * (n raised to n). All other cases give expected result.

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Raised to block in operators category

Post by JohnM » Nov 19th, '17, 18:08

Thanks for reporting this. In v076 it nows gives an error message (in the debugger) rather than returning the mysterious NaN.

There's a special case for -1 raised to an integer power, which is sometimes used in math equations as a way to get alternating -1 and 1 values. Maybe that should be extended for any negative base raised to an integer power. It would need to be computed using repeated multiplication rather than logarithms. In general, raising a negative number to a non-integer power isn't a real number (e.g. -1 raised to 0.5, the square root of -1, is an imaginary number).

Hope that helps!

vickiS
Posts: 7
Joined: Oct 5th, '17, 16:26
Contact:

Re: Raised to block in operators category

Post by vickiS » Nov 19th, '17, 19:07

Thanks for responding John. I'm not much of a mathematician (or programmer either :) ). I tried out calculators to compare results and did some reading on line before I posted and people do seem confused about this. The only thing I really know about imaginary numbers is that they are used to compute mandelbrot and julia sets. I should say complex numbers but yeah, comprehension ends about there. Currently I am working through programming concepts using Rosetta Code tasks and GP Blocks and that's how I stumbled into this. Predictably I don't always fully understand the task or whether it even is applicable to GP Blocks but I am having a lot of fun doing it. I am a Squeak/Squeak Etoys fan and I am very enthused about what you and your team are doing with GP Blocks.

MrSteve
Posts: 61
Joined: Jun 16th, '16, 01:22

Re: Raised to block in operators category

Post by MrSteve » Nov 28th, '17, 05:42

@vickiIS Yeah for the Squeak/Etoys fans :)

Regarding raising to -1 perhaps Vi Hart could come up with a nice visualization, for now I'll settler for her video: https://youtu.be/WU3AlAOCxN0

Post Reply