File:Mobiusplot,on0to100.png

From specialfunctionswiki
Jump to: navigation, search
Original file(861 × 876 pixels, file size: 11 KB, MIME type: image/png)
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
from mpmath import *
from pylab import rcParams
rcParams['figure.figsize'] = 10, 10

def numberOfFactors(n):
        counter = 0
        while (n > 1):
                i=2
                while (i <= n):
                        if(n%i ==0):
                                n /= i
                                counter += 1
                                break
                        i += 1
        return counter

def isDivisibleBySquare(n):
        i=2
        while(i**2 <= n):
                if (n%(i**2)==0):
                        return 1
                i += 1
        return 0

def isValid(n):
        if (n <= 0):
                return 0
        elif (n-int(n) != 0):
                return 0
        return 1

def mobius(n):
        if not isValid(n):
                return 0
        elif (n==1):
                return 1
        elif(isDivisibleBySquare(n)):
                return 0
        else:
                return (-1)**numberOfFactors(n)
fig, ax = plt.subplots()

x=np.arange(0,100,1)
f=np.vectorize(mobius)
y=f(x)

plt.xlabel(r'$n$')
plt.ylabel(r'$\mu(n)$')

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current09:43, 16 June 2016Thumbnail for version as of 09:43, 16 June 2016861 × 876 (11 KB)Tom (talk | contribs)Category:Plot <pre>#!/usr/bin/python import numpy as np import matplotlib.pyplot as plt from mpmath import * from pylab import rcParams rcParams['figure.figsize'] = 10, 10 def numberOfFactors(n): counter = 0 while (n > 1):...
  • You cannot overwrite this file.

The following page links to this file:

Metadata