 Beginner - 4 years ago 194
Python Question

# Integrating a function to get a function

I have a function which takes a dictionary and returns an acceleration

`a`
.

I put a list of data for a certain parameter (lets call it
`alpha`
) in that dictionary, and the function returned an array of 100 results(in respect to alpha).

Now I want to integrate these values one by one, to get let's say an array velocity
`v`
in respect to the parameter
`alpha`
( so that i can plot these values in matplotlib).

Edit:

Actually i have a mechanical problem. The ladder is placed against the wall, and because its
`friction coefficient`
is too small it's starts sliding.
So i have written a function which returns the
`acceleration`
`angle between 30° and 90°`
(30 is the starting angle, and 90 is when the ladder is on the ground).

Anyways, I've calculated
`acceleration`
in respect to the angle
`alpha`
. I have the data stored in array
`a`
.
I tried
`scipy.integrate.simps()`
but that method returns the final velocity
`v`
. I've also tried
`scipy.integrate.quad()`
but returns the same result.

I would like to generate an array of velocities
`v`
which will contain a value for every angle, like in array of accelerations -
`a` Anonymous
It sounds like you want to perform cumulative quadrature on an array of values. In that case, `scipy.integrate.cumtrapz` should do want you want. That will perform a cumulative integration using the trapezoidal rule on the supplied array, yielding an array of outputs the same size in the inputs. You control in initial value via a separate argument if it is non-zero.