Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Views: 1794
Image: ubuntu2004
1
def generator():
2
t = var("t")
3
y, yp = mi_vars("y", "y'")
4
5
# pick a for y'-ay
6
a = randrange(1,6)*choice([-1,1])
7
8
# particular solution
9
b=a
10
while (b==a):
11
b = randrange(1,6)*choice([-1,1])
12
c = choice([-3,-2,2,3])
13
part_sol = choice([
14
c*exp(b*t),
15
c*exp(a*t)*t,
16
c*exp(a*t)*sin(b*t),
17
c*exp(a*t)*cos(b*t)
18
])
19
d = choice([-1,1])*randrange(1,5)
20
ode = shuffled_equation(yp,-a*y,-part_sol.diff()+a*part_sol)*d
21
k = var("k")
22
ode_sol = (y==k*exp(a*t)+part_sol)
23
24
return {
25
"ode": ode,
26
"ode_sol": ode_sol
27
}
28
29