mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
add new versin and vercos builtin functions
Added new versin(x, [,eps]) for versed sine and vercos(x, [,eps]) for versed cosine. Updated trig help files.
This commit is contained in:
@@ -3498,15 +3498,68 @@ print '050: read -once test3400';
|
||||
define test_trig()
|
||||
{
|
||||
local tnum; /* test number */
|
||||
local pi; /* pi to 1e-20 precision */
|
||||
local i;
|
||||
|
||||
print '3400: Beginning test_trig';
|
||||
|
||||
/* test 3401-3407 */
|
||||
tnum = test3400(1, 3401);
|
||||
vrfy(tnum == 3407, '3407: tnum == 3407');
|
||||
vrfy(tnum++ == 3407, '3407: tnum == 3407');
|
||||
|
||||
print '3438: Ending test_trig';
|
||||
/* test versed sine */
|
||||
pi = pi(1e-20);
|
||||
vrfy(round(versin(0.2, 1e-10), 10) == 0.0199334222,
|
||||
strcat(str(tnum++),
|
||||
': round(versin(0.2, 1e-10), 10) == 0.0199334222'));
|
||||
vrfy(round(versin(3/7, 1e-10), 10) == 0.0904396483,
|
||||
strcat(str(tnum++),
|
||||
': round(versin(3/7, 1e-10), 10) == 0.0904396483'));
|
||||
vrfy(round(versin(-31, 1e-10), 10) == 0.0852576422,
|
||||
strcat(str(tnum++),
|
||||
': round(versin(-31, 1e-10), 10) == 0.0852576422'));
|
||||
vrfy(versin(pi/3, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': versin(pi/3, 1e-10) == 0.5'));
|
||||
vrfy(versin(pi/2, 1e-10) == 1,
|
||||
strcat(str(tnum++), ': versin(pi/2, 1e-10) == 1'));
|
||||
vrfy(versin(pi, 1e-10) == 2,
|
||||
strcat(str(tnum++), ': versin(pi, 1e-10) == 2'));
|
||||
vrfy(versin(3*pi/2, 1e-10) == 1,
|
||||
strcat(str(tnum++), ': versin(3*pi/2, 1e-10) == 1'));
|
||||
vrfy(round(versin(1, 1e-10), 10) == 0.4596976941,
|
||||
strcat(str(tnum++),
|
||||
': round(versin(1, 1e-10), 10) == 0.4596976941'));
|
||||
vrfy(round(versin(2 + 3i, 1e-10), 10) == 5.189625691+9.1092278938i,
|
||||
strcat(str(tnum++),
|
||||
': round(versin(2 + 3i, 1e-10), 10) == 5.189625691+9.1092278938i'));
|
||||
|
||||
/* test versed cosine */
|
||||
pi = pi(1e-20);
|
||||
vrfy(round(vercos(0.2, 1e-10), 10) == 0.8013306692,
|
||||
strcat(str(tnum++),
|
||||
': round(vercos(0.2, 1e-10), 10) == 0.8013306692'));
|
||||
vrfy(round(vercos(3/7, 1e-10), 10) == 0.584428145,
|
||||
strcat(str(tnum++),
|
||||
': round(vercos(3/7, 1e-10), 10) == 0.584428145'));
|
||||
vrfy(round(vercos(-31, 1e-10), 10) == 0.5959623547,
|
||||
strcat(str(tnum++),
|
||||
': round(vercos(-31, 1e-10), 10) == 0.5959623547'));
|
||||
vrfy(vercos(pi/6, 1e-10) == 0.5,
|
||||
strcat(str(tnum++), ': vercos(pi/6, 1e-10) == 0.5'));
|
||||
vrfy(vercos(pi/2, 1e-10) == 0,
|
||||
strcat(str(tnum++), ': vercos(pi/2, 1e-10) == 0'));
|
||||
vrfy(vercos(pi, 1e-10) == 1,
|
||||
strcat(str(tnum++), ': vercos(pi, 1e-10) == 1'));
|
||||
vrfy(vercos(3*pi/2, 1e-10) == 2,
|
||||
strcat(str(tnum++), ': vercos(3*pi/2, 1e-10) == 2'));
|
||||
vrfy(round(vercos(1, 1e-10), 10) == 0.1585290152,
|
||||
strcat(str(tnum++),
|
||||
': round(vercos(1, 1e-10), 10) == 0.1585290152'));
|
||||
vrfy(round(vercos(2 + 3i, 1e-10), 10) == -8.1544991469+4.16890696i,
|
||||
strcat(str(tnum++),
|
||||
': round(vercos(2 + 3i, 1e-10), 10) == -8.1544991469+4.16890696i'));
|
||||
|
||||
print strcat(str(tnum++), ': Ending test_trig');
|
||||
}
|
||||
print '051: parsed test_trig()';
|
||||
|
||||
|
Reference in New Issue
Block a user