Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
- 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.
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started