Hence my use of $x*$x rather than $x**2. I doubt there's much difference on modern processors.
Oh yes it does make a difference. $x*$x does a multiplication of two numbers, while $x**2 goes the long route of exp(log($x)*2), as ** is a very generic power raising operator. Not only will it take longer (maybe negligible these days, like you say), but most of all: its result will be less precise: both log and exp have quite large margins of error.
| [reply] [d/l] [select] |
hi,
Your ideea is very nice,I thought about it
so if we take $d=2 then the radius which in this case is $d/2=1
so now we can have the formula ($x-1)**2 + ($y-1)**2 <= 1
exactly as you write in your comment.
About the difference between $x*$x and $x**2,what optimisations do you think could be
made ?
| [reply] [d/l] |
Rate original multiply powers
original 0.405/s -- -72% -76%
multiply 1.45/s 257% -- -14%
powers 1.69/s 317% 17% --
| [reply] [d/l] [select] |
Further optimization is of little value in terms of convergence. The problem is in the random-walk nature of the convergence. While the quotient is guaranteed to eventually converge, over a given interval the quotient can diverge. While convergence is guaranteed the time over which it converges is not guaranteed.
s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s
|-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,,
$|=1,select$,,$,,$,,1e-1;print;redo}
| [reply] [d/l] |