def newtons_method(func, funcderiv, x,n): def f(x): f=eval(func) return f def df(x): df=eval(funcderiv) return df for intercept in range(1,n): i= x - (f(x)/df(x)) x=i print(f"The root was found to be at {x} after {n} interations") newtons_method("x**2-2", "2*x", 2, 10) newtons_method("x**2-2", "2*x", -10, 10)
@ash-lo2dc2 жыл бұрын
alternatively you can evalutate the derivative using f(x+h)-f(x) / h and set h = 0.0000001 instead of manually putting the derivative function its an approximation but it will do the job
@NakulPatel-sd6uk2 ай бұрын
you can also use autograd library of python.
@AJ-et3vf2 жыл бұрын
Nice! I'm happy to have watched this. I learned something new about Python specifically the eval function ❤️❤️
@arianghanbari13492 жыл бұрын
Thank you so much , that was so helpful.
@kavishkadilharawickramasin47262 жыл бұрын
I love this video ❤️❤️❤️. Thank you so much. Learned a lot.
@philipp-w7 ай бұрын
Hey, great video and thanks for the help! Quick question: What theme do you use? It looks really good and a bit more colerful than dracula
@quailegg55142 жыл бұрын
dude you are saving me here. thank you!
@AsasinHD2 жыл бұрын
Good video, it helped me a lot. U don't have newton raphson videos?
@StudySessionYT2 жыл бұрын
This playlist is still a work in progress so more videos to come!
@maximilienfrancoismarieisi11829 ай бұрын
Thank you so much, mate ❤
@user-xo1on3hp4e2 жыл бұрын
you help me thank 😊 very much
@fezkhanna69002 жыл бұрын
Awesome!
@antekkalafior2 жыл бұрын
Is there a chance of you making a video about fixed-point iteration method? I would really like to see you explain this
@jenna7180 Жыл бұрын
I keep coming across an issu where I have to define "n" to allow the function to run. Do you know why that is happening nd how to fix it
@HenioGracie2 жыл бұрын
Hello. Is there a way to omit the parentheses in a code, since i want to use this code in dataframes. I cannot do it really with parentheses, at least i dont know how to. Thanks in advance
@cjlimps89712 жыл бұрын
good day! is this newton raphson method? its looks the same with it
@arsyactivity95422 жыл бұрын
Wow
@cansadececan12073 ай бұрын
Bulduysan ben de seni çok seviyorum
@Leo-io4bq2 ай бұрын
okay now multidimensional
@cansadececan12073 ай бұрын
Merhaba canım ❤🙌
@mcgamescompany2 жыл бұрын
"Although this may not be the most efficient way..." Me after writing a 130 line, messy code, to make a system that reads functions but only polynomial ones, founding that there's already a function that does exactly that but better: ...bruh