NumPy Tutorial (2022): For Physicists, Engineers, and Mathematicians

Sdílet
Vložit

Komentáře • 216

  • @francisrayquintana5119
    @francisrayquintana5119 Před 3 lety +131

    This dude, this channel: is a blessing.

  • @indocesare14
    @indocesare14 Před 2 lety +18

    At university I've been taught Matlab but I always wanted to switch to python in order to get rid of licensing problems and fully embrace the "open-sourceness" of this programming language. This video is a blessing!

  • @vittoriociardiello9945
    @vittoriociardiello9945 Před 2 lety +60

    Believe me, you are one of the most useful channels about python. Thank you so much.
    You would deserve much more subscriptions.
    What about a cython playlist?

  • @VALedu11
    @VALedu11 Před rokem +3

    I have shared this link with almost 75 students of mine in the MAchine learning with PYthon class. You have made my job so much easier.. thanks a TON

  • @leonardofacchin1452
    @leonardofacchin1452 Před 2 lety +6

    Like many others before me, I'm just chiming in in order to thank you for these outstanding tutorials.
    It's not hard to find numpy tutorials on the internet, but most of them are either very basic because of the target audience (and so they can't push the student hard enough) or deeper but still mostly amounting to a showcase of methods, functions and syntax. What I like about yours is that they can be challenging at times for a newbie but still very much rooted in the scientific problem-solving mindset and that makes them priceless and fun to watch and try out.

    • @bot5am
      @bot5am Před 2 lety +1

      Exactly what you said. Chiming x 2

  • @flynnxd8229
    @flynnxd8229 Před 3 lety +20

    Super useful and engaging! Looking forward to the scipy and matplotlib ones.

  • @ayushkumarsharma7019
    @ayushkumarsharma7019 Před rokem +4

    Even after 2 years this is the most fun and informative video for numpy that i needed , really loved those exercises.
    thank you for such an amazing content

  • @connorbrown5267
    @connorbrown5267 Před 2 lety +17

    For my entire undergrad and masters I avoided coding like the plague, always disliked matlab and used maple a few times for checking christoffel symbols in black hole studies, other than that I am extremely inept, this tutorial saved my life, looking forward to trying all of your other videos, from one PhD student to another, god bless you

    • @guitar0wnz
      @guitar0wnz Před 2 lety +1

      Good luck man, did the same thing. Didn't feel comfortable coding until I was out of college knowing that deadlines and everything were finally behind me. Now that I'm out though I realize what an amazing resource it is. Bet you'll have a badass thesis down the line

    • @annakquinn7084
      @annakquinn7084 Před 2 lety

      Good luck with your student loans

    • @alboz1327
      @alboz1327 Před 2 lety +1

      @@annakquinn7084 ???????? What kind of comment is that

    • @annakquinn7084
      @annakquinn7084 Před 2 lety +1

      @@alboz1327 real ones based on reality

    • @albertonovati8033
      @albertonovati8033 Před 2 lety +1

      @@annakquinn7084 the comment doesn't make sense. Why bringing up student loans, what does this have to do with anything in a python video

  • @sietsebuijsman8523
    @sietsebuijsman8523 Před 3 lety +28

    Very good tutorial, thank you! I was kind of figuring out Python by myself, but this helped me put everything in context. And this finally enables me to get rid of the for loops :'D

  • @abishaimathai6542
    @abishaimathai6542 Před rokem +1

    I hope the algorithm blesses you. Best tutorial for NumPy on the internet hands down.

  • @amsal1998
    @amsal1998 Před 3 lety +6

    This video series is going to be great!

  • @kekskekskeks112
    @kekskekskeks112 Před 3 lety +7

    Wow, thank you so much! Because of your explanation at 29:44 I just understood those slice-operations, I allways struggled with, fell like scales from my eyes :D

  • @frankkoslowski6917
    @frankkoslowski6917 Před 2 lety +1

    Nice and meaty tutorial. Have been going over it several times.
    Cross-referenced many ideas and principles with information from other sources.
    It can be said that If nothing else, the effort invested in studying the material,
    has produced good fluency in typing LaTex Script,
    and consequently, textbook-like IPython Notebook files.
    Thank You!

  • @SubhadipDas1
    @SubhadipDas1 Před rokem +1

    Your tutorial are very easy to learn yet very concise, informative and in-depth. Please keep making such contents.

  • @bismillahyusufu5121
    @bismillahyusufu5121 Před 9 měsíci

    For sure, you're the best Python teacher I have met so far on CZcams.
    Thank you so much. God bless you

  • @sucksh97
    @sucksh97 Před 3 lety +8

    Amigo, eres un crack! me sirvió muchísimo el tutorial. Gran calidad de videos :)

  • @AbdelatifMariche
    @AbdelatifMariche Před měsícem

    one of the best if not the best explanation, within 1h:30 u can say that you manipulate numpy well... continuing to scipy and plt

  • @nicoleworoniuk1544
    @nicoleworoniuk1544 Před rokem

    This is the best channel I have come across for python, as an engineering student, I am so grateful! Thank you !!

  • @marounrizk
    @marounrizk Před 9 měsíci

    So underrated, what a great channel ! Thank you from a physics engineering undergraduate.

  • @akshatrastogi9063
    @akshatrastogi9063 Před rokem

    This is one of the best numpy tutorial for engineers on youtube!

  • @Ali-pd2rl
    @Ali-pd2rl Před rokem +3

    It's awesome mate! Your videos about these libraries really help me, and of course these are very useful in my major (physics). Thank you 🙏

  • @mayabelemezova1548
    @mayabelemezova1548 Před 2 lety

    Thanks a lot and for questions we have to think of. At that places you stop and think :"Am I really remember all the elements? And did I know how exactly to use them?" All the tricks are not just for the exact implementation of the rules , it was to teach with the way of thinking!
    Thank you!

  • @Michallote
    @Michallote Před rokem +12

    Just a small remark: at 31:31 we have not found 'exactly' the locations where dydx = 0. We have just found the minimum interval available where dydx = 0 is bound to be. This is important because imagine our number of points wasn't ideally as big as 10000, in most cases we don't have the luxury of having analytic functions. And in most cases this makes it sensitive to discretization errors.
    So in reality one additional step would suffice to get the most precise answer. This already gives us the number of sign changes in the interval. So we could simply use interpolation to find zeros between the x[interval],x[interval+1] to get a precise answer.

  • @d3f3kt57
    @d3f3kt57 Před rokem

    I am migrating from Matlab to Python. Your videos are a blessing. Thanks

  • @maksudulhossainjewel378
    @maksudulhossainjewel378 Před 3 lety +1

    It's gonna hit a million in no time!

  • @richardbennett4365
    @richardbennett4365 Před 2 lety

    I like watching this man, because he is thorough and is great with examples in his teaching, but his language is unique!!!
    He is LOUD. He yells to learn you the material. He also repeats himself, and he is a big fan of the imperative mood in English. He's always commanding the listener to do something or remember something. He's so funny 🤣😅🤣.

  • @user-vi1tw1xw7r
    @user-vi1tw1xw7r Před 8 měsíci

    This has been fantastically helpful, thanks. I've used python a lot for the last 5 years or so for many projects, but hadn't properly acquainted with numpy. I'm currently exploring analysing captured audio signals for equipment testing, so playing with numpy and fft a bit. The array multiplication tip for finding zero crossing points is just brilliant. I've just implemented it as another way to get a frequency measurement. 👍

  • @Millapez
    @Millapez Před 6 měsíci

    thank you Mr.P, as a PhD geology student entering into python this video is amazing,

  • @ErikS-
    @ErikS- Před rokem

    better than most of the other video tutorials on numpy that I have seen...

  • @AishikDasgupta-pm5pl
    @AishikDasgupta-pm5pl Před rokem +1

    Thanks a lot mate. Please keep posting. I find these videos tremendously helpful for my Computational Nano electronics course.

  • @user-le1el4fy4t
    @user-le1el4fy4t Před 6 měsíci

    very nice and in depth presentation. You deserve appreciation and subscription. Thanks

  • @alex_blade2001
    @alex_blade2001 Před 4 měsíci

    Thanks a lot for all this video. It helped me a lot in my final year project.
    😊

  • @AndreasLvgaard
    @AndreasLvgaard Před 2 lety +2

    This was really informative! You are a genius, thank you!
    I like the hands-on exercises/examples, which I followed along in my own desktop application (VSCode). And I learned that "trick" of how to get all x-values when dy/dx = 0. Incredible how something that looks hard can turn out to be so easy :D
    Using Python a lot in my engineering career and NumPy is essentiel in numerical calculations!
    I guess I will continue to look at your videos, starting with SciPy!

  • @NinjaMartin
    @NinjaMartin Před 4 měsíci

    Man. So good. I really wish you the best, you are such a great teacher as well. Thanks for sharing your knowledge.

  • @irvinggaspar1531
    @irvinggaspar1531 Před 2 lety

    I've learned a lot of thing with your videos rather than in Computer physics classes, thank u Bro

  • @carlossalgueirosa1821
    @carlossalgueirosa1821 Před 2 lety +1

    Awesome! There are no more word to say, your lecture is awesome!

  • @gedavaa1
    @gedavaa1 Před rokem

    Dear Mr. P Solver, I am very thankful for your Python tutorial videos. I have learnt much more things. Thank you again.

    • @User-jr7vf
      @User-jr7vf Před rokem

      do you know what software he is using in the video?

  • @marioaguilar8735
    @marioaguilar8735 Před 2 lety +1

    U got one more subscriber. Just found you by chance, and I appreciate.
    Great tutoria and very clear explanations!!!

  • @anweshbhattacharyya7763

    Bro you are a gift for data science & machine learning.

  • @lecturesfromleeds614
    @lecturesfromleeds614 Před 10 měsíci

    Brilliant presentation! You pretty much covered everything important for doing computational mathematics

  • @markushaysnielsen4885
    @markushaysnielsen4885 Před 3 lety +3

    This is amazing! I’m sharing this with everyone I know :-)

  • @user-qo7vr3ml4c
    @user-qo7vr3ml4c Před 3 měsíci

    Referred to your scipy and numpy tutorials, excellent content. Thank you!!

  • @davidhendriks1395
    @davidhendriks1395 Před 3 lety +1

    Great video. Having some clear and complete tutorial on these topics is very useful!

  • @samuelnjau8086
    @samuelnjau8086 Před rokem

    The illustration and speed is just amazing😎

  • @Arkantosi
    @Arkantosi Před rokem

    I never compliment people but...this dude is fantastic.

  • @alvarobyrne
    @alvarobyrne Před rokem

    zooming in: at 13:51 you did something most coding teachers don't take into account, which is zooming in; you yourself forget to zoom in at the beginning of your excellent tutorials , but they could be much better if you remembered to zoom in at the beginning of them; ha ha. you know, some of your thousands of spectators use glasses to watch your tutorials, 13:51, thnkyou very much for your channel for your attention and thanks in advance for zooming in, ;) Ah! and removing the side bar, hiding it: everything that increases screen real state

  • @thomasking5894
    @thomasking5894 Před 3 lety

    great young teacher here. fine fast ideas for my use of numpy in my elliptic curve work.thanky P. Solver

  • @ameerbaloch9894
    @ameerbaloch9894 Před 3 lety +3

    thank you so much for these videos. please keep up the good work

  • @renukavelu1701
    @renukavelu1701 Před 3 lety +3

    I enjoyed learning!! Please do more such tutorials. If possible, please share the codes too:)

    • @renukavelu1701
      @renukavelu1701 Před 3 lety

      could you explain why this code doesn't work for the last part of the 1st exercise? x[dydx==0]

    • @pratyushprakashpatra7062
      @pratyushprakashpatra7062 Před 2 lety

      @@renukavelu1701 Because it's never exactly equal to 0. We have to find the value for which it is closest to 0

  • @lookaway8496
    @lookaway8496 Před 2 lety +1

    such a great teacher you are! I am learning a lot here

  • @TatouVlogs1
    @TatouVlogs1 Před 3 lety +2

    I need more, you're wholesome.

  • @AluminiumT6
    @AluminiumT6 Před rokem

    Completed today. Thanks for this great resource Luke!

  • @AnatolVZ
    @AnatolVZ Před rokem

    Amazing algorithm for roots!! I have watched 3 times and I cetch the idea!! You are cool!!!

  • @brucewernick6542
    @brucewernick6542 Před 2 lety

    This stuff is pure gold. The curvefit video was excellent. Then the turkey cooking demo caught my eye. Now, you have me playing with numpy, scipy, matplotlib and sympy. Fantastic tools for engineers. I tried Jupyter but I don't see the benefit. There seems to be a big overhead when you consider that Python can be run from the most basic plain text editor.

  • @kevinesh
    @kevinesh Před 3 lety +1

    U r the GOAT. I already liked it and I still don't even see it. Do you think it would be possible a serie in Optimization Methods using numpy numba, etc?

  • @caiolaytynher5994
    @caiolaytynher5994 Před 2 lety +2

    First things first, your channel is really great, I'm an engineering student learning python and you are making that process so much easier. That being said, did you know that you don't need any library to answer question 2? Just use a list comprehension!
    sum([i for i in range(0, 10_001) if i % 4 != 0 and i % 7 != 0])

    • @MrPSolver
      @MrPSolver  Před 2 lety +1

      Very neat! Though I suspect this may be faster with numpy, as list comprehension (which is essentially just a for loop) can be slow in python. I would try this for 10 million numbers and see which method works faster.

    • @caiolaytynher5994
      @caiolaytynher5994 Před 2 lety

      @@MrPSolver In my tests, there is no significant improvement other than 1 ms, 100,000,000 was enough to take the runtime to over 7 s. If someone test this and find a significant improvement, I'll like to see cuz even myself thought that with numpy would be faster, lol.

  • @rio_agustian_
    @rio_agustian_ Před 2 lety +1

    28:00 Wow, that's an amazing trick! Last semester I had a computational physics exam. If I know this sooner, probably my grade would be better

  • @sarojmandloi7974
    @sarojmandloi7974 Před 2 lety +1

    Thank you very much for providing this type of content to us.

  • @develxper7931
    @develxper7931 Před 2 lety

    This dude is an absolute legend

  • @ozgurbezgen4276
    @ozgurbezgen4276 Před 9 dny

    For the final part of the Question 1 :
    I wrote the following code before watching the solution and got the same results. I hope it helps.
    len= np.shape(dydx[np.sort(dydx) < 0])[0]

    biggest_negative = np.sort(dydx)[len-1]
    biggest_negative2 = np.sort(dydx)[len-2]
    biggest_negative3 = np.sort(dydx)[len-3]
    print(biggest_negative,biggest_negative2,biggest_negative3)
    a, b, c = np.where(dydx == biggest_negative), np.where(dydx == biggest_negative2), np.where(dydx == biggest_negative3)
    # a, b, c are the indexes of the biggest_negative, biggest_negative2, biggest_negative3 consecutively.
    print(a,b,c)
    print(x[a], x[b], x[c])

  • @frankservant5754
    @frankservant5754 Před 2 lety +1

    Very concise explanations thanks you are a lifesaver

  • @scienceaj2907
    @scienceaj2907 Před 2 lety

    Amazing stuff and one of the best teachings I’ve ever seen ❤️

  • @Ligress
    @Ligress Před rokem

    brilliant series, many people say that scientists use NumPy, scipy but you showed "HOW TO DO IT"

  • @bensepter8500
    @bensepter8500 Před rokem

    These videos are great, man.

  • @kevinsweeney2809
    @kevinsweeney2809 Před rokem

    Can you please make a video where you write code for a nudged elastic band calculation? You use nudged elastic band methods to calculate the structure and energy of transition state(s) for a reaction. The classic example for a nudged elastic band calculation is determining the structure and energy of the transition state for H2 splitting.

  • @rasin9391
    @rasin9391 Před 2 lety +2

    love the camera dude

  • @user-we6mf5bn4m
    @user-we6mf5bn4m Před rokem

    This is Awesome !!
    Science girls should be in looove

  • @abdullahalmehadi6152
    @abdullahalmehadi6152 Před 2 lety

    These tutorials are really great ! Thanks man !

  • @kaushikgupta8722
    @kaushikgupta8722 Před 2 lety

    Perhaps the best explanation!!

  • @e-Technik
    @e-Technik Před 3 lety

    Thanks a ton. Please keep making your videos. Just excellent.

  • @frankkoslowski6917
    @frankkoslowski6917 Před 2 lety

    ravel(), compared to flatten(), will often be faster since no memory is copied, but you have to be more careful about modifying the array it returns. flatten() always returns a copy. ravel() returns a view of the original array whenever possible.

  • @prietjepruck
    @prietjepruck Před rokem

    Thanks for this great tutorial.

  • @ghostcleanseIRL
    @ghostcleanseIRL Před 5 měsíci

    1:10:56 I think it should be z instead of t given that we're plotting Ex as function of z with fixed t

  • @maksudulhossainjewel378
    @maksudulhossainjewel378 Před 2 lety +1

    Can you please explain this part E = np.swapaxes(E, 0, -1)? Why is -1 the element or inner axis?

  • @user-ek6rf7dw5d
    @user-ek6rf7dw5d Před 11 měsíci +1

    At 24:31 , is there any advantage of using the * operator rather than a plain logical & operator? Both give the same result, but, coming from a programming background, I feel using a boolean operator make the meaning of the operation much clearer. Other operator, like | , don't match so cleanly to a multiplication.

  • @idotsameret5144
    @idotsameret5144 Před 2 lety +1

    your channel is over the top and your are better then my python prof, so thanks . can you also uplode a video about pandas ? to much lab results in a csv file . and again many thanks

  • @shivpratapsingh5766
    @shivpratapsingh5766 Před 3 lety +1

    You are a legend

  • @anilawasiya3642
    @anilawasiya3642 Před 2 lety

    omg awesome content I am learning for my passion in physics

  • @diegofernandez8881
    @diegofernandez8881 Před 3 lety +2

    Thanks, and please continue (:

  • @mentefria98
    @mentefria98 Před 2 lety +1

    God bless you, thanks for this

  • @nicholas.hutton
    @nicholas.hutton Před 3 lety +5

    Thanks for having the chapters built into the video. I do have a question though. Do you see a benefit to learning math applications of python like this instead of using Matlab? My school gives us an edu license and I don't know where to spend my time learning.

    • @MrPSolver
      @MrPSolver  Před 3 lety +8

      Despite having access to both, I would still choose learning python over Matlab, mostly because there are so many resources available online for python. That being said, from what I understand, the two languages are very similar. If you spend a lot of time learning one, it should transfer over to the other (not the notation, per se, but the general way you approach problems). But for all intents and purposes, python has everything you need for an undergraduate degree. When I was in undergrad, my school also offered a full Matlab license, but I chose to learn python instead. Also when working with others people's code after you've graduated (grad school, industry) you'll notice that A LOT of code will be written in python.

    • @Piipolinoo
      @Piipolinoo Před 3 lety +7

      Without any doubt: python. Matlab is proprietary bullshit and there is a reason Mathworks (the maker of matlab) is giving out free educational licenses to universities: just to trap you in their ecosystem. Stay clear from matlab unless you actually have to.

  • @shrimaykher2978
    @shrimaykher2978 Před 2 lety

    Man you are amazing!!
    Great work

  • @bot5am
    @bot5am Před 2 lety

    1:09:00 is a multi-level blessing.

  • @hsh7677
    @hsh7677 Před 3 lety +2

    Thank you!!

  • @attajilani
    @attajilani Před rokem

    Impressive, wonderful python skills.

  • @user-ql1im6ew7i
    @user-ql1im6ew7i Před rokem

    Please continue making video

  • @user-ml9ib1lm3r
    @user-ml9ib1lm3r Před 2 lety

    Amazing tutorial thank you very much !!

  • @onadav
    @onadav Před 3 lety +1

    great! I am back to python thanks to you. what about the Maxwell equations?

  • @ramacharan2825
    @ramacharan2825 Před 2 lety +1

    thanks yu sooo much ,you are awesome .

  • @anupkulkarni6986
    @anupkulkarni6986 Před rokem

    Hey man ,you got one new subscriber 😊

  • @heirta21
    @heirta21 Před rokem

    hello Mr. P Solver, I really love your videos but with regards to that multi-dimensional arrays, 3D animations would really help.

  • @nobody2937
    @nobody2937 Před 2 lety

    Excellent Tutorial .... Thank you ...

  • @athalm8289
    @athalm8289 Před rokem

    Thank you, Luke. Can you upload the meshgrids diagram , thanks!

  • @AntonioLopez8888
    @AntonioLopez8888 Před rokem

    Canada seems to be a country with very good education system

  • @DiomedesStrosMkai
    @DiomedesStrosMkai Před 3 lety +2

    Can someone elaborate why we need to swap axes at 1:12:00? I just can't wrap my head around it

    • @isaac.zeitgeist
      @isaac.zeitgeist Před 2 lety

      Ok I think I got it, that was hard af.
      Basically when we say that E=Ex,Ey,Ez we are not creating a bunch of vectors mashed together with the components in order, no, we are creating a 3D array that you can visualize like 3 slices of 100x100 arrays (that is the size of our meshgrid). Each slice has all possible combination of z and t values evaluated in Ex, Ey and Ez respectively.
      So the shape of the array is (3, 100, 100)
      Now, when we do swapaxes(E, 0, -1) what you are telling python is "in E, swap the first axis (the one with the 3) and the last (the second axis that has 100))
      So python reshapes everything to give you E in a shape like this (100, 100, 3). That means 100 slices of 100 rows and 3 columns, which is basically what you see in screen, a lot of vectors put together with the components in order.
      If you don't have the data in that form, you can't do the cross product properly. That is why we need the axes to be swapped.

  • @haliluya4217
    @haliluya4217 Před rokem

    I think in question 4,the last term of y-axis should be E(t/k) rather than E(tk)

  • @muzammilomarzoy6616
    @muzammilomarzoy6616 Před 4 měsíci

    Day 1 | 15:18 Calculus and Statistics

  • @aliexpress.official
    @aliexpress.official Před 3 lety +3

    1:12:30 I don't understand what swapaxes does? is it not just a transpose?

    • @MrPSolver
      @MrPSolver  Před 3 lety +2

      Its essentially the same thing, ya!

    • @nahblue
      @nahblue Před 2 lety

      The array has three dimensions, so there are "many ways to transpose it"; swapaxes picks which two axes we want to switch around here.

    • @isaac.zeitgeist
      @isaac.zeitgeist Před 2 lety +1

      Ok I think I got it, that was hard af.
      Basically when we say that E=Ex,Ey,Ez we are not creating a bunch of vectors mashed together with the components in order, no, we are creating a 3D array that you can visualize like 3 slices of 100x100 arrays (that is the size of our meshgrid). Each slice has all possible combination of z and t values evaluated in Ex, Ey and Ez respectively.
      So the shape of the array is (3, 100, 100)
      Now, when we do swapaxes(E, 0, -1) what you are telling python is "in E, swap the first axis (the one with the 3) and the last (the second axis that has 100))
      So python reshapes everything to give you E in a shape like this (100, 100, 3). That means 100 slices of 100 rows and 3 columns, which is basically what you see in screen, a lot of vectors put together with the components in order.

  • @BoostedPLAYER1
    @BoostedPLAYER1 Před rokem +1

    24:34 Can anyone confirm that `y[(x>=4)*(x=4)&(x

  • @NTC
    @NTC Před 2 lety +4

    you must have had a PhD in either Maths or Physics, am I wrong?