News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Fast Sinus() and Cosinus() algos

Started by jj2007, September 10, 2015, 12:08:13 AM

Previous topic - Next topic

Farabi

Hi jj how much time it was called? Fsin was 100microsecond for 1 million loop. 358ms was too slow.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

jj2007

Quote from: Farabi on October 16, 2015, 11:22:40 PM
Hi jj how much time it was called? Fsin was 100microsecond for 1 million loop. 358ms was too slow.

Can you explain a bit what you are referring to?

Farabi

Edit:

Sorry I get a wrong perception.
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

Farabi

Quote from: jj2007 on September 10, 2015, 12:08:13 AM
Hi folks,
Just uploaded a new version featuring faster Sinus() and Cosinus() algos. The absolute error is rather small, here compared to the FPU fsin and fcos functions:
x       sin x                   error
-90     -1.000000000000000000   0.0
-45     -0.7071067811865475244  -9.38e-18
0       0.0     0.0
45      0.7071067811865475244   9.38e-18
90      1.000000000000000000    0.0
135     0.7071067811865475244   -2.82e-17
180     0.0     -5.31e-17
225     -0.7071067811865475244  -4.69e-17
270     -1.000000000000000000   0.0
315     -0.7071067811865475244  6.57e-17
360     0.0     1.06e-16
405     0.7071067811865475244   8.44e-17
450     1.000000000000000000    0.0

x       cos x                   error
-90     0.0     0.0
-45     0.7071067811865475244   -9.38e-18
0       1.000000000000000000    0.0
45      0.7071067811865475244   -9.38e-18
90      0.0     -2.65e-17
135     -0.7071067811865475244  -2.81e-17
180     -1.000000000000000000   0.0
225     -0.7071067811865475244  4.69e-17
270     0.0     7.96e-17
315     0.7071067811865475244   6.56e-17
360     1.000000000000000000    0.0
405     0.7071067811865475244   -8.45e-17
450     0.0     -1.33e-16


On my machine, they are almost five times as fast. Can I have some timings please? Thanks.

Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
293 ms fpu fsin         71 ms MasmBasic
295 ms fpu fsin         61 ms MasmBasic
294 ms fpu fsin         61 ms MasmBasic
295 ms fpu fsin         66 ms MasmBasic
290 ms fpu fsin         60 ms MasmBasic
290 ms fpu fsin         61 ms MasmBasic
299 ms fpu fsin         61 ms MasmBasic
288 ms fpu fsin         67 ms MasmBasic


Ah my mistake, your are faster.  :dazzled:
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

Adamanteus

 And looks not only yours, as with sameness  of 18 digits with fpu-CRT - not sure as my test of original C++ algo, shows minimal sameness of 6 digits, as in this angel
36.66666 0.59715859 0.59715860
- mostly correct are 7 digits, in 8 digits output already many difference with MS-CRT sin in test tabels.

jj2007

Could you post your source, please? I have tried to mimic your tabels output, but somehow the steps are not exactly the same.

include \masm32\MasmBasic\MasmBasic.inc      ; download
  SetGlobals fct:REAL10
  Init
  For_ fct=0.0 To 0.785398 Step 0.00289814760147601476014760147601
      Print Str$("\n%9f\t", fct), Str$("%8f", Sinus(fct, rad)#)
  Next

EndOfCode


Sinus() has the same precision as the FPU fsin function when used with integer arguments such as 45°, 123° etc.

Adamanteus

#21
 Source on C++ - there exactness of REAL8, step equal 10 minutes in degrees and asm source of REAL10 I not had, so full test can't.
P.S. Translating source if need yourself, so it's and me disturbing.

TWell

Slower in this AMD? Why?
AMD Athlon(tm) II X2 220 Processor 2.8 GHz
230 ms fpu fsin         725 ms CRT sin          116 ms MasmBasic
231 ms fpu fsin         706 ms CRT sin          119 ms MasmBasic
234 ms fpu fsin         704 ms CRT sin          116 ms MasmBasic
229 ms fpu fsin         707 ms CRT sin          116 ms MasmBasic
229 ms fpu fsin         708 ms CRT sin          116 ms MasmBasic
231 ms fpu fsin         710 ms CRT sin          116 ms MasmBasic
229 ms fpu fsin         714 ms CRT sin          117 ms MasmBasic
230 ms fpu fsin         710 ms CRT sin          115 ms MasmBasic