![Bobater](/img/default-banner.jpg)
- 2
- 143 077
Bobater
United States
เข้าร่วมเมื่อ 20 ก.พ. 2023
This is a channel dedicated to teaching and exploring Math and Computer Science concepts in a way that's engaging and easy to understand for everyone.
How can Computers Calculate Sine, Cosine, and More? | Introduction to the CORDIC Algorithm #SoME3
In this video, I'll explain the motivation for an algorithm to calculate sine, cosine, inverse tangent, and more in a fast and efficient way. I'll cover topics like geometry, calculus, and computer science to explain where and how these ideas are developed.
Music by Vincent Rubinetti
Download the music on Bandcamp:
vincerubinetti.bandcamp.com/album/the-music-of-3blue1brown
Stream the music on Spotify:
open.spotify.com/playlist/3zNK20qC96mVSww60lVi1k
Music by Vincent Rubinetti
Download the music on Bandcamp:
vincerubinetti.bandcamp.com/album/the-music-of-3blue1brown
Stream the music on Spotify:
open.spotify.com/playlist/3zNK20qC96mVSww60lVi1k
มุมมอง: 141 211
วีดีโอ
What Does it Mean to Change the Base of a Number? | An Introduction to Binary and Hexadecimal
มุมมอง 2Kปีที่แล้ว
In this video, I'll cover how numbers can be represented in different ways using different base systems, and what makes those systems so useful. Music used is from: th-cam.com/video/m8IRu3lEUPs/w-d-xo.html Outer Wilds Soundtrack Piano Cover
May I know if this algorithm is better than Taylor series computation of sine and cosine?
Lol I think I just visualised the Taylor series expansion of the functions
I entered with a question, the video title, I exit with another, how computers calculate the trigonometric values (without another trigonometric function)?
Even if the terms of a series are gradually getting smaller when n is getting bigger, the series can diverge. For example, the harmonic series (1/n) diverges even though the sequence 1/n converges to 0. In fact, if a series converges, then the corresponding sequence converges to 0. But, if a sequence converges to 0, the corresponding series can either converge or diverge.
Unfortunately, the setup was just a bit too complicated here
Back when I was first learning to program (using C++), I was so enthusiastic that I wanted to make my own command-line calculator. At first I made it using just basic arithmetic operations. And then later on I added trig functions (along with the other typical math functions). But at the time I didn't know the standard library already provided built-in sine/cosine/tangent functions, so I ended up writing my own rudimentary ones using Taylor's series approximations 😅
Nope. I give up. Ill never get trig
Not even clarity makes me get it
Wait this looks like physics diagram... Oh. Oh my god. Anyways, its a/theta. It came to me in a dream today around 6:00 at morning.
Nah imma just use ((n-2)*180°)/2 For my angles. Oh, rotation? Just multiply the variable
7:30, well multiplication speed is relative. In x86 floating point multiplication takes the same number of cycles as addition.
W VIDEO
Quick question. I was wondering if computers could use the complex plane to rotate points(by multiplying complex numbers), instead of using a rotation matrix. Is there a reason this isn't used?
Very interesting. Is that how scientific calculators do this kind of calculations? Like the venerable TI-30?
In the old days, i calculated the Arctan in assembler using a the CORDIC. There is a mathematical proof of the CORDIC somewhere.
Thank you for this lesson. I learned something beyond my capability. You forgot to mention the software you use to make those circles and triangles.
This is cool stuff. Highly advanced for rocket engineers.
Super interesting, I always wondered how CORDIC worked. Question, though, at 12:19, I'm not sure that the ratio of a[n+1]/a[n] is really sufficient to prove convergence, since the latter terms of the harmonic series (1/2 + 1/3 + 1/4 + ...) satisfies that test but still doesn't converge. Maybe I'm missing something though. Anyways, great video!
Thanks for watching! The key with the ratio test is that we’re evaluating the ratio as a limit as we approach infinity. For the harmonic series, that ratio approaches 1 as we approach infinity. Since the ratio isn’t less than 1, the test does not tell us that the terms of the harmonic series are shrinking relative to each other at the limit, and therefore doesn’t imply that the harmonic series converges, which is why there is no contradiction in using the test
how do you keep track of what theta is in order to compare it to the target angle? i understand how you track the x and y coordinates, but not the angle.
Good question! We can store the total angle that we’ve rotated by in memory. Each time we iterate the algorithm, we can add or subtract the angle that we’ve just rotated by with our total angle so that we know what angle we are currently at and can compare it with the target angle.
thanks for your response. my confusion was more about how you actually know what angle you're adding, since we only know them as arctan of 2^{-k}, not an approximate decimal value which we could sum and keep track of. do you just start by calculating decimal approximations of arctan(2^{-k}) in some other way for a sufficiently large number of values of k, and then storing them for use in the CORDIC algorithm?@@bobater
Yep that’s exactly right! We can pre calculate the angles using some other method and then store them in a lookup table in memory which we can reference while using the algorithm
I've been trying to find this. Thanks!
This video is AWESOME
Multiplication is not repetitive sum
i found my own method for calculating cos(x) 1.choose accuracy n 2. divide the input number by 2^n-1 3.square the number and subtract 2from that 4. repeat 3 n times 5.divide the answer by two this works due to the double angle formula and chebesev polinomials
not well explaind. There are other videos with this topic and much easier explaind.
I'm really impressed. I'm currently implementing a cordic calculation in an FPGA. Both HLS and HDL implementations for two separate projects, but i have to admit this was a great refresher. Please keep it up. You're doing gods work.
I was disappointed that this did not receive a mention in the final announcement. I hope you continue to make videos though.
can you make one explaining how a logarithm is calculated? ive always wanted to know
13:10 technically this statement is incorrect and the harmonic series is a popular counter example. Awesome video though!
Ahhhh this video was so confusing! 1. At 7:18, you say that because we have the rotation matrix, "we have a way to rotate vectors and get their x and y coordinates after we rotate them" (correct) "...that gives us our sine and cosine" BUT the rotation matrix requires that we calculate sine and cosine! I don't understand why we're any better off at this point. 2. Was the motivation behind why we're adding successively smaller angles to an initial 45° ever explained? I don't see what doing that is giving us and I feel like it's probably a crucial part of this algorithm. Is it that you precalculate the terms of the summation AND their sines and cosines? Then you can just store those in a list and easily plug them into the rotation matrix? I appreciate the video but feel that this key point could have been explained a little more in depth.
Really appreciate your feedback. This was my first real attempt at making a video explaining a topic not many people had seen before. When I made this video, I had about 6 subscribers, so the amount of people I expected it to reach and the quality standards I set for myself were somewhat low. If I have time, I might make another version of this video with all of the feedback I got and mistakes I made in mind, but I am pretty busy right now so I’m not sure if/when that will happen.
Warning: unless you've had a Calculus II class (infinite series, product sums, l'Hopital's Rule, etc.), this will be over your head. Otherwise, this is a good video.
Shrinking terms is not sufficient. Look at sum(1/n,n,1,m) ≈ log(m)+g
This is awesome and so are you!!! Excellent graphics and clear explanation!
Thanks.
I didn't understand how should we get tan(x) values? Have we a precalculated table of tan(45), tan(22.5) ... ?
Really cool entry P.S. love the effort in the 8 bit computer you made. I have seen ben's series on it
did anyone else find it hard to follow, or am i just dumb
If K is constant, start at (K,0) and remove one multiplication.
16:44 The numbers on the right don't match the drawing on the left. That's more like 1 or 2 degrees, not 36 (I assume you mean degrees here but it's not indicated)
The number on the right is actually the total angle we've rotated the vector by up until this point, not the current angle the vector makes with the x-axis. Also yes, this is measured in degrees not radians.
One that's fun to play with is base64, since you can use different dictionaries to do the translation. The standard dictionary for internet communications just seems wrong to me, so for my own personal use, as in it doesn't need to be decoded by anyone else, I'll use [0-9a-zA-Z\-+] which are even safer for URL encoding due to the lack of a /. Note that I don't use a \ literally, it's escaping the -. Now I'm going to play with some math and see if I can finally understand how sine and cosine were derived generically.
I think you've just given me the insight I needed to figure out how the equations were derived in the first place. Taking the simple ratios of a unit circle and making them more complicated by stepping makes so much sense I don't know why I didn't think of it before, but hopefully I'll build up a better understanding of math because of this.
CORDIC rotations first used in HP35 calculator?
No, many years ago before: in 1956 in DIVIC.
Hey Bobater, great job! I was wondering if any of this might help explain the super cool phenomenon of tan 89, tan 89.9, tan 89.99, etc. Why they keep going up by factors of 10 has always been something I've been curious about.
It's easier to see when you convert them contangents using the fact that cot x = tan(90-x). This results in cot 1, cot 0.1, cot 0.01. They approximately scales by factor of 10 is because cot x is close to 1/x for small x, using sin x ≈ x and cos x ≈ 1.
in practice, if you alredy have microcomputer capable of simple operations then you should use polynomial approximation of sin/cos up to 5th power for sine(3 terms) and 4th for cosine(constant + 2 terms). it is pretty fast and uses only couple multiplications and additions.
Yes if you have access to fast hardware multiplication it’s usually better to use a polynomial based method rather than CORDIC. CORDIC is a better method on computers without access to fast hardware multiplication.
Very good Video really. But out of the eye of a newbie to Math and Computersince i would like to know why we need to do it this way. So why is this such a big problem for Computers in the first place ;) .
Well, think about it. How would you go about computing sin(x) if you had to do it yourself? Since sin(x) is a transcendental function, we need to use something like an infinite series or some approximation to actually calculate it. We can’t actually add infinite terms though, and often the terms of the series are expensive to compute. This is where the challenge lies and what led to the development of algorithms like CORDIC and other approximations.
This is a really nice video. I am excited about the content on this channel because it corresponds well to the content on my new channel. Your video is very professional and easy to understand - a feat considering the content. One quibble: the part about convergence misses a really important point - you need to cover all possible values. It turns out that the atan(.5^n) basis works, but not because the rate of converge is 0.5. For example, tan (pi/4*(.5^n)) would have the same asymptotic rate of convergence but leaves the range of computable values a Swiss cheese of holes. The property you need is sum of all remaining basis numbers must equal or exceed the last included basis number.
Good point. I'll admit this is something I missed when researching the video, but it makes intuitive sense as to why that property needs to be satisfied. Thanks for bringing this up.
Thank you for the information.
Thanks for this! I've been meaning to understand CORDIC for a while but there's just too much fluff/ computer science background that I couldn't be bothered to read into. This cuts right through all the fluff (especially the (1/2)^n series at the beginning of the video) and helps me understand it!
That was exactly my goal in making this video, to just present the ideas and motives behind CORDIC without going too far into the technicalities of it. Glad you liked it!
Glad to be here before this channel blows up. Such amazing visuals and intuitions are a scarce thing
Kudos. This is one of my favorites of this SoMe so far.