Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Explore the roll function from numpy. First, get set up import numpy as np a

ID: 3705317 • Letter: 1

Question

1. Explore the roll function from numpy. First, get set up import numpy as np a =np . array ( [ [1,2,3],[4,5,6],[7,8,9]], float ) Then, answer this: What do each of the following return? 1.np.roll (a, 1, axis-0) 2. np.roll(a, 1, axis-1) 3. np.roll(a, 1, axis-o) 4. np.roll(a, 1, axis-l) 2. You have a 2D array of potentials called phi. Write the new potential, phiNew, in terms of the old potential, phi, using the appropriate calls to In other words,fl-in the missing bits phiNew .25 *(np.roll(phi, ?) +np.roll (phi, ) + np.roll(phi, ) + np.roll(phi, 22?)) 3. Write the commands that you need to set to boundary values for the array phiNew to the values in Part 1 below

Explanation / Answer

If you understood the anwer to question one, 2 should be pretty easy.

make a 2d array phi

phi = np.array([[1,2,3],[4,5,6],[7,8,9]],float)

You get a new 2d array phinew.