Learn to Code via Tutorials on Repl.it!

← Back to all posts
##### The Riemann Sum!

Let's talk about the Riemann Sum!!

Okay, so the Riemann Sum does the same thing that an integral does, as it is essentially measuring the area under a curve! What this means for 𝛑, is that you can measure the area (well, approximate the are) of a semicircle, multiply it by 2 to get the area of a circle, and divide by r**2, to solve for an approximate value of 𝛑!

To imagine the Riemann Sum properly, think of a semicircle, with both ends touching the x axis. Now, imagine this:

This is a good visualization of integration (or more specifically, the Riemann Sum), but what is actually going on?

Well, there are two ways to explain this: The Calculus way, or the Summation way.

First off, the Calculus method is fairly concise and easy to read, but does not really help all that much:

Cool, right? (Note from after I took that photo, the integration is not approximately the area, it is exactly the area.)

Now, the Summation way (aka the Riemann Sum) makes all this so much clearer!

(In case you do not know how to read this one, it is basically saying that, as n → ∞, it sums all of the areas of all n rectangles that fit under the curve.)

Note that, when plugged into a calculator, you can say:

Please let me know if you have any further questions!!!
^ ^*

Oh, also, please pardon my poor penmanship.. T ~ T I have not written English too much lately. (Lol)

hotnewtop
CodingCactus (4188)

@LizFoster, how is Pokemon violet going btw?

LizFoster (648)

@CodingCactus Oh, thank you for asking! Quite well, actually. I'm making steady progress on the sprites, I may be able to (if I work a lot on it) finish the first 30 to 40 sprite sets by next week! ^~^*

AmazingMech2418 (1039)

@LizFoster Wow! That's a lot faster than it was when you were doing it by hand...

LizFoster (648)

@AmazingMech2418 Sorry for the really late response, I haven't been on here as much unfortunately... It is going pretty well, since I started using the IDLE Python program. I can now use multiple files, turtle, AND properly use the sprite converter you made! I've started work on the most important parts though, including:

• Type effectiveness system
• Proper damage calculation
• Bag system (I have just barely started this, though.)
• Turn system for battle, and status effects that affect the
initiative order

Got any ideas on ways I could do these easily? Thanks ^ ^*

AmazingMech2418 (1039)

@LizFoster I'm not sure exactly what you mean by each of those. (sorry, but I've never played a Pokemon game before) Could you explain what you mean?

LizFoster (648)

@AmazingMech2418 Okay, so:

• In Pokemon, each different pokemon has one or two types (so
Grass, Fire, Water, etc). Some types are super effective
against others, and vice versa.
• All this means is a way to calculate how much damage a move
would do to the enemy, that is accurate.
• The bag is just the player's inventory.
• I mean a turn-based fighting style like there is in Pokemon.
There are some status effects that affect the order in which
the pokemon make their moves.

So sorry, does this help at all? o~o

AmazingMech2418 (1039)

@LizFoster Well, for the type effectiveness part, you could probably just use a list or dictionary with values for the effectiveness and use those values to determine the damage per attack (or whatever is needed in Pokemon. I'm not really sure).

For the "bag" or inventory, you should be able to do a dictionary with all of the different items and their quantities and, when an object is picked up, increase the quantity by 1, and when an object is used/discarded, decrease it by 1. If there is a finite size, you could do that you can't pick up an object if the sum of all of the quantities is greater than a certain value, or the sum of the products of the quantities and a separate variable to determine the amount of space it would take up.

Then, for the turn-based fighting system, I'm still not completely sure what you need help with (the AI, the player, the overall UI?).

I hope this helps!

LizFoster (648)

@AmazingMech2418 This certainly does help! Thank you! For the turn-based fighting, I was referring more specifically to the AI.

AmazingMech2418 (1039)

@LizFoster For the AI, I guess you could just use a system to evaluate all possible moves and use a pseudorandom number generator to choose the move?

LizFoster (648)

@AmazingMech2418 Hm, good idea. THe only problem now is, how am I supposed to find what every trainer's pokemon are? I don't have a copy of the games, so this might prove a bit more challenging than the more simple stuff, such as trainer AI, or a list of all of the items (and their functions).. T~T

LizFoster (648)

@AmazingMech2418 Also on a high note, I've finished plugging in all of the front sprites for all of the pokemon! Now I just have to delete the old and unnecessary files, and do the same for all of the back sprites. Hooray! :D

AmazingMech2418 (1039)

@LizFoster Nice! Though, what do you mean by "what every trainer's pokemon are"?

LizFoster (648)

@AmazingMech2418 Well, along the way on your journey in the game, you run into a bunch of NPCs, or trainers as they are called. They all have teams of their own pokemon.

AmazingMech2418 (1039)

@LizFoster Okay. So, you don't know what pokemon are in each team? Maybe, you could randomize it or something? I don't know.

LizFoster (648)

@AmazingMech2418 That could make for a rather interesting game, actually! (Lol) Although, another tactic comes to mind. I could watch a few play-throughs of the game, as well as look through the Pokemon wikis. Those might help for the major trainers, and for the minor ones, I could probably just randomize them based on the surrounding available pokemon...?

LizFoster (648)

@AmazingMech2418 Sweet! Also, I just found a page that lists how stats are calculated!

bgrubert (189)

You should do the Riemann hypothesis next in python with turtle

LizFoster (648)

@bgrubert Ooh, that's fun! I'll see what I can do, though it may take a bit, as I am busy with ポケットモンスターwwwwwwwww

LizFoster (648)

@bgrubert If you're referring to ζ(2), I've already done the Basel Problem.

bgrubert (189)

@LizFoster Not the Basel problem, but the analytic continuation of the zeta function - I find it looks really cool

LizFoster (648)

@bgrubert Oh, of course. Yes, it does!

LiamDonohue (291)

im online if you want to work on the math functions for the programming language

SixBeeps (5060)

Wow, very interesting!
The summation formula It kinda looks like the distance formula.

LizFoster (648)

@SixBeeps Good point! However, if you look more specifically at the formula for a semicircle, you'll see the striking similarity even clearer!

CodingCactus (4188)

@LizFoster lol, this is your learn post ;)

luffy223 (6)

I wow I am amused in all of the intrest on rymen sum what if you proximate it using tylor serise what will happen

DynamicSquid (4622)

I love the tutorial! Expect I didn't understand a thing... I'm trying to learn higher levels of calculus (like integrals and all that), and I even have a book on it, but... eh, I don't wanna do Math lol

LizFoster (648)

@DynamicSquid Well, if you have questions, I would gladly answer them! Calculus can be super cool and fun.

luffy223 (6)

if you wana see calculas visualy see three blue one brown chanal https://youtu.be/WUvTyaaNkzM @DynamicSquid

LizFoster (648)

@luffy223 I never got around to putting it in, but I meant to post his "Essence of Calculus" Series as a link on the post (Lol)

luffy223 (6)

the best chanal for math seekeris i am affriad of being involved of his diffrential calculas [email protected]

luffy223 (6)

numberphile is a good one [email protected]

LizFoster (648)

@luffy223 True, that channel has lots of good stuff on it
^__ ^*

luffy223 (6)

philosphy math and physics are my [email protected]

LizFoster (648)

@luffy223 I can tell! (Lol)

(Same here #_ _# )

What would the value of f^(n)(a) be? I am slightly puzzled as to how I would code that..

DynamicSquid (4622)

@LizFoster I have a quick question, where did you learn calculus?

LizFoster (648)

@DynamicSquid Since my school has yet to teach me, I had to learn it on my own time. T~T

I first really discovered and enjoyed the idea of calculus and integrals and all that stuff when I came across the graph of the equation e^x. It fascinated me that the area under any given x of this equation, is the equation!

I learned the bulk of it through video explanations and through the ever-helpful Mathematics Stack Exchange. If you'd like, I can supply you with some handy channels on YouTube for understanding the basics. ^__ ^

(Although, odds are, you probably know Calculus already _ _)

DynamicSquid (4622)

@LizFoster Well i just know the basics of it like limits and derivatives. Any links for the more advanced stuff?

LizFoster (648)

@DynamicSquid I would highly recommend one of my favorites:
blackpenredpen.
There is also James Cook, but I do not really like that he insists on beginning every lecture with a prayer (of course, that is just me, he is alright at explaining things otherwise).

luffy223 (6)

are you asking f to the power (n*a) [email protected]

LizFoster (648)

@luffy223 No, the Wikipedia page says that a Taylor series can be written in Sigma Notation, like so:

LizFoster (648)

@DynamicSquid Oh, and for blackpenredpen, obviously not all of his videos are Calculus-themed, but he probably has a playlist of them.

luffy223 (6)

as for learning culculas i highly recomend CALCULUS, FOURTH EDITION by robert smith and roland for all bacics of calculas untill second order diddrential equstion
if any one need it i have it it is from where i am studing from now @LizFoster

luffy223 (6)

I relly do not know but certinly you should try finding a code to find higher drivtion at first for any [email protected]

DynamicSquid (4622)

@LizFoster Cool! I'll definitely check them out. Thanks!

LizFoster (648)

@DynamicSquid No problem! As always, if you have any questions, I'd happily help you out!

LiamDonohue (291)

i am wowed again. now please try to get some sleep lol

BlueComet (116)

The 𝛑 master back at it again with a better than ever project!
(Your pretty much the only 𝛑 coder I know in repl)

BlueComet (116)

LizFoster (648)

@iterate Yes, of course! wwwww

Highwayman (1443)

👌 this is sick! It was nice to have pictures to look at for once XD

LizFoster (648)

@Highwayman Ha ha ha ha! Do they help you understand things better? They help me too ^ ^*

Highwayman (1443)

@LizFoster yeah, I looked at the first paragraph and I was like ....um.... and then I looked at the picture directly after, paced for like 2 seconds and was like oh! Cool!

avibeskrowni (72)

amazing!
i can see that after your first pi approximation, you were still hungry ;)

LizFoster (648)

@avibeskrowni A suggestive (but accurate!) way of saying it. (~_^)

avibeskrowni (72)

@LizFoster yea i guess
didn't really read that through did i

LizFoster (648)

@avibeskrowni Nyahahahahaha, I found it funny.

[deleted]

It's not that your penmanship is bad, but might I recommend having everything that is in the images also typed out below them? Maybe for people who can't load images, screen readers, or people who need to Google Translate the writings?

Also, do you ever think that this 𝛑 thing has become an obsession? Considering the amount of time dedicated and sleep lost to calculate an already (relatively) known number?

LizFoster (648)

@JadenGarcia Ah, okay, I can do that, of course.

Oh, and about spending so much time on 𝛑.... Never say die!

[deleted]

@LizFoster “Die”!? As in English “die”? Like the singular form of “dice,” or relating to death?

Or the German article?
Oh, and “Die,” there, I said it.

LizFoster (648)

@JadenGarcia English "die." Is that the wrong usage?! 0~0

[deleted]

@LizFoster Think so, I dunno English well though, so you can't take my word for it.

Evanlicious (18)

@LizFoster By chance, would that be a reference to the Goonies?

LizFoster (648)

@Evanlicious Ah, no, it is not. What is that?

Evanlicious (18)

@LizFoster Just some movie from an obscure past that I never saw. They had a quote like "Never say die!" or something.

[deleted]

@Evanlicious Well, seeing as she is totally unaware of the reference, she must not be using "die" correctly.

LizFoster (648)

@Evanlicious Oh, ha ha ha. No, I heard it somewhere (though I do not remember where...).

[deleted]

@LizFoster So... what were you intending to say? You haven't been using it incorrectly all along... have you!?

[deleted]

@LizFoster Oh no... that can't end well, I feel sorry for you.

[deleted]

@LizFoster So, you never properly answered the question, "is this an obsession yet"? What are your end goals? A solid not infinite length PI?

LizFoster (648)

@JadenGarcia Well, my real end goal is probably to discover my own approximation of 𝛑.

CodingCactus (4188)

@LizFoster That was a correct use of the word die, "never say die" is a saying. Which basically means that you shouldn't give up on something :-]

LizFoster (648)

@CodingCactus Okay, good! So they were just trolling I suppose? wwwww

[deleted]

@CodingCactus I've never heard it used like that in my entire life.

CodingCactus (4188)

@JadenGarcia It's just a phrase that people use sometimes, it's kinda gone out of fashion I think tho, but it still makes sense

[deleted]

@CodingCactus It must've gone out of fashion.

[deleted]

@LizFoster Aren't you?

[deleted]

@LizFoster Ha, I was being sarcastic, it was a joke. I doubt you'd be that old.

LizFoster (648)

Warhawk947 (530)

very good job, this math is way beyond my middle-school brain...
¯_(ツ)_/¯

LizFoster (648)

@Warhawk947 Ha ha ha ha! If it is at all interesting to you, you should watch 3Blue1Brown's `Essence of Calculus`
series, or Don't Memorise's `Calculus Basics`
series, which I am finishing at the moment!

AmazingMech2418 (1039)

Your Riemann Sum is RIGHT! (hopefully, you get the joke) Also, I would recommend putting in here the formula(s) for the Riemann Sum as shown in this screenshot from Khan Academy just to teach Riemann Sums in general instead of just for approximating pi. (I'm not sure how to use LaTeX in a Repl.it comment...)

By the way, the screenshot is from https://www.khanacademy.org/math/ap-calculus-ab/ab-integration-new/ab-6-3/a/riemann-sums-with-summation-notation.

LizFoster (648)

@AmazingMech2418 Good pun ^ ^;

Oh, I should have done that! (Lol)

I will add that `RIGHT` away, thank you!

AmazingMech2418 (1039)

@LizFoster Thank you and you're welcome!

CodingCactus (4188)

# 👍

CodingCactus (4188)

@LizFoster aww, that upvote on my comment now means my cycles aren't palindromic anymore :(

LizFoster (648)

@CodingCactus Noooooo T~T I'll remove the upvote

CodingCactus (4188)

@LizFoster or I'll try to get to 313 ;)

CodingCactus (4188)

@LizFoster erm, what does wwwwww mean?

LizFoster (648)

@CodingCactus Oh, sorry (Lol)

It's basically just laughter, I guess?

CodingCactus (4188)

@LizFoster wait, have you done the same as yesterday? What time is it where you are?

LizFoster (648)

@CodingCactus Yes, yet another sleepless night T~T

My sleep schedule is seriously messed up..

It is almost 4:00

CodingCactus (4188)

@LizFoster !!!!
You need to try and stay up the whole of "today", then not go on your computer/phone 2 hours before you should be going to sleep :-]

LizFoster (648)

@CodingCactus T~T I will try, it is not like I have much of anything to do now..

CodingCactus (4188)

@LizFoster wow, I'm only 1 cycle away from being palindromic again!

LizFoster (648)

@CodingCactus Hopefully you'll have it soon!

CodingCactus (4188)

@Nettakrim urghhh....
It keeps changing :(
But now (317) the digits add to 11, which is good!

CodingCactus (4188)

@Warhawk947 yeah, which still adds up to 11!

Warhawk947 (530)

@CodingCactus hmm now you have 807 :thonk: