Question: This is my code for Euler's method: change(N)=0.2*N*(1-(N/100)) count = srange(0,1000) vals = [150] step_size = 0.1 for i in count: current_value=vals[i] future_value=current_value+step_size*change(current_value) vals.append(future_value) vals

This is my code for Euler's method:

change(N)=0.2*N*(1-(N/100))

count = srange(0,1000)

vals = [150]

step_size = 0.1

for i in count:

current_value=vals[i]

future_value=current_value+step_size*change(current_value)

vals.append(future_value)

vals

Questions:

  1. Turn your implementation of Euler's method into a function. This function should take a differential equation (see the previous paragraph), an initial value, a step size, and the number of steps as inputs. It should return a list of state values as its output.
  2. Modify this function so it returns a list of pairs of time and state values.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!