Finding Zeros of Functions In Python (Bisection Method and Scipy)

Поделиться
HTML-код

Комментарии • 61

  • @cicciobombo7496
    @cicciobombo7496 6 лет назад +39

    If you replace tol with 0 in the if else statement you get a much better accuracy

    • @AndrewDotsonvideos
      @AndrewDotsonvideos  6 лет назад +8

      Good catch! Thanks!

    • @zuzannagembus882
      @zuzannagembus882 4 года назад +1

      @@AndrewDotsonvideos Where exactly? In 6:47?

    • @pengjieren9601
      @pengjieren9601 3 года назад

      @@AndrewDotsonvideos lol, i was wondering that

    • @mpperfidy
      @mpperfidy 2 года назад

      @@AndrewDotsonvideos You are near-criminally underfollowed. Always interesting content.

  • @DragasGaming
    @DragasGaming 6 лет назад +21

    You're doing gods work. Please more python videos.

  • @noellundstrom7447
    @noellundstrom7447 6 лет назад +13

    You really got to the root of my issue Andrew, thank you!

  • @williambrunosalesdepaulali6582
    @williambrunosalesdepaulali6582 2 года назад

    Here i am discovering your channel again after so many years hahhas. Awesome!

  • @aliciaroberts3965
    @aliciaroberts3965 2 года назад

    This really helped me finish my python hw I put off to the last minute, so thank you!

  • @muhammedabdulmalik3687
    @muhammedabdulmalik3687 2 года назад

    Great job! You dissected it very well.

  • @robertjcliu
    @robertjcliu 3 года назад

    I am watching your tutorial in Taiwan. Thank you.

  • @ferns191
    @ferns191 4 года назад

    Thank you so much!! You made this so easy to understand

  • @JoseGonzalez-cb2gw
    @JoseGonzalez-cb2gw 3 года назад

    Thank you very much, excellent explanation of the procedure

  • @galenseilis5971
    @galenseilis5971 5 лет назад +16

    You can use "elif" instead of nesting "if" inside "else".

  • @kamehamehaDdragon
    @kamehamehaDdragon 5 лет назад

    I love this kind of videos!

  • @DRNi23
    @DRNi23 4 года назад

    Useful video! Thank you!

  • @calebwhales
    @calebwhales 6 лет назад +1

    Love the python videos mate

  • @uaenaarmy-enhyFim
    @uaenaarmy-enhyFim 5 лет назад

    Thank u! U saved my life

  • @ulilhidayat7467
    @ulilhidayat7467 4 года назад

    Yuu're doing gods work, thanks

  • @danielriquelme5766
    @danielriquelme5766 4 года назад

    I like your binary search xD good video

  • @bishwasgnawali
    @bishwasgnawali 5 лет назад +3

    Can you use this method to find a complex root of a complex function?

  • @al-washisarkerturan8913
    @al-washisarkerturan8913 3 месяца назад

    Described very well

  • @jptuser
    @jptuser 4 года назад +1

    what's the use of the tolerance ??? we did the same code in fortran for computational physics but didn't understand that tolerance

  • @aureeel
    @aureeel 3 года назад +1

    Please do more python videos, you make it so much easier to understand

  • @janlhesternavasca3160
    @janlhesternavasca3160 3 года назад +2

    What if you have two roots?

  • @QsHsNation1
    @QsHsNation1 6 лет назад

    Did you learn how to use python for physics mainly on your own or did your courses help you develop those skills? I'm going into my Junior year of physics (Quantum and Thermo this year!) and also starting my minor in comp sci, and I have very little knowledge of coding. Been trying to find resources online for learning to code for math and physics and what not, but i've been unsuccessful lol. We do have a course that works with coding for physics at my uni which I'll probably take next semester or next year. Just want to get ahead of the game though to be valuable during research.

    • @DrHami
      @DrHami 6 лет назад +2

      Computational Physics by Nicholas J. Giordano is a great textbook that may help you "learn to code for math and physics." I suspect that you already know, more or less, how to code a simple program (there's a shitload of resources for that), but you don't have experience in solving physics/math problems numerically. If that's the case, then that textbook might come in handy. (There's many ways to get that book online without paying a dime >_>)

    • @QsHsNation1
      @QsHsNation1 6 лет назад

      Thank you! Yeah, I understand the basics of coding, just don't know how to use the tools of it to solve problems. Alot of the libraries he imported in this video like matplotlib i didn't have so I guess I gotta figure out how to obtain that lol. I'll go check out that book *cough cough* by "purchasing it" *cough cough.

  • @brianbecsi7482
    @brianbecsi7482 4 года назад +1

    you call me smart... it goes straight to my head

  • @mqfkkc6621
    @mqfkkc6621 3 года назад

    hi, may i ask if there is another possible way to get two roots without using fsolve?

  • @kanadkrishanusengupta2578
    @kanadkrishanusengupta2578 4 года назад

    Which is the best book to learn numerical analysis ?????

  • @johnchristian5027
    @johnchristian5027 6 лет назад

    Nice!

  • @GavinCOC
    @GavinCOC 5 лет назад

    thank you!!

  • @arthurheinrich723
    @arthurheinrich723 Год назад

    In the bissection method, if values "a" and "b" are root, or any "c" value makes f() function returns zero, the routine enter in an infinite loop

  • @phvisser1
    @phvisser1 2 года назад

    how do you get 2 answers for x with the bisection method?

  • @aniruddha4672
    @aniruddha4672 4 года назад

    more python videos pls!!

  • @iamwhitewhale
    @iamwhitewhale Год назад

    do u guys have any idea why my code isn't working? after running the code a star will appear in left side and then nothing, i need to re-run the jupyter.

  • @megabyte3348
    @megabyte3348 3 года назад +1

    Hello! Is there any book or free course that explain numerical methods in a simple way? What do you recommend?

    • @thisisFaye1
      @thisisFaye1 2 года назад +2

      I'm using Computational Physics by Mark Newman right now and I find it's my most useful textbook. There are some accompanying materials posted by the author for free online.

    • @muhammedabdulmalik3687
      @muhammedabdulmalik3687 2 года назад

      How can I get a pdf version please?

  • @asifmahmud6331
    @asifmahmud6331 4 года назад

    If I put "c = (xl + xr) / 2" line outside the while loop (just after xr = b), it takes forever to run. Can you tell me why is that?

    • @johnjohnerd6921
      @johnjohnerd6921 4 года назад +1

      if you define c before the loop starts it will never get updated and therefore the greater than/less than conditions don't effect c.

  • @speedspeed121
    @speedspeed121 6 лет назад +6

    Could you do Newtons method in Python?

  • @young_la_flame
    @young_la_flame 3 года назад

    I was searching how to do the bisection search.
    how did I ended up here.

  • @theflaggeddragon9472
    @theflaggeddragon9472 6 лет назад +1

    If there are multiple roots, the algorithm works regardless, you'll just find one of the roots instead of multiple. You could then search the other intervals by a bisection method to make sure you haven't missed any? (This doesn't work for arbitrary functions since you don't know when to stop, but polynomials, which have at most n roots for degree n, this would work pretty fast I think).

  • @anatolyrozhkov851
    @anatolyrozhkov851 4 года назад +1

    8:00 How on Earth the first function and the second are connected? How does the bisection function understands that it needs to find a different root when the f(x) is changed to the quadratic????!!!

    • @UmurCanKaya
      @UmurCanKaya 4 года назад +1

      If the interpreter can't find an object inside the function it starts to look for it in the main code. It would be much safer to give f as an argument of the bisection function.

  • @abhishankpaul
    @abhishankpaul 11 месяцев назад

    I had tried so much to find roots of Bessel functions of 1st,2nd or 3rd order, everytime the code screwed up things

  • @nitindogra6195
    @nitindogra6195 Год назад

    hey at 2:18 shouldn't it be () ? or may be i need to re-understand this, thanks

  • @alexanderrobertson5530
    @alexanderrobertson5530 6 лет назад

    Hey, Andrew I had an idea and I would like your input on it. I could be completely and utterly wrong, but I can't shake the idea so I want someone who knows some QM and SR to give me some feedback. Quantum field theory describes antimatter as matter moving backwards through time. If you look at a Feynman diagram of a matter-antimatter annihilation event the antimatter is described as moving in the negative time direction well matter goes in the positive time direction while being mediated by force carrying bosons. This is considered a mathematical trick that has no physical significance and leads to wacky joke theories like the one electron universe theory. Well what if antimatter is just regular matter that is tachyonic. Tachyons are a mathematical trick with lorentz transformations. You can't approach the speed of light because it requires infinite energy to get to because when v = c the entire equation is dividing by 0. Well if you approach it from the opposite direction so you start off being faster than the speed of light then it requires infinite energy to slow down for the exact same reason you can't speed up to being faster than light. When you do this you end up dealing with the square root of a negative number so an imaginary number. Well, we all know that travelling faster than the speed of light is equivalent to travelling backwards in time then is it possible that antimatter is simply the tachyonic equivalent of matter. If you trace a tachyonic worldline it reverses the direction of time. In QFT a little mathematical quirk is just considering antimatter to be time reversed matter so it is just regular matter travelling backwards through time just like a tachyon would. Thanks for any input.

  • @PauloVictor-hp9op
    @PauloVictor-hp9op 4 года назад

    how can i proceed to find all roots of a function in some range (or interval)?

    • @PauloVictor-hp9op
      @PauloVictor-hp9op 4 года назад

      fsolve can give us roots just in specified point (guesses).

  • @asratmekonnenbelachew6225
    @asratmekonnenbelachew6225 4 года назад

    Please it does not work for the function 2*x**2 - 5*x + 3 with xl=0 and xr=1.3. In this case, our solution must be x=1
    but using this code, we have the answer
    # Let assume that the root is found between x1=0 and x2=1.3
    x1=0
    x2=1.3
    y1=2*x1**2 - 5*x1+3
    y2=2*x2**2 - 5*x2+3
    if y1*y2>0:
    print("the root is not found in the interval")
    exit
    for bisection in range(1,101):
    xh=(x1 + x2)/2
    yh=2*xh**2 - 5*xh+3
    y1=2*x1**2 - 5*x1+3
    if abs(y1)

  • @supercat908
    @supercat908 2 года назад

    Ben Affleck doing python tutorials?

  • @ariusmaximilian8291
    @ariusmaximilian8291 6 лет назад

    first

  • @jnscollier
    @jnscollier 5 лет назад

    Thanks Ryan Reynolds

  • @googlegoogle1610
    @googlegoogle1610 2 года назад

    there is always one typo hhhhhhhhhhhhhhh at least :)

  • @valentinewiggin9705
    @valentinewiggin9705 4 года назад

    this code is so bad...