Skip to content

Commit 6d951d8

Browse files
committed
feat: added a new function eexp_ for the exponential function.
- it can be numerically evaluated with the evaluate statement. - Note: exp_ is already a FORM function, so the naming follows that of the symbol ee_.
1 parent a405343 commit 6d951d8

File tree

7 files changed

+32
-4
lines changed

7 files changed

+32
-4
lines changed

check/features.frm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,23 @@ assert result("LN") =~ expr("
12591259
+ 9.99999327347282003e-01*ln(2.71828e+00)
12601260
")
12611261
*--#] evaluate_ln :
1262+
*--#[ evaluate_eexp :
1263+
#Startfloat 84b
1264+
CFunction exp;
1265+
Local EXP = exp(0)*eexp_(0)+exp(1)*eexp_(1)+exp(-10)*eexp_(-10)+exp(2/11)*eexp_(2/11)+exp(36124.5)*eexp_(36124.5);
1266+
Evaluate;
1267+
Print +s;
1268+
.end
1269+
#pend_if wordsize == 2
1270+
assert succeeded?
1271+
assert result("EXP") =~ expr("
1272+
+ 1.199396102035385909645662e+00*exp(2/11)
1273+
+ 4.688258114961839863324201e+15688*exp(3.61245e+04)
1274+
+ 4.539992976248485153559152e-05*exp(-10)
1275+
+ 1.0e+00*exp(0)
1276+
+ 2.718281828459045235360287e+00*exp(1)
1277+
")
1278+
*--#] evaluate_eexp :
12621279
*--#[ evaluate_li2 :
12631280
#Startfloat 18d
12641281
CFunction li2;

doc/manual/float.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ \chapter{Floating point}
124124
the floating point numbers are printed in raw internal format.
125125
\end{description}
126126
In addition to the above commands there are the following functions that
127-
can be evaluated sqrt\_, ln\_, li2\_, gamma\_, agm\_, sin\_, cos\_, tan\_,
128-
asin\_, acos\_, atan\_, sinh\_, cosh\_, tanh\_, asinh\_, acosh\_, atanh\_.
129-
For the functions atan2\_ and lin\_ there is currently no code.
127+
can be evaluated sqrt\_, ln\_, eexp\_, li2\_, gamma\_, agm\_, sin\_, cos\_, tan\_,
128+
asin\_, acos\_, atan\_, atan2\_, sinh\_, cosh\_, tanh\_, asinh\_, acosh\_, atanh\_.
129+
For the function lin\_ there is currently no code.
130130
The agm\_ function is the arithmetic geometric mean of its two input
131131
values.
132132

doc/manual/functions.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,9 @@ \section{Extra reserved names}
13141314
\leftvitem{3cm}{ln\_}\index{ln\_}\index{function!ln\_}
13151315
\rightvitem{13cm}{The natural logarithm.}
13161316

1317+
\leftvitem{3cm}{eexp\_}\index{eexp\_}\index{function!eexp\_}
1318+
\rightvitem{13cm}{The exponential function.}
1319+
13171320
\leftvitem{3cm}{sin\_}\index{sin\_}\index{function!sin\_}
13181321
\rightvitem{13cm}{The sine function.}
13191322

sources/evaluate.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,10 @@ int EvaluateFun(PHEAD WORD *term, WORD level, WORD *pars)
531531
else mpfr_log(auxr3,auxr1,RND);
532532
mpfr_mul(auxr2,auxr2,auxr3,RND);
533533
break;
534+
case EXPFUNCTION:
535+
mpfr_exp(auxr3,auxr1,RND);
536+
mpfr_mul(auxr2,auxr2,auxr3,RND);
537+
break;
534538
case LI2FUNCTION: /* should be between -1 and +1 */
535539
if ( nsgn == 0 ) goto getout;
536540
mpfr_abs(auxr3,auxr1,RND);
@@ -645,6 +649,7 @@ int EvaluateFun(PHEAD WORD *term, WORD level, WORD *pars)
645649
case LNFUNCTION:
646650
case LI2FUNCTION:
647651
case LINFUNCTION:
652+
case EXPFUNCTION:
648653
case ASINFUNCTION:
649654
case ACOSFUNCTION:
650655
case ATANFUNCTION:

sources/float.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,6 +2768,7 @@ int CoEvaluate(UBYTE *s)
27682768
*/
27692769
case SQRTFUNCTION:
27702770
case LNFUNCTION:
2771+
case EXPFUNCTION:
27712772
case SINFUNCTION:
27722773
case COSFUNCTION:
27732774
case TANFUNCTION:

sources/ftypes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,8 @@ typedef int (*TFUN1)();
477477
#define MZVHALF 121
478478
#define AGMFUNCTION 122
479479
#define GAMMAFUN 123
480-
#define MAXBUILTINFUNCTION 123
480+
#define EXPFUNCTION 124
481+
#define MAXBUILTINFUNCTION 124
481482
#else
482483
#define MAXBUILTINFUNCTION 115
483484
#endif

sources/inivar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ static struct fixedfun {
252252
,{"mzvhalf_" ,0 ,0 ,0 ,0} /* MZVHALF */
253253
,{"agm_" ,0 ,0 ,0 ,0} /* AGMFUNCTION */
254254
,{"gamma_" ,0 ,0 ,0 ,0} /* GAMMAFUN */
255+
,{"eexp_" ,0 ,0 ,0 ,0} /* EXPFUNCTION */
255256
#endif
256257
};
257258

0 commit comments

Comments
 (0)