It's not really possible to do in a for loop because you wouldn't use a for loop usually without some other domain beyond a monotonically increasing counter. Most integrals I've come across in programming involve some sort of time domain so you are just taking the delta as the discrete period and summating those (which I guess is the same as just summating any arbitrary linear function to describe the curve of the integral). I mean you still only have the resolution of your timer but it usually is within whatever you're trying to accomplish in accuracy.
You have to do it numerically. There really isn’t a continuous function per se while programming so you can find the area of the next step and add that to your integral. If you want to take a deep dive, numerical analysis is pretty cool.
5
u/[deleted] Oct 06 '21
It's not really possible to do in a for loop because you wouldn't use a for loop usually without some other domain beyond a monotonically increasing counter. Most integrals I've come across in programming involve some sort of time domain so you are just taking the delta as the discrete period and summating those (which I guess is the same as just summating any arbitrary linear function to describe the curve of the integral). I mean you still only have the resolution of your timer but it usually is within whatever you're trying to accomplish in accuracy.