here is my main multiply function:

def multiply_optimized(poly1, poly2):

m,n = len(poly1),len(poly2)

if m ==1:

return [poly1[0]*poly2[i] for i in range(n)]

elif n == 1:

return [poly2[0]*poly1[i] for i in range(m)]

else:

n = max(m,n)

a,b = split(poly1, poly2)

a0,a1,b0,b1 = a[0],a[1],b[0],b[1]

u = multiply_optimized(a0,b0)

z = multiply_optimized(a1,b1)

y = multiply_optimized(add(a0,a1), add(b0,b1))

x = minus(minus(y, u),z)

pro = add(add(u, increase_exponent(x, n//2)), increase_exponent(z,n))

return pro

and i have written another function to subtract 2 polynomials that is:

def minus(poly1, poly2):

“”“Add two polynomials”""

result = [0] * max(len(poly1), len(poly2))

for i in range(len(result)):

if i > len(poly2)-1:

result[i] = poly1[i] - result[i]

else:

result[i] = poly1[i]-poly2[i]

return result

on giving the poly1 = [1,1] poly2 = [1,1] inputs the function gives [1, 4, 1] output.

can you tell me where i have done the mistake in the function? thanks.