Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def run_benchmark(n):
a0 = symbols("a0")
a1 = symbols("a1")
e = a0 + a1
f = 0;
for i in range(2, n):
s = symbols("a%s" % i)
e = e + sin(s)
f = f + sin(s)
f = -f
t1 = clock()
e = expand(e**2)
e = e.xreplace({a0: f})
e = expand(e)
t2 = clock()
print("%s ms" % (1000 * (t2 - t1)))
def run_benchmark(n):
a0 = symbols("a0")
a1 = symbols("a1")
e = a0 + a1
f = 0;
for i in range(2, n):
s = symbols("a%s" % i)
e = e + sin(s)
f = f + sin(s)
f = -f
t1 = clock()
e = expand(e**2)
e = e.xreplace({a0: f})
e = expand(e)
t2 = clock()
print("%s ms" % (1000 * (t2 - t1)))