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

Finding Neighbors in an Array The figure below shows an array of integers, f, wi

ID: 3820251 • Letter: F

Question

Finding Neighbors in an Array The figure below shows an array of integers, f, with the indices of the array on the top row, and the values on the bottom row: index: 0 1 2 3 4 value: 18 19 23 45 7 Notice that each entry in the array has two neighbors (except the first and last). Element f[i] has neighbors f[i-1] and f[i+1]. We can also think of an array of numbers as a discretely sampled function, so that the value of the function at n, f(n) is equal to the value of the array at index n, f[n]. Given this, we can approximate the derivative of this function using "finite differences". Recall that the definition of a derivative is f'(n) = lim_h rightarrow 0 (f(n+h) - f(n-h))/2h For a discrete difference, we drop the limit and simply get one of the following: f'(n) approx f(n+1) - f(n) forward difference f'(n) approx f(n) - f(n-1) backward differences f'(n) approx f(n+1) - f(n-1) central difference We can approximate the second derivative (also called the Laplacian) by subtracting the backward difference from the forward difference, which gives us f"(n) approx f (n-1) - 2f(n) + f (n+1) Using the values of the f array given at the top of this section, compute the values of f"(1), f"(2) and f"(3), and write them in your answer file.

Explanation / Answer

f(1)=19
f(1-1)=f(0)=18
f(1+1)=f(2)=23
f''(1)=f(0)-2*f(1)+f(2)=18-2*19+23=3

f(2)=23
f(2-1)=f(1)=19
f(2+1)=f(3)=45
f''(2)=f(1)-2*f(2)+f(3)=19-2*23+45=18

f(3)=45
f(3-1)=f(2)=23
f(3+1)=f(4)=7
f''(3)=f(2)-2*f(3)+f(4)=23-2*45+7=-60

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote