Calculating Weird Trig Values
Drawn by me on Piskel. |
How do calculators calculate irrational values and trigonometric values? Is the calculator programmed with a giant table with all the values of, say, sine, and when you ask it for the sine of 5, it looks it up? Maybe, but what if you asked it something really weird, like the cos(-57/ln3.2) or e^2.74? It's irrational that a calculator would just happen to have all those numbers and their corresponding values stored inside. Besides, if it did, where would they even come from?
Calculators use something called a Taylor Polynomial to estimate values like those stated above. Let's see how it works.
First, let me show you something interesting. This is sine.
All graphing screenshots are of desmos.com |
It really is.
Alright, alright, here's the trick: it's just zoomed in really close. If you notice the x and y values, they are all less than 1 away from zero.
So we can conclude that when x is really close to zero, y=x is a pretty dang good approximation of sin(x). When x is past 0.5 and -0.5, the two lines start diverging.
Use the function y = sin(x) - x
Hmm... Look familiar?
It's -x^3 multiplied by some constant to make it wider. A fraction, you conclude. After some fiddling, you find out that -(1/6)*x^3 works pretty well. Let's see how far that brings our approximation to.
Pretty nice, pretty nice. Now, the accuracy starts tapering off around 1.0 instead of 0.5.
If you repeat the cycle of finding the difference and adding another chunk of math to the approximation, you'll end up with this nifty equation:
(Red is sine and purple is the sine approximation.)
You can get pretty far by finding the difference and using guess and check to find the best denominator, but it'll get pretty tedious. It would be really sweet if there was, say, a pattern.
Thankfully, there is one. Notice how the 3 corresponds to 6; 5, 120; 7, 5040; 9, 362880? It's factorials!
The Taylor Polynomial, what this estimation equation is called, follows this pattern:
From Wikipedia |
- f(a) is the function
- f'(a) is the first derivative, f''(a) is the second, and so on
- a is where the polynomial is centered
- x is the value, plugged into f(x) that you want to find
- the closer x is to a (read: the closer the value you plug in is closer to where the polynomial is centered), the more accurate your approximation will be
You might be wondering why the sin(x) function we approximated in our example only has odd-powered x's and there is no (x-a).
That's because the "a" we used in the example was zero, so ever even-valued derivative of f at a is zero. In people speak, that means that sine is always zero at zero. And even-numbered derivatives (the second derivative, fourth derivative, and even no derivative aka zero) are always in sine, not cosine (which the odd-numbered derivatives are in which is why the numerator is always one in the example).
Since a = 0 in the example, (x-a) evaluates to simply x.
By the way, remember that this is an approximation! Use those squiggly approximation lines instead of the actual equal sign.
These squiggly lines. (Thanks, Wikipedia) |
Anyway, that's the Taylor Polynomial, and it is used to approximate sine, cosine, tangent, e, and other "weird" math.
—Stang
Subscribe to:
Posts
(
Atom
)
No comments :
Post a Comment
Please be appropriate and respectful.