i have this question
Write a python code to solve the following initial value problem ordinary differential equation using Euler method over the interval (0 10) with 10 time steps. A) y'= -y -y^2 ; y(0)=1 If that exact solution was y(t) = 1/(-1+2e^t) What is the absolute error at y(10). now i have write this code
def pow_t(x,b):
t=1;
while (b):
t*=x
b=b-1
return t
def absolute():
y=[x for x in range(1,11)]
h=0.0001
for i in range(1,10) :
y[i]=y[i-1]+(h*(-1*y[i-1]-pow_t(y[i-1],2)))
print("y",i,"=",y[i])
exact = 0.0000227
approx = y[9]
absolute = exact - approx
print("abbsolute erroe = exact - approx ")
print("abbsolute erroe = ",absolute)
print(absolute())
and this is the actual result that I get
i need to set the first index of y list to 1 then fill the rest of list by the for loop, how can i code this?