@MIT i am using 2.7.2 and (as far as i can tell) i copied this exact equation but if i typed in sqrtbi(9, 0.0001) my result was 2.25, then i typed in sqrtbi(25, 0.0001) my result 6.25... can some one examine my copied program and tell me what mistake i have maid?
@prithudak1 thank you for trying to explain although honestly I didn't quite understand the use of n. However, as you recommended, Wikipedia did help me solve it! so thanks again :)
Should I be worried if some of this is confusing to me? I'm just learning Python for the first time and watching these lectures alongside reading the Python edition of How To Think Like A Computer Scientist - I have lots of knowledge but no way to put stuff together yet.
I'm also not very good at math and trying to remedy that, so the bisection method section was a bit confusing.
@Faffel Have you ever tried using project Euler? It's a great source for beginners to learn some number theory while developing their programming skills (e.g. find all the pythagorean triples between one and ten thousand). The problems get quite challenging if you don't use all of your resources. For many of them, you can adapt an old program to fit the needs of a new problem, developing your editing/optimization skills at the same time.
IIRC It's implemented as an array of pointers to the values, that's why it can be heterogeneous; e.g. a python list of [ 1, 42, 'baa', 0.0001] is valid.
It's similar in use Lisp lists but implemented differently (and actually more efficiently).
Nice lesson. However, the initial algorithm has a critical error when dealing with numbers less than 1. Applying max(x, 1.0) to initial guess is not sufficient to correct the problem because it's necessary to invert the logic when setting high and low variables. Choosing 0.25 for testing the algorithm worked but others numbers less than 1 should fail as that algorithm doesn't converge...
@oinocx Nope. sqrt(0.24) is 0.4898... which is less than 0.5 and so on. To make sure I didn't misunderstand you I tested the algorithm with 0.01, 0.02, ... 0.98, 0.99 and it worked nicely.
@oinocx@oinocx At first I thought yes you're right, but let me guess why your argument is invalid: You say one has to invert the logic when choosing new lower and upper bounds, but the if condition reads "if guess**2 < x" and because taking the square of a number between 0 and 1 actually makes it smaller, this problem is implicitly taken care of. cheers
How does one use the library of point values for the letters that is defined in the ps5 code they give? I've looked around Python's website, but I can't find anything.
The 'incorrect' square root wasn't a precision error, it was a typo. The program printed out that it taking the square root of 123456789 for both of them, but it was actually taking the square root of 1234567890 for the first one.
well it apears asthough youtube thinks im trying to hack so i cant post the code
brassmonkey9871 1 month ago
@MIT i am using 2.7.2 and (as far as i can tell) i copied this exact equation but if i typed in sqrtbi(9, 0.0001) my result was 2.25, then i typed in sqrtbi(25, 0.0001) my result 6.25... can some one examine my copied program and tell me what mistake i have maid?
brassmonkey9871 1 month ago
Correction: the babylonians devised the method ascribed here to Newton-Rhapson, although it was only for the particular case of finding square-roots
iateyourgranny 1 month ago
Using Newtonian equation
a slope of tangent can be shown as dy/dx
dy is equal to f[x(n] - 0
dx can be represent as [x(n+1) - x(n)]
now use the algebra to get the value of x(n+1)
for more explanation search newton's tangent method in Wikipedia
prithudak1 2 months ago in playlist MIT 6.00 Intro to Computer Science & Programming, Fall 2008
@prithudak1 thank you for trying to explain although honestly I didn't quite understand the use of n. However, as you recommended, Wikipedia did help me solve it! so thanks again :)
scorpionismification 2 months ago
Does any one know how we get guessi+1 = (guessi-F(guessi))/2*guessi ? Thanks
scorpionismification 2 months ago
I'll be a genius in programming after I finish watching his lectures.
agapitoflores001 3 months ago 3
Thumbs up for the Macbook bashing at 26:10.
LarsYurich 4 months ago
dunno. cuz u want candy?
ILOVEANIMEHOPECARD 4 months ago
He throws candy.
ILOVEANIMEHOPECARD 6 months ago
@ILOVEANIMEHOPECARD Guess why I am admitting to MIT? ;)
someonep93 4 months ago
26:27 best part haha
epicnidhogg 6 months ago
Phew this lecture is a bit harder to wrap my head around. better see it again a few times xD
arngorf 6 months ago
oh my god, thanks to this videos I know I never want to study this, it is f** boring!!
a00225186 7 months ago
@a00225186 It's a class designed for total beginners at programming, it gets more interesting when you get to more advanced topics.
someonep93 4 months ago
the Python stuff kicks back in around 33:00
3djes 1 year ago 2
@3djes Thanks
Ironside451 8 months ago
@poopeatit
Ahh I see, thanks for the reply.
prodigypc 1 year ago
Should I be worried if some of this is confusing to me? I'm just learning Python for the first time and watching these lectures alongside reading the Python edition of How To Think Like A Computer Scientist - I have lots of knowledge but no way to put stuff together yet.
I'm also not very good at math and trying to remedy that, so the bisection method section was a bit confusing.
Faffel 1 year ago 5
@Faffel Have you ever tried using project Euler? It's a great source for beginners to learn some number theory while developing their programming skills (e.g. find all the pythagorean triples between one and ten thousand). The problems get quite challenging if you don't use all of your resources. For many of them, you can adapt an old program to fit the needs of a new problem, developing your editing/optimization skills at the same time.
Pichounator 8 months ago 2
Divide by zero @ 21:45
poopeatit 1 year ago
What does he keep throwing at the students?
prodigypc 1 year ago
@prodigypc he gives them candy for correct answers, usually misses
poopeatit 1 year ago
Is a list the same as an array in other languages, or is there some difference?
ntwiles 1 year ago
@ntwiles
IIRC It's implemented as an array of pointers to the values, that's why it can be heterogeneous; e.g. a python list of [ 1, 42, 'baa', 0.0001] is valid.
It's similar in use Lisp lists but implemented differently (and actually more efficiently).
I think it's explained in one of these lectures.
Uvthenfuv 1 year ago
This has been flagged as spam show
def SquareRootNR(x,epsilon): assert x >= 0, +str(x) assert epsilon > 0, +str(epsilon) x = float(x) guess = x/2.0 diff = guess**2 - x crt = 1 while abs(guess**2-x) > epsilon and crt <= 100: guess = guess - (diff)/(2.0*guess) diff = guess**2 - x crt += 1 assert crt <= 100 print 'NR method Num iterations:',crt,'Estimate:',guess return guess
SquareRootNR(5,1)
SquareRootBi(5,1)
raw_input()
SquareRootNR(5,0.0001)
SquareRootBi(5,0.0001)
Fensterplaetzchen 1 year ago
Fensterplaetzchen 1 year ago
It's great to learn new things the world is always evolving and new things appear
miguelantonio1975 1 year ago
I have to say that this series lectures gave me a different view of programming. It's always a good thing to learn more.
FMadot 1 year ago
Nice lesson. However, the initial algorithm has a critical error when dealing with numbers less than 1. Applying max(x, 1.0) to initial guess is not sufficient to correct the problem because it's necessary to invert the logic when setting high and low variables. Choosing 0.25 for testing the algorithm worked but others numbers less than 1 should fail as that algorithm doesn't converge...
oinocx 1 year ago 2
@oinocx Nope. sqrt(0.24) is 0.4898... which is less than 0.5 and so on. To make sure I didn't misunderstand you I tested the algorithm with 0.01, 0.02, ... 0.98, 0.99 and it worked nicely.
Uvthenfuv 1 year ago
@oinocx @oinocx At first I thought yes you're right, but let me guess why your argument is invalid: You say one has to invert the logic when choosing new lower and upper bounds, but the if condition reads "if guess**2 < x" and because taking the square of a number between 0 and 1 actually makes it smaller, this problem is implicitly taken care of. cheers
Fensterplaetzchen 1 year ago
I should go to MIT, so i can get free candy!
iamsoprocuziizpro 1 year ago 4
How does one use the library of point values for the letters that is defined in the ps5 code they give? I've looked around Python's website, but I can't find anything.
Jarke11 1 year ago
The 'incorrect' square root wasn't a precision error, it was a typo. The program printed out that it taking the square root of 123456789 for both of them, but it was actually taking the square root of 1234567890 for the first one.
RobCozzens 1 year ago 22
Nice lecture, AND getting more complicated as it goes on! :D
originamrversatility 2 years ago 4
Nice lecture, but getting more complicated as it goes on.
litotimmy 2 years ago
What languaje is that? C ++ ?
diegoramos27 2 years ago
Python
32koala 2 years ago 30
Comment removed
dingyihamigua 2 years ago
@diegoramos27 It's Python
MrDogbert2 1 year ago