39 #define M_PI 3.14159265358979323846
43 #define M_PI_2 1.57079632679489661923
47 #define M_PI_4 0.785398163397448309616
51 #define M_E 2.71828182845904523536
66 static void zdel(
char* c)
68 int l = strlen(c) - 1;
69 bool f = (c[l] ==
'f');
72 while ( l>1 && c[l-1] !=
'.' && c[l] ==
'0') c[l--] = 0;
77 string docT (
char* c) {
return string(c); }
78 string docT (
int n) {
char c[64]; snprintf(c, 63,
"%d",n);
return string(c); }
79 string docT (
long n) {
char c[64]; snprintf(c, 63,
"%ld",n);
return string(c); }
96 }
while ((
float)(1.0 + (machEps/2.0)) != 1.0);
107 double machEps = 1.0f;
110 }
while ((1.0 + (machEps/2.0)) != 1.0);
122 double maxAbsoluteError = maxRelativeError;
125 if (fabs(A - B) < maxAbsoluteError)
127 double relativeError;
128 if (fabs(B) > fabs(A))
129 relativeError = fabs((A - B) / B);
131 relativeError = fabs((A - B) / A);
132 if (relativeError <= maxRelativeError)
146 stringstream ss (stringstream::out|stringstream::in);
147 int k = (int)floor(log(n)/log(
M_PI));
150 if (k!=1) ss <<
"^{"<< k <<
"}";
166 stringstream ss (stringstream::out|stringstream::in);
167 int k = (int)floor(log(n));
170 if (k!=1) ss <<
"^{"<< k <<
"}";
201 stringstream ss (stringstream::out|stringstream::in);
203 if ((num==1) & (denom==1)) {
205 }
else if ((num==1) & (denom!=1)) {
206 ss <<
"\\frac{"<< exp <<
"}{" << denom <<
"}";
207 }
else if ((num!=1) & (denom==1)) {
208 ss << num <<
"*" << exp;
210 ss <<
"\\frac{"<< num <<
"}{" << denom <<
"}*" << exp;
226 for (
int i=1;i<10;i++) {
227 for(
int j=1;j<10;j++) {
238 string entree =
" * 10^{";
240 string::size_type ps;
242 snprintf(tmp, 63,
"%.15g", n);
246 if (ps != string::npos) {
247 s.replace(ps, 1,
"");
248 s.insert(ps, entree);
bool isPiPower(double n, string &s)
Return true if n>0 is equal to PI^k for some small integer k.
const string positiveSymbolicNumber(double n)
Return symbolic or numerical representation of n>0.
static bool AlmostEqual(double A, double B)
Check if two floating point numbers are (almost) equal Abs(x-y) < epsilon.
interval abs(const interval &x)
float fltEpsilon()
Compute the smallest float representable difference epsilon such that 1 != 1+epsilon.
double dblEpsilon()
Compute the smallest double representable difference epsilon such that 1 != 1+epsilon.
bool isExpPower(double n, string &s)
Return true if n>0 is equal to e^k for some small integer k.
const string symbolicNumber(double n)
Return symbolic or numerical representation of n.
bool isSymbolicPower(double n, string &s)
Return true if n>0 is equal to e^k or PI^k for some integer k The symbolic latex representation is re...
const string addFraction(int num, int denom, const string &exp)
Return exp or num.exp, or exp/denom, or num/denom.exp.