Integration, Symbolic and Numeric with Python

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Good video, just not what I was hoping for
Just in case anyone was hoping this video would be about numeric integration in python, not importing scripts in python, here's an actual numeric code:
# example function
def func(x):
y = 1
y = (x*x*x) - (2*(x*x)) + x - 3
return y

# Integrate function
def integrate(start, end, step):
result = 1
index = start
while(index <= end):
result = result + func(index)
index = index + step
result = result * step
return result

def main():
print(integrate(-2, 2, 0.001))

main()

xx
Автор

Very helpful, articulated and practical examples just in very low time. Thanks

hamedjabarian
Автор

Wow. My Python Professor needs to take lessons from you. Seriously. I've spent weeks studying from her and it's a bunch of guessing and anticipating and not clearly explained as this. My grant payers should get a refund.

matrixate
Автор

Thanks so much! Right to the point and practical!

gillespieQMA
Автор

thanks for this
could you touch upon the difference between using quad and trapzd for integration?

noobmaster-dmtu
Автор

Hi thats a great video.Could you please tell if there are double integrals and dx, dy, how to deal with that in python?

kiranshakeel
Автор

Can you integrate with Python to find volume?

Vathananable
Автор

Top video! Is Matlab good in solving the more complex integrals?

johanmoens
Автор

This is great. May I ask a query. When we use sympy for analytical solution for an integration, sometimes the output seem to be a piecewise datatype. May I know how to resolve this?
Example:
from sympy import *
x=Symbol('x')
alpha=Symbol('alpha')
beta=Symbol('beta')
W=Symbol('W')
f1=(alpha-beta)
result1=integrate(f1, (x, 0, x))
f2=alpha*exp(-result1)
result2=integrate(f2, (x, 0, W))
M=1/(1-result2)
print(M)
Output: 1/(1 - Piecewise((alpha/(alpha - beta) - alpha*exp(-W*(alpha - beta))/(alpha - beta), Ne(alpha - beta, 0)), (W*alpha, True)))

sriharshakodati
Автор

Hi great video, short and crisp. thanks. I have another question, if you would help will be great. If I have x & y column data, can you tell how can I integrate them [with y = int f(x) ]?
thanks
A M

ayanmitra
Автор

I'm not a coder person. I need to output a bunch of anti derivatives as training data. I can't afford mathematica, so Im using jupytor with python 3 in my browser. I havent found a way to get wolfram alpha to output lists of antiderivatives like I want. My code only outputs one integral at a time. I thought maybe doing like a print(sp.integrate(x*sin(x**2), x), but I don't like its non-nice form. How can I get it to output a list of antideriviatives? My code:
import sympy as sp
from sympy import sin, cos, exp, log, simplify
x = sp.Symbol('x')
sp.integrate(x*sin(x**2), x)
sp.integrate(x, x)
The problem is that in the output, you can only see the last integral. So I try to do a print thing and then the outputs are no longer user friendly.
import sympy as sp
from sympy import sin, cos, exp, log, simplify
x = sp.Symbol('x')
print(sp.integrate(x*sin(x**2), x)
, sp.integrate(x, x))
I'll prolly figure it out before you get back to me, but figure Id put out a feeler.

rookitchen
Автор

It's pretty helpful, Thank you. Is it possible to integrate a function with a singularity and get a result consisting of the real and imaginary parts?

kuncheng
Автор

Hi nice video, but what about if I have a function to be integrated that has variable coefficient: f(w, t) = b(w)*cos(w*t).
b(w) comes from a data base and let's say w(0, 5, 0.05) and we want F(t) = int f(w, t)) dw?

francescodallevedove
Автор

DEEPLY DISAPPOINTED WITH THIS PACKAGE. IT CAN'T INTEGRATE A FUNCTION THAT MATHEMATICA INTEGRATES BETTER AND FASTER. I TRIED IT THINKING IT WOULD BE A STEP UP FROM MATHEMATICA, BUT IT'S NOT SO.
*Here the code.*

q=3/2
n=2

def f(u):
return

exp = quad(f, 0, 1)

*Am I doing something wrong?*

ThomasJr
Автор

Thank you. Please magnify the screen a bit.

hamzaa.
Автор

Hi,
Very well demonstrated. Thanks for the examples.
I had a question with complex integrations. Is it impossible to derive symbolic expressions of integral like x/(1+0.000015x^2)? I keep getting the error "no convergence : try value of n<30 and maxsteps > 50. I tried changing these values too but no luck. Kindly, guide where I am wrong .

rohanarya
Автор

Thank you so much this was extremely helpful!!

kedwards
Автор

how i can make global assumption assume(x>3) so when i tape abs(x-3) i get x-3 and thxs

allaniamed
Автор

Hi ApMonitor.com. Let's me start to give you thanks for the so wonderful explications regarding analytical and numerical way to solve integration using Python code. However I want just to mention one thing about the famous exercise to gave us to solve . (integral of exp^(-x)sin(3x)dx. For the analytical part you found zero as answer for that integration something I didn't understood, I tried it myself I got the answer which is different to zero. I was wondering why did we not get the same answer? Have you some reason for that? Thanks a lot .

NZIT
Автор

i am failing to apply integration help me f (x) = 20 e -20(x-12.5),
limits (12.6 to infinity), (12.5 to 12.6) i want python code
i tried d=12.6
sp.integrate(sp.exp(-20*(d-12.5)), y)
output:0.135335283236614𝑦

yellowsmash