$\begingroup$ Show I want to plot a numerical integral function of some function $f$ using I tried the following but it didn't work (run with
I also tried to vectorize the function
nicoguaro♦ 8,1295 gold badges21 silver badges47 bronze badges asked Jan 20, 2016 at 15:06
$\endgroup$ $\begingroup$ First of all, your function $x\sin(\frac{1}{x})$ is singular in $x=0$. You might want to add an
but this does hurt speed (masked arrays would be better). The reason why your code doesn't work is because
This code works:
answered Jan 20, 2016 at 19:35
GertVdEGertVdE 6,0911 gold badge19 silver badges36 bronze badges $\endgroup$ 3 $\begingroup$ Replace the last line by
That should do it. Edit: you can define your function F as
answered Jan 20, 2016 at 18:53
$\endgroup$ 1 $\begingroup$
answered Jan 17, 2021 at 8:40
$\endgroup$ $\begingroup$ If you insist on using
answered Jan 17, 2021 at 13:44
Lutz LehmannLutz Lehmann 3,7111 gold badge12 silver badges17 bronze badges $\endgroup$ How do you import a plot in Python?Import matplotlib.. Set the figure size and adjust the padding between and around the subplots.. Create random data points, x.. Plot x using plot() method.. To display the figure, use show() method.. Can Python do integrals?find the integral of a function f(x) from a to b i.e. In python we use numerical quadrature to achieve this with the scipy. integrate.
How do you integrate two arrays in Python?Use numpy. concatenate() to merge the content of two or multiple arrays into a single array. This function takes several arguments along with the NumPy arrays to concatenate and returns a Numpy array ndarray. Note that this method also takes axis as another argument, when not specified it defaults to 0.
|