Unsupported operand type(s) for *: 'function' and 'function' with lambda function

323 views Asked by At

I know that I can multiply two lambda functions and get a lambda function like following:

f1 = lambda x: x+2
f2 = lambda x: x+3
f = lambda x: f1*f2 
 # f = (x+2)*(x+3) = x**2 + 5*x + 6

I'm getting a TypeError for the following line:

 integ = lambda x:(low_vib_wfxn)*(up_vib_wfxn)

and both (low_vib_wfxn) and (up_vib_wfxn) are lambda functions:

low_vib_wfxn = lambda x:(low_norm_const) * (H_list[0]) * (math.exp((-low_aplpha)*(x^2)*(1/2)))

A = lambda x: (norm_up_vib_wfxn_list[k]) * (H_list[k])

up_vib_wfxn = lambda x: A * (math.exp((-up_aplpha)*(x**2)*(1/2)))

H_list is the list of polynomial whose argument is x.

Could someone explain why I get the TypeError and how I fix this?

1

There are 1 answers

0
Finrod Felagund On BEST ANSWER

Probably what you are looking for is:

f = lambda x: f1(x) * f2(x)