Earlier quoted context omitted.
If you just see the conclusion I think it's hard to immediately grok how rotation can arise from this. This is a great technique for cheaply doing 3D starfields etc on 8-bit machines. Look ma, no sine table!
A related interesting fact is that small angular motions compose almost like vectors, order does not matter (i.e. they are commutative). This makes differential kinematics easier to deal with when dealing with polar or cylindrical coordinate systems. Large angular deflections while being linear transforms, do not in general commute. It will spoil the linear relation in your elegant expression, but a slightly better a…
Even faster asin() was staring right at me
51–60 of 68 posts
Re: Even faster asin() was staring right at me
#52Earlier quoted context omitted.
> In what way do you think a sin function is computed? In some way vaguely like this: https://github.com/jeremybarnes/cephes/blob/master/cmath/sin... > I think it is stored like sintable[deg]. The degree is index. I can think of a few reasons why this is a bad idea. 1. Why would you use degrees? Pretty much everybody uses and wants radians. 2. What are you going to do about fractional degrees? Some sort of interpreta…
It isnt good idea to store such values in code. I think it is something that computed when a programming environment is booting up. E.g. when you run "python", or install "python". I try to understand how Math.sin works. There is Math.cos. It is sin +90 degrees. So not all of them is something that completes a big puzzle.
Re: Even faster asin() was staring right at me
#53The coefficients given are indeed a near-optimal cubic minimax approximation for (π/2 - arcsin(x))/sqrt(1-x) on [0,1]. But those coefficients aren't actually optimal for approximating arcsin(x) itself. For reference, the coefficients given are [1.5707288, -0.2121144, 0.0742610, -0.0187293]: if we optimize P(x) = (π/2 - arcsin(x))/sqrt(1-x) ourselves, we can extend them to double precision as [1.5707288189560218, -0.2…
Adjusting the "1" upward in sqrt(1-x) does not seem to help at all.
Re: Even faster asin() was staring right at me
#54A notable approximation of ~650 AD vintage, by Bhaskara is ArcCos(x)= Π √((1-x)/(4+x)). The search for better and better approximations led Indian mathematicians to independently develop branches of differential and integral calculus. This tradition came to its own as Madhava school of mathematics from Kerala. https://en.wikipedia.org/wiki/Kerala_school_of_astronomy_and... Note the approximation is for 0 If I remembe…
Re: Even faster asin() was staring right at me
#55A notable approximation of ~650 AD vintage, by Bhaskara is ArcCos(x)= Π √((1-x)/(4+x)). The search for better and better approximations led Indian mathematicians to independently develop branches of differential and integral calculus. This tradition came to its own as Madhava school of mathematics from Kerala. https://en.wikipedia.org/wiki/Kerala_school_of_astronomy_and... Note the approximation is for 0 If I remembe…
Clearly India history has a lot to say about mathematics but I don't think they get enough attention. Or am I just ignorant and living in my own bubble? Indian philosophy is also very intriguing.
Re: Even faster asin() was staring right at me
#56This precisions should be measured in avg and worst ULP, not in "charts". A good approximation should also give exact results in critical points (-1/0/-1 in this case).
The "faster" version gives this:
asin(0) = 6.75268e-05 (double precision)
Which gives around 5e+15 ULPs, while common libc math implementations targets 19 ULPs (but will be 0 for asin(0)).Re: Even faster asin() was staring right at me
#57The coefficients given are indeed a near-optimal cubic minimax approximation for (π/2 - arcsin(x))/sqrt(1-x) on [0,1]. But those coefficients aren't actually optimal for approximating arcsin(x) itself. For reference, the coefficients given are [1.5707288, -0.2121144, 0.0742610, -0.0187293]: if we optimize P(x) = (π/2 - arcsin(x))/sqrt(1-x) ourselves, we can extend them to double precision as [1.5707288189560218, -0.2…
Re: Even faster asin() was staring right at me
#58A notable approximation of ~650 AD vintage, by Bhaskara is ArcCos(x)= Π √((1-x)/(4+x)). The search for better and better approximations led Indian mathematicians to independently develop branches of differential and integral calculus. This tradition came to its own as Madhava school of mathematics from Kerala. https://en.wikipedia.org/wiki/Kerala_school_of_astronomy_and... Note the approximation is for 0 If I remembe…
Clearly India history has a lot to say about mathematics but I don't think they get enough attention. Or am I just ignorant and living in my own bubble? Indian philosophy is also very intriguing.
Lot of interesting mathematics was done by Indians, Persians, Arabs, Mayans.
Indian mathematics has an additional layer of obscurity. Very little was written down and when it was it was written down in picturesque and poetic verses (as a mnemonic device) that used a lot of symbolism and imagery. For the number one they will mention the Sun, for two the moon and so on, these mappings would also change from work to work, chapter to chapter. So one needs a lot of context to understand what a document is saying.
For example the source of the approximation above is described as follows (literal translation) [1]
The degree of the arc, subtracted from the total degrees of half a circle, multiplied by the remainder from that [subtraction], are put down twice. [In one place] they are subtracted from sky-cloud-arrow-sky-ocean [40500]; [in] the second place, [divided] by one-fourth of [that] remainder [and] multiplied by the final result [i.e., the trigonometric radius].
[1] Kim Plofker, Mathematics in India.
Re: Even faster asin() was staring right at me
#59Earlier quoted context omitted.
> In what way do you think a sin function is computed? In some way vaguely like this: https://github.com/jeremybarnes/cephes/blob/master/cmath/sin... > I think it is stored like sintable[deg]. The degree is index. I can think of a few reasons why this is a bad idea. 1. Why would you use degrees? Pretty much everybody uses and wants radians. 2. What are you going to do about fractional degrees? Some sort of interpreta…
It isnt good idea to store such values in code. I think it is something that computed when a programming environment is booting up. E.g. when you run "python", or install "python". I try to understand how Math.sin works. There is Math.cos. It is sin +90 degrees. So not all of them is something that completes a big puzzle.
Re: Even faster asin() was staring right at me
#60The coefficients given are indeed a near-optimal cubic minimax approximation for (π/2 - arcsin(x))/sqrt(1-x) on [0,1]. But those coefficients aren't actually optimal for approximating arcsin(x) itself. For reference, the coefficients given are [1.5707288, -0.2121144, 0.0742610, -0.0187293]: if we optimize P(x) = (π/2 - arcsin(x))/sqrt(1-x) ourselves, we can extend them to double precision as [1.5707288189560218, -0.2…
How did you find out that his optimization was done for a different equation, just by trial?