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

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ค. 2024
  • Check out my course on UDEMY: learn the skills you need for coding in STEM:
    www.udemy.com/course/python-s...
    This from-scratch tutorial on NumPy is designed specifically for those in physics, mathematics, and engineering. In the future, I will be making tutorial videos on all the essential python packages, so subscribe for more!
    All code can be found here:
    github.com/lukepolson/youtube...
    0:00 Introduction
    3:43 Array Operations
    8:28 Indexing and Slicing (1 Dimension)
    15:18 Calculus and Statistics
    21:28 Examples
    47:18 Multi-Dimensional Arrays
    52:22 Functions on Multi-Dimensional Arrays
    56:26 Linear Algebra: Matrix Operations
    58:33 Linear Algebra: Systems of Equations
    59:53 Linear Algebra: Eigenvalue Problems
    1:02:02 Examples
    1:28:42 Basic Datasets
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 212

  • @francisrayquintana5119
    @francisrayquintana5119 3 ปีที่แล้ว +125

    This dude, this channel: is a blessing.

  • @indocesare14
    @indocesare14 ปีที่แล้ว +16

    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 2 ปีที่แล้ว +59

    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 ปีที่แล้ว +2

    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

  • @flynnxd8229
    @flynnxd8229 3 ปีที่แล้ว +20

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

  • @ayushkumarsharma7019
    @ayushkumarsharma7019 ปีที่แล้ว +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

  • @sietsebuijsman8523
    @sietsebuijsman8523 3 ปีที่แล้ว +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

  • @Ali-pd2rl
    @Ali-pd2rl ปีที่แล้ว +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 🙏

  • @SubhadipDas1
    @SubhadipDas1 ปีที่แล้ว +1

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

  • @kekskekskeks112
    @kekskekskeks112 3 ปีที่แล้ว +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

  • @davidhendriks1395
    @davidhendriks1395 3 ปีที่แล้ว +1

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

  • @Michallote
    @Michallote ปีที่แล้ว +11

    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.

  • @leonardofacchin1452
    @leonardofacchin1452 2 ปีที่แล้ว +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 2 ปีที่แล้ว +1

      Exactly what you said. Chiming x 2

  • @frankkoslowski6917
    @frankkoslowski6917 2 ปีที่แล้ว +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!

  • @AndreasLvgaard
    @AndreasLvgaard 2 ปีที่แล้ว +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!

  • @nicoleworoniuk1544
    @nicoleworoniuk1544 ปีที่แล้ว

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

  • @sucksh97
    @sucksh97 3 ปีที่แล้ว +8

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

  • @abishaimathai6542
    @abishaimathai6542 ปีที่แล้ว +1

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

  • @marioaguilar8735
    @marioaguilar8735 2 ปีที่แล้ว +1

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

  • @AishikDasgupta-pm5pl
    @AishikDasgupta-pm5pl ปีที่แล้ว +1

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

  • @amsal1998
    @amsal1998 3 ปีที่แล้ว +6

    This video series is going to be great!

  • @connorbrown5267
    @connorbrown5267 2 ปีที่แล้ว +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 2 ปีที่แล้ว +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 2 ปีที่แล้ว

      Good luck with your student loans

    • @alboz1327
      @alboz1327 2 ปีที่แล้ว +1

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

    • @annakquinn7084
      @annakquinn7084 2 ปีที่แล้ว +1

      @@alboz1327 real ones based on reality

    • @albertonovati8033
      @albertonovati8033 2 ปีที่แล้ว +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

  • @bismillahyusufu5121
    @bismillahyusufu5121 8 หลายเดือนก่อน

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

  • @AluminiumT6
    @AluminiumT6 ปีที่แล้ว

    Completed today. Thanks for this great resource Luke!

  • @carlossalgueirosa1821
    @carlossalgueirosa1821 2 ปีที่แล้ว +1

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

  • @user-vi1tw1xw7r
    @user-vi1tw1xw7r 7 หลายเดือนก่อน

    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. 👍

  • @marounrizk
    @marounrizk 8 หลายเดือนก่อน

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

  • @irvinggaspar1531
    @irvinggaspar1531 2 ปีที่แล้ว

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

  • @NinjaMartin
    @NinjaMartin 3 หลายเดือนก่อน

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

  • @user-qo7vr3ml4c
    @user-qo7vr3ml4c 2 หลายเดือนก่อน

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

  • @akshatrastogi9063
    @akshatrastogi9063 ปีที่แล้ว

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

  • @scienceaj2907
    @scienceaj2907 ปีที่แล้ว

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

  • @lecturesfromleeds614
    @lecturesfromleeds614 9 หลายเดือนก่อน

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

  • @mayabelemezova1548
    @mayabelemezova1548 2 ปีที่แล้ว

    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!

  • @brucewernick6542
    @brucewernick6542 2 ปีที่แล้ว

    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.

  • @lookaway8496
    @lookaway8496 2 ปีที่แล้ว +1

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

  • @d3f3kt57
    @d3f3kt57 ปีที่แล้ว

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

  • @markushaysnielsen4885
    @markushaysnielsen4885 3 ปีที่แล้ว +3

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

  • @ameerbaloch9894
    @ameerbaloch9894 3 ปีที่แล้ว +3

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

  • @abdullahalmehadi6152
    @abdullahalmehadi6152 2 ปีที่แล้ว

    These tutorials are really great ! Thanks man !

  • @user-le1el4fy4t
    @user-le1el4fy4t 5 หลายเดือนก่อน

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

  • @alex_blade2001
    @alex_blade2001 3 หลายเดือนก่อน

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

  • @richardbennett4365
    @richardbennett4365 2 ปีที่แล้ว

    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 🤣😅🤣.

  • @maksudulhossainjewel378
    @maksudulhossainjewel378 3 ปีที่แล้ว +1

    It's gonna hit a million in no time!

  • @anweshbhattacharyya7763
    @anweshbhattacharyya7763 2 ปีที่แล้ว

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

  • @ErikS-
    @ErikS- ปีที่แล้ว

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

  • @AbdelatifMariche
    @AbdelatifMariche 10 วันที่ผ่านมา

    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

  • @kevinesh
    @kevinesh 3 ปีที่แล้ว +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?

  • @samuelnjau8086
    @samuelnjau8086 ปีที่แล้ว

    The illustration and speed is just amazing😎

  • @sarojmandloi7974
    @sarojmandloi7974 2 ปีที่แล้ว +1

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

  • @frankservant5754
    @frankservant5754 2 ปีที่แล้ว +1

    Very concise explanations thanks you are a lifesaver

  • @e-Technik
    @e-Technik 3 ปีที่แล้ว

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

  • @AnatolVZ
    @AnatolVZ ปีที่แล้ว

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

  • @Millapez
    @Millapez 5 หลายเดือนก่อน

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

  • @gedavaa1
    @gedavaa1 ปีที่แล้ว

    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 ปีที่แล้ว

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

  • @thomasking5894
    @thomasking5894 2 ปีที่แล้ว

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

  • @shrimaykher2978
    @shrimaykher2978 2 ปีที่แล้ว

    Man you are amazing!!
    Great work

  • @onadav
    @onadav 2 ปีที่แล้ว +1

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

  • @kaushikgupta8722
    @kaushikgupta8722 2 ปีที่แล้ว

    Perhaps the best explanation!!

  • @TatouVlogs1
    @TatouVlogs1 3 ปีที่แล้ว +2

    I need more, you're wholesome.

  • @bensepter8500
    @bensepter8500 ปีที่แล้ว

    These videos are great, man.

  • @frankkoslowski6917
    @frankkoslowski6917 2 ปีที่แล้ว

    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.

  • @user-ml9ib1lm3r
    @user-ml9ib1lm3r 2 ปีที่แล้ว

    Amazing tutorial thank you very much !!

  • @alvarobyrne
    @alvarobyrne ปีที่แล้ว

    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

  • @athalm8289
    @athalm8289 ปีที่แล้ว

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

  • @prietjepruck
    @prietjepruck ปีที่แล้ว

    Thanks for this great tutorial.

  • @anilawasiya3642
    @anilawasiya3642 2 ปีที่แล้ว

    omg awesome content I am learning for my passion in physics

  • @develxper7931
    @develxper7931 2 ปีที่แล้ว

    This dude is an absolute legend

  • @attajilani
    @attajilani ปีที่แล้ว

    Impressive, wonderful python skills.

  • @renukavelu1701
    @renukavelu1701 3 ปีที่แล้ว +3

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

    • @renukavelu1701
      @renukavelu1701 3 ปีที่แล้ว

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

    • @pratyushprakashpatra7062
      @pratyushprakashpatra7062 2 ปีที่แล้ว

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

  • @nobody2937
    @nobody2937 2 ปีที่แล้ว

    Excellent Tutorial .... Thank you ...

  • @rio_agustian_
    @rio_agustian_ 2 ปีที่แล้ว +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

  • @caiolaytynher5994
    @caiolaytynher5994 2 ปีที่แล้ว +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  2 ปีที่แล้ว +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 2 ปีที่แล้ว

      @@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.

  • @Arkantosi
    @Arkantosi ปีที่แล้ว

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

  • @maksudulhossainjewel378
    @maksudulhossainjewel378 2 ปีที่แล้ว +1

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

  • @renzy4584
    @renzy4584 2 ปีที่แล้ว

    Amazing!! Some real stuff!!

  • @KylianMbappe07303
    @KylianMbappe07303 2 หลายเดือนก่อน

    54:45 for =anyone who didnt understand, learn aprtial derivatives and integration multivariable one is constant while other is changing and vise versa

  • @idotsameret5144
    @idotsameret5144 2 ปีที่แล้ว +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

  • @hsh7677
    @hsh7677 3 ปีที่แล้ว +2

    Thank you!!

  • @nicholas.hutton
    @nicholas.hutton 3 ปีที่แล้ว +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  3 ปีที่แล้ว +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 3 ปีที่แล้ว +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.

  • @nahblue
    @nahblue 2 ปีที่แล้ว

    In the eigenfunction problem, what do we do to make sure the bounardy conditions are fulfilled? They seem to be, but we don't do anything for it.
    Edit: it "comes from the matrix shape"; the first line of the matrix is just "-2f1 + f2" (with f0 missing). I see it now :)

  • @kevinsweeney2809
    @kevinsweeney2809 ปีที่แล้ว

    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.

  • @upgraduate
    @upgraduate ปีที่แล้ว

    Very good tutorial, thank you! I

  • @TheGmr140
    @TheGmr140 2 ปีที่แล้ว

    very helpful video, thanks for this. very nice

  • @diegofernandez8881
    @diegofernandez8881 3 ปีที่แล้ว +2

    Thanks, and please continue (:

  • @Ligress
    @Ligress ปีที่แล้ว

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

  • @rubayetalam8759
    @rubayetalam8759 2 ปีที่แล้ว

    at 22:50 if endpoint=True in linspace() why should we consider the N+1 value?

  • @rasin9391
    @rasin9391 2 ปีที่แล้ว +2

    love the camera dude

  • @sasikanth3147
    @sasikanth3147 2 ปีที่แล้ว

    Hello Mr.P solver, if it is not much could you do an vedio to explain how to write the Mathematical Expressions in symbolic form for example you wrote sigma, epsilon and others as such. I know I am asking much but I will Highly appreciate your effort thank you in advance

  • @shivpratapsingh5766
    @shivpratapsingh5766 3 ปีที่แล้ว +1

    You are a legend

  • @user-ek6rf7dw5d
    @user-ek6rf7dw5d 10 หลายเดือนก่อน +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.

  • @mariomuysensual
    @mariomuysensual 2 ปีที่แล้ว

    You are amazing dude

  • @haliluya4217
    @haliluya4217 ปีที่แล้ว

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

  • @robbietorkelsonn8509
    @robbietorkelsonn8509 2 ปีที่แล้ว

    x = np.linspace(1,10,100)
    f=vectorize(lambda x: 1/x**2 * np.sin(x))
    dxdy=gradient(f(x), x)
    that is where the vectorize comes in

  • @anupkulkarni6986
    @anupkulkarni6986 10 หลายเดือนก่อน

    Hey man ,you got one new subscriber 😊

  • @dejenewoldeyes4184
    @dejenewoldeyes4184 2 ปีที่แล้ว

    I am struggling define function to uniform random distribution, to count the the number of point in circle from the rectangle.

  • @sabagolshahi
    @sabagolshahi 2 ปีที่แล้ว

    Hi Luke! Thanks for the awesome to-the-point video. I've got a question for you wrt the last part of the first question which was to find the roots. Although the method is clever, it seems there can be some concerns regarding the result. Does this method assume that none of the discrete elements of x are the roots? because if this becomes the case, it seems that the point will be neglected (due to the < 0 condition) which does not seem so elegant. If we change the condition to

    • @sabagolshahi
      @sabagolshahi 2 ปีที่แล้ว

      Moreover, in question 4, I believe there is no match between the what you asked and what you plotted which I find not that nice. Moreover, I think the last formula in the question ( E(t)=Integral.... ) is not a correct formula and is weird. IMO, there was no need to use t' here since E is a function of t. In the solution, all t variables could be replaced by t' and then the t' replaced by kt.

    • @MichaelJGruber
      @MichaelJGruber 2 ปีที่แล้ว

      If none of the consecutive values is 0 then none of the x positions is a root. Assuming the evaluated function is continuous, there has to be one in between (by the intermediate value theorem), and any of the two x positions is an approximation within the accuracy given by the original spacing. This is accepted, of course, and without further information you can at best take the mean of the two positions in order to double the "precision".
      The same precision argument is true for the case where you (numerically) hit a zero. You are correct that

  • @user-we6mf5bn4m
    @user-we6mf5bn4m ปีที่แล้ว

    This is Awesome !!
    Science girls should be in looove

  • @NTC
    @NTC 2 ปีที่แล้ว +3

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

  • @ramacharan2825
    @ramacharan2825 ปีที่แล้ว +1

    thanks yu sooo much ,you are awesome .