Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
3774 views
ubuntu2004
1
def generator():
2
x = var("x")
3
4
# define possible factors
5
factors = [
6
x^randrange(2,10),
7
e^x,
8
cos(x),
9
sin(x),
10
log(x),
11
]
12
shuffle(factors)
13
f = choice([-1,1])*randrange(2,5)*factors[0]*factors[1]
14
15
variant = choice(["derivative", "rate of change"])
16
17
return {
18
"f": f,
19
"dfdx": f.diff(),
20
"d_synonym": variant,
21
}
22
23