[Python] How to integrate a function for multiple upper limits using Python?

Discussão em 'Python' iniciado por Stack, Abril 21, 2025.

  1. Stack

    Stack Membro Participativo

    Suppose I have an integrand, and I want to integrate the function using various upper limits. In my code, I have the upper limit as 1. But I want to evaluate the integral using 1, 2, 4, 6. How do I do that? Do I use the map function? I've tried setting the upper limit as an array but I get all kinds of errors. This is my code using only 1. Any help is appreciated.

    from scipy.integrate import quad
    def integrand(x, a, b):
    return a*x**2 + b

    a = 2
    b = 1
    I = quad(integrand, 0, 1, args=(a,b))

    Continue reading...

Compartilhe esta Página