that range reduction for sen/cos seems ok (max only 1 decimal digit of
error for call) what is not ok is this
arccos(cos(x)) where x>0 very small e.g. 0.0000000000001
(or 0.00000000000000000000000000000000000000001
) )
y=cos(x) and y is ok, but arccos(y) has many decimal digits != x (5-6
too)
for see something
----------------------------------------
#include "kilo.h"
extern fnum Kpi, K2pi, Kpi2, Kpi4, Ke, Katg025;
extern int libero_m_;
extern U c_arctg;
extern U precision;
extern U c_cos;
extern U c_phi;
extern volatile sig_atomic_t segnale_;
int varia=0;
int main( void )
{U mm;
libero_m_=0;
os "inserisci la precisione >"; is mm;
set_precision(mm);
{int i, ii;
U u, uu;
double x;
fnum a="23.85", c=-23.85e50, b=-7.145e-15, e, f;
fnum x0, x1, x2, x3, x4;
snum a3;
num aa, bb, cc;
os "Inserisci un numero >"; is a;
os "Inserisci un il moltiplicatore >"; is f;
a=a+f*K2pi;
c_cos=0;
// os "pi==" << Kpi << "\n";
b= tan(a);
os "tan(a)== " << b << " ";
P("c_tan = %u\n", c_cos);
c_arctg=0;
os "atg(a)== " << arctg(b) << " ";
P("c_atng = %u\n", c_arctg );
c_phi=0;
os "atan_phi(a)==" << atan_phi(b) << " ";
P("c_atng_p= %u\n", c_phi);
c_cos=0;
b= cos(a); x4=b;
os "cos(a)== " << b << " ";
P("c_cos = %u\n", c_cos);
c_arctg=0;
os "acos(a)== " << acos(b) << " ";
P("c_acs = %u\n", c_arctg );
c_phi=0;
os "acos_phi(a)==" << acos_phi(b) << " ";
P("c_acs_p = %u\n", c_phi);
c_cos=0;
b= sin(a);
os "sin(a)== " << b << " ";
P("c_sin = %u\n", c_cos);
c_arctg=0;
os "asin(a)== " << asin(b) << " ";
P("c_acs = %u\n", c_arctg );
c_phi=0;
os "asin_phi(a)==" << asin_phi(b) << " ";
P("c_acs_p= %u\n", c_phi);
if(a>1) {os a << "> " << "1\n";}
else {os a << "<=" << "1\n";}
}
R 0;
}
-------------------------------------------------------
inserisci la precisione >5
Inserisci un numero >0.111111111111111111
Inserisci un il moltiplicatore >5000000000000000000000
tan(a)== 0.1115706278338005836140105774725818603335118300689F
c_tan = 23
atg(a)== 0.1111111111111111109999999999999999999999999999996F
c_atng = 23
atan_phi(a)==0.1111111111111111110000000000000000000000000000003F
c_atng_p= 73
cos(a)== 0.9938335085388919213152595951271344427065097136775F
c_cos = 12
acos(a)== 0.1111111111111111109999999999999999999999999999955F
c_acs = 23
acos_phi(a)==0.1111111111111111110000000000000000000000000000003F
c_acs_p = 73
sin(a)== 0.1108826285099529849812660263523212555739213248246F
c_sin = 11
asin(a)== 0.1111111111111111109999999999999999999999999999996F
c_acs = 23
asin_phi(a)==0.1111111111111111109999999999999999999999999998710F
c_acs_p= 76
31415926535897932384626.5449439061399530826939937499457555285825577398963F>
1
MEMORIA DINAMICA LIBERATA
------------------------------------------------------
here seems all ok, the error is in the last decimal digit of the
numbern (note the 5000000000000000000000 moltiplicator)
---------------------------------
inserisci la precisione >5
Inserisci un numero >0.00000000000000000001
Inserisci un il moltiplicatore >0
tan(a)== 0.0000000000000000000099999999999999999999999999998F
c_tan = 1
atg(a)== 0.0000000000000000000099999999999999999999999999998F
c_atng = 0
atan_phi(a)==0.0000000000000000000099999999407085749105512617598F
c_atng_p= 9
cos(a)== 0.9999999999999999999999999999999999999999500000005F
c_cos = 1
acos(a)== 0.0000000000000000000099999999407085749105512617598F
c_acs = 0
acos_phi(a)==0.0000000000000000000099999999407085749105512617598F
c_acs_p = 9
sin(a)== 0.0000000000000000000099999999999999999999999999998F
c_sin = 0
asin(a)== 0.0000000000000000000099999999999999999999999999998F
c_acs = 0
asin_phi(a)==0.0000000000000000000099999999999999999999999998411F
c_acs_p= 76
0.0000000000000000000099999999999999999999999999998F<=1
MEMORIA DINAMICA LIBERATA
-------------------------------------------
here is not ok because acos(a)==
0.0000000000000000000099999999407085749105512617598F
!= 0.00000000000000000001
in several digits
---------------------------------------------------------
Inserisci un numero >1.2222222222222222222
Inserisci un il moltiplicatore >0
tan(a)==
2.7516868611940567318071872220530884537479613137095596914917F c_ta
n = 34
atg(a)==
1.2222222222222222222000000000000000000000000000000000000000F c_at
ng = 28
atan_phi(a)==1.2222222222222222222000000000000000000000000000000000000228F
c_at
ng_p= 92
cos(a)==
0.3415580120674962110596996650852662387419748224742741638229F c_co
s = 17
acos(a)==
1.2222222222222222222000000000000000000000000000000000000002F c_ac
s = 28
acos_phi(a)==1.2222222222222222222000000000000000000000000000000000000228F
c_ac
s_p = 92
sin(a)==
0.9398606941416904006846365840250964465081184244072584161975F c_si
n = 17
asin(a)==
1.2222222222222222221999999999999999999999999999999999999991F c_ac
s = 28
asin_phi(a)==1.2222222222222222221999999999999999999999999999999999999932F
c_ac
s_p= 90
1.2222222222222222221999999999999999999999999999999999999999F> 1
MEMORIA DINAMICA LIBERATA