| |
|
|
p.specht
| (... and who whom Sinus has, has so too Cosinus and Tangens!) remarkable: in the area 0-90° remaining the thing under 0,047 % Error. prerequisite is though a detailed Computerarithmetik - and who The has, the has usually already a Sinusfunktion installed. still mathematically interestingly. Note: in the FPU the PC go trigonometrische Funktonen ditto through Approximation determined, alledings through CORDIC Algorithmus. The is hold yet accurate, setting but "gehobene" rechentechnische Kenntnisse ahead...
Window Title "Sinus-substitute through Padé-Approximation"
' fountain: https://www.dattalo.com/technical/theory/theory.html
' In XProfan 11.2 umgesetzt of P. woodpecker 2012-05; Jedwede Gewähr impossible!
' Möglicherweise rights Third, therefore go ahead Demonstrationszwecken!
Font 2:randomize:cls rnd(8^8)
set("decimals",10)
'{ Konstanten for Own sinus()-function
var pi!=3.14159265358979323846264338327950288419716939937510
var pi2!=2*pi!
var pih!=pi!/2
var r2g!=pi!/180
var n1!=-325523/2283996
var n2!=34911/7613320
var n3!=479249/(1.1511339840*10^10)
var d1!=18381/761332
var d2!=1261/4567992
var d3!=2623/(1.644477120*10^9)
'}
'{ Hauptschleife
declare w!,af!,rf!
var txt$="Grad Sin() Sinus-Approx Absol.Err Relativfehler\n"
print txt$
WhileLoop 0,360,1
w!=r2g!*&Loop
af!=sinus(w!)-sin(w!)
rf!=100*af!/(sin(w!)+10^-36)
case &Loop<100:print " ";
case &Loop<10 :print " ";
print &Loop,sin(w!),sinus(w!),af!,rf!;" [%]"
if %csrlin>26
waitinput
cls rnd(8^8)
print txt$
endif
EndWhile
print "OK."
Waitinput
'}
End
proc sinus : parameters x!
declare num!,whom!,x2!,x4!,x6!,sinus!,vz!
' 0-90° Rel.Err < 0,047%
' Zyklischen Wertebereich produce
x!=x!-pi2!*int(x!/pi2!)
vz!=1:if x!>=pi!:x!=x!-pi!-1.24*10^-16:vz!= -1:endif
case x!>=pih!:x!=pi!-x!
' Padé-Approximation
x2!=x!*x!:x4!=x2!*x2!:x6!=x4!*x2!
num! = 1 + n1!*x2! + n2!*x4! + n3!*x6!
whom! = 1 + d1!*x2! + d2!*x6! + d3!*x6!
sinus! = vz! * x! * num! / whom!
return sinus!
endproc
proc cosinus :parameters x!
return sinus(x!)+pih!
endproc
proc tangens : parameters x!
return sinus(x!)/sinus!(x!-pih!)
endproc
|
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 05/07/21 ▲ |
|
|
|