Ask Your Question

Wojowu's profile - activity

2019-10-04 21:26:32 -0500 received badge  Famous Question (source)
2019-04-08 09:41:26 -0500 received badge  Notable Question (source)
2018-12-23 04:43:54 -0500 received badge  Notable Question (source)
2018-10-31 05:22:35 -0500 received badge  Popular Question (source)
2017-04-01 12:08:00 -0500 received badge  Popular Question (source)
2016-11-11 15:42:55 -0500 received badge  Supporter (source)
2016-11-04 09:12:14 -0500 commented question Speeding up power_mod

@Mafra Thank you for your replies! I have tested and compared a few methods of computing modular powers. Apart from SageMath's power_mod, I have tried Python's pow, GMP's .powermod and SageMath's modular integer rings. The latter three have noticably outperformed power_mod, but all of them gave improvements of order of 30%, as opposed to 70% provided by Julia (tested using JuliaBox if that makes any difference) (to be precise: 63 seconds for power_mod, ~45s for other three, and 18.5s for Julia). By the way, do you think it makes any difference that I am using SageMathCloud as opposed to having it downloaded? I can't test right now because I don't have Sage on the machine I'm using now.

2016-11-01 08:13:15 -0500 received badge  Nice Question (source)
2016-10-31 03:45:54 -0500 received badge  Student (source)
2016-10-28 15:00:30 -0500 asked a question Speeding up power_mod

Recently I've been working a bit with modular arithmetic and big numbers. An incredibly useful tool for that is modular exponentiation by repeated squaring, implemented using power_mod function. Earlier I was using Julia for that (together with BigInt there), and I was quite disappointed to find out that in Sage modular exponentiation is noticably slower for (very) large moduli - slowdown by a factor of 3 modulo 10^5000 and by a factor of almost 10 modulo 10^50000 (I didn't test larger ones). I don't know if the reason for this is that Julia uses some faster modular exponentiation algorithm (I didn't manage to find how it is implemented), or whether it is because the BigInt makes it that significantly easier for CPU to work with these.

So my question is, is there some way to speed up the modular exponentiation in Sage?

2016-10-02 03:34:09 -0500 commented answer Plotting point when coordinate involves symbolic and numerical values

Hello, sorry for a late reply, I was away from home. I am using SageMathCloud, and I'm not sure what version it's running (my guess is 7.3, latest stable). I also have version 7.2 downloaded on a Windows machine, but I didn't try running the code there, and I don't know where I could download beta versions. Anyways, using RDF fixed the problem, so I am willing to accept this answer.

2016-09-25 13:21:03 -0500 asked a question Plotting point when coordinate involves symbolic and numerical values

Consider the following single piece of code:

point([real_part(zeta(I))+1,0])

When trying to compile it, I get the following error message:

Error in lines 1-1
Traceback (most recent call last):
  File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 957, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "", line 1, in <module>
  File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/plot/point.py", line 353, in point
    return point3d(points, **kwds)
  File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.py", line 1143, in point3d
    A = sum([Point(z, size, **kwds) for z in v])
  File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.py", line 720, in __init__
    self.loc = (float(center[0]), float(center[1]), float(center[2]))
TypeError: 'sage.symbolic.expression.Expression' object does not support indexing

Is there some simple way to fix this?

Interesting note: I have played around with this error, and it is very unclear to me when it does or doesn't appear. Here are some examples of when the error does appear (as far as I've checked, the traceback is always the same):

point([real_part(zeta(I))+1,0])
point([real_part(zeta(I))*2,0])
point([real_part(zeta(I))+real_part(zeta(I)),0])
point([real_part(zeta(I))/2,0])
point([real_part(zeta(I))-real_part(zeta(2*I)),0])

Here are some examples where it doesn't appear:

point([real_part(zeta(I))+0,0])
point([real_part(zeta(I))*1,0])
point([real_part(zeta(I))*real_part(zeta(I)),0])
point([real_part(zeta(I))+real_part(zeta(2*I)),0])
point([real_part(zeta(I))+imag_part(zeta(I)),0])

(edit: the error doesn't seem to ever occur if we give the zeta function a real argument)

I'd be interested if someone figured out under what conditions the error appears or not, because I fail to see any pattern. Thank you in advance.

2016-09-21 16:05:06 -0500 commented answer Errors when plotting zeta function parametrically

Thank you very much! I am relatively new to both Python and Sage, so any help is appreciated.

2016-09-21 16:04:54 -0500 commented answer Errors when plotting zeta function parametrically

Thank you very much! I am relatively new to both Python and Sage, so any help is appreciated. By the way (although this isn't strictly relate to my overall question), do you know of a way to make the the plot non-monochromatic? I am thinking of making the hue of the line changing as x increases, so that the plot looks rainbow-y.

2016-09-21 16:04:20 -0500 received badge  Scholar (source)
2016-09-21 10:45:33 -0500 received badge  Editor (source)
2016-09-21 10:29:13 -0500 received badge  Organizer (source)
2016-09-21 10:04:03 -0500 asked a question Errors when plotting zeta function parametrically

I have the following piece of code:

def f(x):
    return(real_part(zeta(1+x*I)).n())
def g(x):
    return(imag_part(zeta(1+x*I)).n())
parametric_plot([f(x),g(x)], (x,2,10))

It should be moderately clear what I'm trying to do - I want to produce a plot of Riemann zeta function on the line Re(z)=1 using parametric plotting. However, when I try to plot this, I get an error TypeError: cannot evaluate symbolic expression numerically. I also tried the same thing without the .n(), but then I get an error TypeError: unable to coerce to a real number. I couldn't find any help online.

It's worth noting that trying to plot function f(x) I get the same error with .n(), but it works just fine without it (as opposed to parametric plot). Does anyone have an idea how to fix the issue?

Thanks in advance.