<jupyter_start><jupyter_text>Differential eqn solving $\frac{dy}{dt} = -k*y$ k=0.2 y0=12<jupyter_code>import numpy as np      
from scipy.integrate import odeint   # for differential eqn solving
import matplotlib.pyplot as plt


def model(y,t):
    k=0.2
    y0=12
    dydt=-k*y
    return dydt
    
t=np.linspace(0,20,50)
y=odeint(model,y0,t)
plt.plot(y,t,'r',linewidth=2)
plt.xlabel('time')
plt.title('differential eqn graph')
plt.ylabel('y(t)')
plt.grid(True)
plt.show()
y=odeint(model,y0,t)
plt.plot(y,t,'r',linewidth=2)
plt.xlabel('time')
plt.title('differential eqn graph')
plt.ylabel('y(t)')
plt.grid(True)
plt.scatter(y,t)
plt.show()<jupyter_output><empty_output><jupyter_text>next ques.k=0.1,k=0.2,k=0.3<jupyter_code>def model(y,t,k):
    dydt=-k*y
    return dydt
y0=12 
t=np.linspace(0,20,50)
k=0.1
y1=odeint(model,y0,t,args=(k,))   #args=arguments
k=0.2
y2=odeint(model,y0,t,args=(k,))
k=0.3
y3=odeint(model,y0,t,args=(k,))
plt.plot(t,y1,'r',linewidth=2,label='k=0.1')
plt.plot(t,y2,'b',linewidth=2,label='k=0.2')
plt.plot(t,y3,'g',linewidth=2,label='k=0.3')
plt.title('comparative graphs')
plt.xlabel('time')
plt.ylabel('y(t)')
plt.legend()

plt.show()
print(y)


print(model(y,0.2,k))<jupyter_output>[[-3.6       ]
 [-3.31779766]
 [-3.05771698]
 [-2.81802387]
 [-2.59712029]
 [-2.39353318]
 [-2.20590519]
 [-2.03298527]
 [-1.87362047]
 [-1.72674821]
 [-1.59138924]
 [-1.46664091]
 [-1.35167159]
 [-1.24571466]
 [-1.14806364]
 [-1.05806745]
 [-0.97512601]
 [-0.89868632]
 [-0.8282387 ]
 [-0.76331344]
 [-0.70347763]
 [-0.64833233]
 [-0.59750985]
 [-0.55067131]
 [-0.50750443]
 [-0.46772138]
 [-0.43105691]
 [-0.39726655]
 [-0.366125  ]
 [-0.33742462]
 [-0.31097405]
 [-0.28659694]
 [-0.26413073]
 [-0.24342564]
 [-0.22434361]
 [-0.20675741]
 [-0.19054979]
 [-0.17561268]
 [-0.16184648]
 [-0.1491594 ]
 [-0.13746686]
 [-0.1266909 ]
 [-0.11675965]
 [-0.10760691]
 [-0.09917166]
 [-0.09139763]
 [-0.08423301]
 [-0.07763003]
 [-0.07154464]
 [-0.06593629]]<jupyter_text>Question$\frac{dy(t)}{dt} = -y(t) + 1$ y(o)= 0<jupyter_code>import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt
def model(y,t):
    dydt = -y + 1
    return dydt
y0=0
t=np.linspace(0,20,100)
y=odeint(model,y0,t)
plt.plot(t,y)
plt.xlabel('time')
plt.ylabel('y(t)')
plt.show()
def model(y,t):
    dydt = -y + 1
    return dydt
y0=0
t=np.linspace(0,5,25)
y=odeint(model,y0,t)
plt.plot(t,y)
plt.xlabel('time')
plt.ylabel('y(t)')
plt.grid(True)
plt.scatter(t,y)
plt.show()<jupyter_output><empty_output><jupyter_text>New Ques$\frac{dy}{dt} = k*y +3.0$ k = 0.8 y0 = 0.5 To solve this differential equation, let us consider a function as<jupyter_code>def model(y,t):
    dydt=k*y+3.0
    return dydt
y0=0.5 

t=np.linspace(0,20,100)
k=0.8
y=odeint(model,y0,t)
plt.plot(t,y)
plt.xlabel('time')
plt.ylabel('y(t)')
plt.grid(True)
plt.show()<jupyter_output><empty_output><jupyter_text>New Ques$\frac{dy}{dt} = -k*y +3.0$ k=0.8 y0=1.1<jupyter_code>def model(y,t):
    dydt=-k*y+3.0
    return dydt
y0=1.1

t=np.linspace(0,20,100)
k=0.8
y=odeint(model,y0,t)
plt.plot(t,y)
plt.xlabel('time')
plt.ylabel('y(t)')
plt.grid(True)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22636737274739172, 'fraction_numerical': 0.17673095162820107, 'mean_word_length': 4.670250896057348, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '518449', 'license': 'MIT', 'n_tokens_mistral': 1923, 'n_tokens_neox': 1630, 'n_words': 217, 'path': 'Diff.eqn solving & plot.ipynb', 'repo_name': 'Daya-Ram/Differential-eqn-solving', 'size': '3163'}