[Tutor] fixed quad

Peter Otten __peter__ at web.de
Sat Jul 24 03:52:12 EDT 2021


On 24/07/2021 08:31, Msd De wrote:
>   I have nested integrals and need to use a fixed quad to carry out the
> integration
> Below is my code. Not sure of whether use of lambda function is appropriate
> need help with regards to use of lambda function.
> Thank you

> *for i in range(64): *
>       *JRuss11[i]=integrate.fixed_quad(lambda Ex: DEx11(Ex),ELOW, EHIGH,
> n=64)*
>       array_JRuss11[int(i)]=(JRuss11[i][0])

I'm sorry. I can't help you with the actual task. However, the lambda 
above is superfluous. Consider the simple analog


do_stuff(lambda x: f(x))

If you rewrite it with a "normal" function this becomes

def g(x):
     return f(x)

do_stuff(g)

and it should be easy to see that g() wraps f() without doing any extra 
work; so you better write

do_stuff(f)

directly, or in your case

fixed_quad(DEx11, ...)



More information about the Tutor mailing list