Coding Challenge 125: Fourier Series
Вставка
- Опубліковано 15 чер 2024
- In this coding challenge, I visualize a Fourier series for a square wave in JavaScript with p5.js. Code: thecodingtrain.com/challenges...
🕹️ p5.js Web Editor Sketch: editor.p5js.org/codingtrain/s...
🎥 Previous video: • Coding Challenge 124: ...
🎥 Next video: • Coding Challenge #126:...
🎥 All videos: • Coding Challenges
References:
🗄 Fourier Series: en.wikipedia.org/wiki/Fourier...
📄 Purrier Series (Meow) and Making Images Speak: bilimneguzellan.net/purrier-se...
📄 An Interactive Guide To The Fourier Transform by Better Explained: betterexplained.com/articles/...
Videos:
🎥 What is a Fourier Series?: • What is a Fourier Seri...
🎥 But what is the Fourier Transform? A visual introduction: • But what is the Fourie...
🚂 Polar Coordinates: • 3.4 Polar Coordinates ...
🔴 Coding Train Live 163: • Coding Train Live 163:...
Related Coding Challenges:
🚂 #61 Fractal Spirograph: • Coding Challenge #61: ...
🚂 #130 Drawing with Fourier Transform and Epicycles: • Coding Challenge #130....
Timestamps:
00:00 Welcome! Some resources on the Fourier Series
02:44 Explain! What is a Fourier Series?
07:00 Code! Create a dot spinning around a circle!
11:41 Code! Draw the wave path of the dot!
14:41 Oops! Invert the order of the wave!
16:16 Code! Add multiple circle waves!
23:50 Code! Draw the Fourier series!
25:30 Code! Add slider for number of circles!
27:39 Suggestions
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
🚂 Website: thecodingtrain.com/
👾 Share Your Creation! thecodingtrain.com/guides/pas...
🚩 Suggest Topics: github.com/CodingTrain/Sugges...
💡 GitHub: github.com/CodingTrain
💬 Discord: thecodingtrain.com/discord
💖 Membership: ua-cam.com/users/thecodingtrainjoin
🛒 Store: standard.tv/codingtrain
🖋️ Twitter: / thecodingtrain
📸 Instagram: / the.coding.train
🎥 Coding Challenges: • Coding Challenges
🎥 Intro to Programming: • Start learning here!
🔗 p5.js: p5js.org
🔗 p5.js Web Editor: editor.p5js.org/
🔗 Processing: processing.org
📄 Code of Conduct: github.com/CodingTrain/Code-o...
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
#fourier #maths #javascript #p5js
3blue1brown recommended this video for his Fourier transform video
I've just watched it, it was amazing !!!
I just watched his video, then I tried coding my own Fourier series. Figured I would come on here and see what I did wrong.
@@FilthyManatee In this video the Fourier series is developed in JavaScript language to be run on a normal web browser. If you want more advanced tools to work with such series you can use mathematical software (Matlab, Maple, Octave ..) they have many dedicated methods to be implemented easily. If you want to do things the hard way ;) you can download the code of the presented script in this video and try to modify the coefficients or change other parameters.
@@akremhadji7326 I wrote mine in the hard/fun way (javascript/canvas) already. I did it very differently than what was shown here, but was still able to learn a thing or two watching this video. It gave me a few things to think about and change in my code. I went right into the chain of alternating spinning vectors and drawing from the last point on the chain.
I came here from 3 Blue 1 Brown. And, I am so happy I did! This is a great channel! :)
So happy to see you and Destin interact. This is the intersection of all the best content on UA-cam
who is destin?
@@blasttrash destin is the smarter every day dude
I'm 11 and I'm from Mexico, and have been programming for 3 years and Coding Train is my source of inspiration and learning.
So nice to hear! Please feel free to share anything you make 🙂
it's awesome to have such a productive hobby you get enjoyment from and willingly invest your free time. especially at such a young age. keep it up
Awesome keep it up
b0ss thats great for his age and its called a "comment", plus he just want to say thanks to Daniel
@@don1041 I learned Javascript, p5.js, HTML and CSS
Wow, smarter every day in the coding train... Avengers is no longer the most ambitious crossover in the history of the world
Yeah who needs Rewind if they keep making quality crossovers like these
Fuckavengers
:p
90% of my coding skill is from Coding Train.
Everytime my friends ask me where i learned something, I always show them this channel.
I love this channel so much❤️❤️
I'm Russian student and I want to express my huge thanks to The Coding Train channel! Thanks to you I have top marks in my school! The whole world loves you!!!
Я думал русских ент
Теперь это русский чат макс репост
Thank you!
@@maximgasai1349 Русские везде
Russians everywhere
@@sharphurt8753 у вас в школе преподают JS? Жестко.
dude...I am obsessed. you are literally one of the best teachers Ive ever experienced.
@3:30 What you are calling "Amplitude" is in fact the "Peak to Peak" value. The "Amplitude" will be only half of that.
Indeed, thank you for the correction!
But the coefficient (often called amplitude) is the vertical peak to peak distance of the wave.
@@CJBurkey Peak-to-Peak value isn't the coefficient or the amplitude. Peak is the absolute distance from the average of a function to either the min or max and peak-to-peak is the absolute distance from min to max. The amplitude is the peak value, and on sinusoidal functions, the peak-to-peak value is double the amplitude or peak value.
This is more of the electrical engineer view of it, though
What are you calling "peak to peak value" is in fact sometimes called "peak to peak amplitude", and what you calling "amplitude" is sometimes called "semi-amplitude".
It's kinda similar situation as with "Natural numbers" - the name is ambiguous and it's better to refer to it either as "Positive integers" or "Non-negative integers" depending on what exactly you mean.
That took me -1/12 lines of code
Infinite lines is impossible.
@@sujals7108 But what if i made a code that adds a line to the js file every frame?
@@x-lightsfs5681 Then to make infinite lines, you would need an infinite number of frames, hence infinite time.
@@sujals7108 how bout making more line each frame? Then you'll get to infinity in no time :v
@@x-lightsfs5681 cant go to infinity since memory is always limited :)
I am a high-school student from France and I am really happy to see how great and efficient code can be with people like you!!!
*Procrastinating intensifies*
Underrated comment lol
hah, yeah
hell, there are worst ways to distract yourself. programming fourier transformations is a decent way to waste your time (though time spent learning isn't wasted, I'm told)
As an EET major looking back at studying how to code, I love this! We look at wave forms all day. I am going to recreate this and show my fellow electrical engineers at work.
Did you do it? Were they impressed, or at least mildly entertained?..
please we need an update
I love this channel and this guy and all the videos. Thank you .
I need to more consciously appreciate the amazing, high quality content on UA-cam. We are living in a beautiful time in history
Just stumbled across your channel. This is the best UA-cam channel I've ever seen. So many high quality videos and such great teaching and enthusiasm. I'm just speechless!
28:28 I love that ending. *Has a good moral:* If you stumble over your words instead of trying to solve the confusion just give up, blow your flute, and say goodbye :D
My favourite channel... This is really great...
Fantabulous! This needs to be taught in every DSP course!
Thank you. As always, you make learning so much fun. I've never been able to visualize how Fourier creates a square wave or any wave until now.
LOVE The Crossover with Smarter everyday, Been getting into coding because of you, thanks!
An interesting thing that was done i think in 3blue1brown was to assign random or non-regular growing or shriking radius to the circles. Theses Fourrier series create really unique and interesting patterns, some of them event ressembing famous man made paintings.
Awesome, interesting and instructing. Thank you for all the effort you put in the channel!
this is so freaking fantastic! I could do this all day
After visualising this in the full complex form, it becomes pretty clear how higher frequencies enhance the "precision" of the wave position. I love how the whip rolls up into a tight ball with each rotation and each addition of epicycles.
It's the first video of yours i've seen, and damn! I wish my brain could think that fast for programming crazy math stuff lol. Congrats man, you got a new fan here
Isn't it so satisfying to witness that sine waves are making rectangular wave , that ending of this video made my whole 2019 yr , and a good start of 2020 , thanks for this awesome video 🌷
Yoooo nice plugging smartereveryday. I love that channel.
Best analogy ever. Very smooth.
I love the way the best and the brightest youtube channels are inspired and motivated by each other...that is a really positive environment.... Siraj,you,smarterEveryday,3 blue 1 brown.....
You guys really help me and many others as well .
Thank you.
awesome !!! The movement of all those circles radii looks so "biologic", fascinating !
1:21 Website's name actually means "science is so beautiful"
dafgjkdfjaglh
you always release coding challenges just when im studying a specific topic
Yeah, I'm supposed to study algorithms and time complexity proving. So... I guess I will fail the test, but I will know a bit more about FS. Totally worth it xD
Right? I was recently looking into graph plotting and stumbled upon this, too. And within a week there this video. Hee's tracking my browser history.... I have to go.
This is a good example of coding Fourier series, thanks.
I really appreciate the goofs and slight logic mistakes on this one, it was almost more enlightening than if he had just done the thing
That refactoring song though ahah! We need 10 hour version for productive coding work!
You can translate
Bilimneguzellan= Bilim+ne+ guzel +lan = Science+ what+ beautiful +guy = hey guy Science is what a beautiful thing !
for pronounciation,
go to google translate, select turkish , type the "Bilim ne güzel lan" and tap the voice button :)
Oh be gördüm rahatladım. Yoksa ben yazacaktım.
Iyi yetiştin
Adamsın, adam sitenin ismini okurken bunaldım...
djfsdfsjdfjdfljdfg çok iyi okumadı mı dfghjkdfghjdfghjhjdfgkdfg
27:18 Kinda cool illustration of aliasing that happens when the sampling rate is not a perfect multiple of the signal frequency being sampled. After increasing it to 100, sometimes you get a big spike at the corners on the square wave, sometimes not -- this is the aliasing. Sometimes you're "lucky" to sample (draw) when the tip of the pendulums are at the very top or bottom of the corner, and you get a spike. Sometimes you're "unlucky" to sample (draw) when the tip of the pendulums are not near the top or bottom, and you get a more traditional "90 degrees corner" without the spike.
the slider part at the end is even more interesting as it gives even chaotic curve which when condensed give non continuous sine waves of different frequencies......*wow*
Wow awesome job it's super satisfying! :)
I’m actually so excited for this video
This was amazing, thanks for doing a video on this
Dude, you are my new hero.
This was really fun to watch that i didn't notice the video's lengh was 30min.
Nice work really :D
4:12 - To play a musical note, the sine wave is made of multiple sine waves. You have the note you want, but you also have some overtones.
I'm native Turkish and i like how you pronounce the name of the website :D and great video, thank you
You deserve so much more attention.
Primer video que veo. Adoro!
The end result looks like a fantastic whip. WT-TSH!!
It's wappah
Very very useful. Thank you so much Dan
Great video, loved it.
Amazing. Thank you for sharing your awesome skills.
This video inspired me to learn p5.js .Will be my new resolution to learn p5.js !!!
What a coincidence the video was suggested to me just when I was about to start Fourier series for my exam prep.👻
I’d love to see a part 2!
Fun fact at 27:20 you can see spikes on the corners of the function and this is called the Gibbs phenomenon and you can never get rid of it, due to the discontinuity of the function that you are trying to approximate.
thanks, yesterday i was trying this
I'm glad after a couple years of thinking about the fourier transform, I made something like what he talked about with the homer simpson being drawn,
Brother, dude, friend Daniel, thank you!
Thank you so much man
I was anticipating your video since you mentioned doing this in the smarter everyday video comments.
I searched on how to get the x and y values on something that had been rotated for hours. I knew that it would be something having to do with the angle and the hypotenuse, but I never found what I was looking for. I finally got the answer by some guy on Reddit this morning. Why couldn’t I have watched this video when I really needed it?
You have a great taste on youtube channels you watch
Hey, go to 3Blue1Browns Channel for a new video about Fourier Series!!
You can make
y = negative radius sin(time) ..... because y is upside in computer land.
my most favorite to date
I like these Coding Challange videos :) trying to replicate these in python makes learning so much fun and also easier. Thank yyou!
What do you use to draw in python? Turtle?
I like your approach to explanation - really interesting - cool video
You are the best man
I am so excited !!
Thanks for making the video
this video made me study Fourier series again
I needed this
page's name is "bilim ne guzel lan" and it means in english "science is what a sweet thing buddy" :D
Geniuss😭. Please teach us more !
AMAZING!!
this guy is so funny i love it
Just awesome
Amazing!
I like your train if thought, it is very helpful
this is EPIC , would you please continue uploading like this content? especially on fourier drwaing visuals?
yes, i'm planning to!
Brother me Bangladeshi your good tips my head very easy work thank you so much brother
Amazing 😄
Awesome 👍
I like your codding challanhes.So maybe I will learn js
You are amazing
amazing. Wow
this is so much fun
Thanks!
Thank you for the support!
You are the bestest ❤
i come from 3b1b and i barely know coding, but i just subscribed...
great video
This guy is the smartest guy in the neighborhood - the Mr Rogers of code.
Interesting to see the fractal tree branches being produced here by the circles radiuses 23:50
OMG, I like this channel a lot! thank you and, btw, how did you cancel the auto-fill? 😂
Is it just me or is this pattern of circles rotating around eachother looking like a whip when it reaches a hundred.
Maybe this is how a whip delivers such a fatal blow.
Tries to type stroke
Accidentally types MediaStreamTrackAudioSourceNode
that was impressive
Attempted JAVA translation - ua-cam.com/video/H6T7dyfcXW0/v-deo.html
Something interesting at 27:46 when those circles come around they almost *slap* the square wave and it changes the spikes at the corner of the square wave lol
Sweet!