complex pass (except floating point base numbers)

This commit is contained in:
Louis Rubet 2022-02-20 15:58:15 +01:00
parent f7b95c68a2
commit 949a1a0648
13 changed files with 643 additions and 833 deletions

View file

@ -57,7 +57,7 @@ add_executable(
${PROJECT_SOURCE_DIR}/src/program.cpp
${PROJECT_SOURCE_DIR}/src/parse.cpp
${PROJECT_SOURCE_DIR}/src/rpn-branch.cpp
#${PROJECT_SOURCE_DIR}/src/rpn-complex.cpp
${PROJECT_SOURCE_DIR}/src/rpn-complex.cpp
${PROJECT_SOURCE_DIR}/src/rpn-general.cpp
#${PROJECT_SOURCE_DIR}/src/rpn-logs.cpp
${PROJECT_SOURCE_DIR}/src/rpn-program.cpp

View file

@ -13,6 +13,11 @@ Changelog
- Delivery as flatpak and snap
grosse perte en performances (!)
- v2.3.2 fibo: 0,01s user 0,01s system 97% cpu 0,017 total
- v3.0.0 fibo: 2,60s user 0,00s system 99% cpu 2,611 total
- facteur 150 environ
cf https://gmplib.org/manual/Custom-Allocation
cf https://www.geeksforgeeks.org/overloading-new-delete-operator-c/
New
- `«` and `»` are now valid as program delimiters. `<<` and `>>` are still valid
@ -34,11 +39,14 @@ Compatibility is broken on these points
- rpn is not delivered as deb and rpm anymore, since it is too much bound to particular OS
- `sto/` bug correction: 3 'a' sto/ now correctly does a/3 -> a (although it did 3/a -> a)
- `sto+` `sto-` `sto*` `sto/` don't accept anymore the syntax `'varname' value stoX`, but only `value 'varname' stoX`, ex: `3 'a' sto*`
- incomplete entry `(1,` not available anymore
- signed zero is the sign of zero is subject to change compared to previous version, for example `-3 sqrt` now equals `(0.000000,1.732051)` instead of `(-0.000000,1.732051)`
missing tests
missing tests / problems
- nested loops / if / while / do + access to local variables
- les arguments d'une fonction en erreur doivent ils êre consommés ?
ex embettant : sto+
- sto+ * - / : ajouter des cas de test avec type incorrects
- `10 -> n << n >>` plante
- `1 'i' sto while i <= 2 repeat 0 'j' sto while j <= 1 repeat i (1,0) * j (0,1) * + 1 'j' sto+ end 1 'i' sto+ end` plante
- `1 'i' sto while i <= 2 repeat 0 'j' sto while j <= 1 repeat i (1,0) * j (0,1) * + 1 'j' sto+ end 1 'i' sto+ end` plante
- real: ln, lnp1, log, log10, log2, exp, expm, alog2, alog10, sinh, asinh, cosh, acosh, tanh, atanh

View file

@ -52,15 +52,15 @@ program::keyword_t program::s_keywords[] = {
{cmd_keyword, "max", &program::rpn_max, "max of 2 real numbers"},
// OPERATIONS ON COMPLEXES
// {cmd_undef, "", NULL, "\nOPERATIONS ON COMPLEXES"},
// {cmd_keyword, "re", &program::rpn_re, "complex real part"},
// {cmd_keyword, "im", &program::rpn_im, "complex imaginary part"},
// {cmd_keyword, "conj", &program::rpn_conj, "complex conjugate"},
// {cmd_keyword, "arg", &program::rpn_arg, "complex argument in radians"},
// {cmd_keyword, "c->r", &program::rpn_c2r, "transform a complex in 2 reals"},
// {cmd_keyword, "r->c", &program::rpn_r2c, "transform 2 reals in a complex"},
// {cmd_keyword, "p->r", &program::rpn_p2r, "cartesian to polar"},
// {cmd_keyword, "r->p", &program::rpn_r2p, "polar to cartesian"},
{cmd_undef, "", NULL, "\nOPERATIONS ON COMPLEXES"},
{cmd_keyword, "re", &program::rpn_re, "complex real part"},
{cmd_keyword, "im", &program::rpn_im, "complex imaginary part"},
{cmd_keyword, "conj", &program::rpn_conj, "complex conjugate"},
{cmd_keyword, "arg", &program::rpn_arg, "complex argument in radians"},
{cmd_keyword, "c->r", &program::rpn_c2r, "transform a complex in 2 reals"},
{cmd_keyword, "r->c", &program::rpn_r2c, "transform 2 reals in a complex"},
{cmd_keyword, "p->r", &program::rpn_p2r, "cartesian to polar"},
{cmd_keyword, "r->p", &program::rpn_r2p, "polar to cartesian"},
// MODE
{cmd_undef, "", NULL, "\nMODE"},

View file

@ -6,14 +6,8 @@
void program::rpn_re() {
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_complex);
rpnstack::copy_and_push_front(*_stack, _stack->size() - 1, _calc_stack);
_stack->pop_front();
number* re = new number();
_stack->push_front(re);
CHECK_MPFR(mpfr_set(re->_value.mpfr, ((complex*)_calc_stack.at(0))->re()->mpfr, mpreal::get_default_rnd()));
_calc_stack.pop_front();
_stack->push_front(new number(real(_stack->value<ocomplex>(0))));
_stack->erase(1);
}
/// @brief im keyword implementation
@ -22,14 +16,8 @@ void program::rpn_re() {
void program::rpn_im() {
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_complex);
rpnstack::copy_and_push_front(*_stack, _stack->size() - 1, _calc_stack);
_stack->pop_front();
number* im = new number();
_stack->push_front(im);
CHECK_MPFR(mpfr_set(im->_value.mpfr, ((complex*)_calc_stack.at(0))->im()->mpfr, mpreal::get_default_rnd()));
_calc_stack.pop_front();
_stack->push_front(new number(imag(_stack->value<ocomplex>(0))));
_stack->erase(1);
}
/// @brief arg keyword implementation
@ -38,16 +26,8 @@ void program::rpn_im() {
void program::rpn_arg() {
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_complex);
// calc atan2(x/y)
complex* cplx = (complex*)_stack->front();
number* num = new number();
_calc_stack.push_back(num);
CHECK_MPFR(mpfr_atan2(num->_value.mpfr, cplx->im()->mpfr, cplx->re()->mpfr, mpreal::get_default_rnd()));
rpnstack::copy_and_push_front(_calc_stack, _calc_stack.size() - 1, *_stack);
_calc_stack.pop_front();
_stack->push_front(new number(arg(_stack->value<ocomplex>(0))));
_stack->erase(1);
}
/// @brief conj keyword implementation
@ -56,9 +36,7 @@ void program::rpn_arg() {
void program::rpn_conj() {
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_complex);
complex* cplx = (complex*)_stack->back();
CHECK_MPFR(mpfr_neg(cplx->im()->mpfr, cplx->im()->mpfr, mpreal::get_default_rnd()));
_stack->value<ocomplex>(0) = conj(_stack->value<ocomplex>(0));
}
/// @brief r2c keyword implementation
@ -68,17 +46,8 @@ void program::rpn_r2c() {
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
rpnstack::copy_and_push_front(*_stack, _stack->size() - 2, _calc_stack);
rpnstack::copy_and_push_front(*_stack, _stack->size() - 1, _calc_stack);
_stack->pop_front();
_stack->pop_front();
complex* cplx = new complex();
_stack->push_front(cplx);
CHECK_MPFR(mpfr_set(cplx->re()->mpfr, ((number*)_calc_stack.at(1))->_value.mpfr, mpreal::get_default_rnd()));
CHECK_MPFR(mpfr_set(cplx->im()->mpfr, ((number*)_calc_stack.at(0))->_value.mpfr, mpreal::get_default_rnd()));
_calc_stack.pop_front(2);
_stack->push(new ocomplex(_stack->value<number>(1), _stack->value<number>(0), _stack->obj<ocomplex>(1)->reBase, _stack->obj<ocomplex>(0)->reBase));
_stack->erase(1, 2);
}
/// @brief c2r keyword implementation
@ -87,18 +56,9 @@ void program::rpn_r2c() {
void program::rpn_c2r() {
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_complex);
rpnstack::copy_and_push_front(*_stack, _stack->size() - 1, _calc_stack);
_stack->pop_front();
number* re = new number();
_stack->push_front(re);
number* im = new number();
_stack->push_front(im);
CHECK_MPFR(mpfr_set(re->_value.mpfr, ((complex*)_calc_stack.back())->re()->mpfr, mpreal::get_default_rnd()));
CHECK_MPFR(mpfr_set(im->_value.mpfr, ((complex*)_calc_stack.back())->im()->mpfr, mpreal::get_default_rnd()));
_calc_stack.pop_front();
_stack->push(new number(real(_stack->value<ocomplex>(0)), _stack->obj<ocomplex>(0)->reBase));
_stack->push(new number(imag(_stack->value<ocomplex>(1)), _stack->obj<ocomplex>(1)->imBase));
_stack->erase(2);
}
/// @brief r2p keyword implementation
@ -107,20 +67,10 @@ void program::rpn_c2r() {
void program::rpn_r2p() {
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_complex);
rpn_dup();
rpn_dup();
rpn_arg();
complex* cplx = (complex*)_stack->at(1);
CHECK_MPFR(mpfr_set(cplx->im()->mpfr, ((number*)_stack->back())->_value.mpfr, mpreal::get_default_rnd()));
_stack->pop_front();
rpn_swap();
rpn_abs();
cplx = (complex*)_stack->at(1);
CHECK_MPFR(mpfr_set(cplx->re()->mpfr, ((number*)_stack->back())->_value.mpfr, mpreal::get_default_rnd()));
_stack->pop_front();
mpreal rho = abs(_stack->value<ocomplex>(0));
mpreal theta = arg(_stack->value<ocomplex>(0));
_stack->value<ocomplex>(0).real(rho);
_stack->value<ocomplex>(0).imag(theta);
}
/// @brief p2r keyword implementation
@ -129,26 +79,5 @@ void program::rpn_r2p() {
void program::rpn_p2r() {
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_complex);
rpnstack::copy_and_push_front(*_stack, _stack->size() - 1, _calc_stack);
_calc_stack.push_back(new number());
// assert complex is polar
complex* rhotheta = (complex*)_calc_stack.at(1);
number* tmp = (number*)_calc_stack.at(0);
complex* result = (complex*)_stack->back();
// calc cos(theta)
CHECK_MPFR(mpfr_set(tmp->_value.mpfr, rhotheta->im()->mpfr, mpreal::get_default_rnd()));
CHECK_MPFR(mpfr_cos(tmp->_value.mpfr, tmp->_value.mpfr, mpreal::get_default_rnd()));
// calc rcos(theta)
CHECK_MPFR(mpfr_mul(result->re()->mpfr, rhotheta->re()->mpfr, tmp->_value.mpfr, mpreal::get_default_rnd()));
// calc sin(theta)
CHECK_MPFR(mpfr_set(tmp->_value.mpfr, rhotheta->im()->mpfr, mpreal::get_default_rnd()));
CHECK_MPFR(mpfr_sin(tmp->_value.mpfr, tmp->_value.mpfr, mpreal::get_default_rnd()));
// calc rsin(theta)
CHECK_MPFR(mpfr_mul(result->im()->mpfr, rhotheta->re()->mpfr, tmp->_value.mpfr, mpreal::get_default_rnd()));
_stack->value<ocomplex>(0) = polar(abs(_stack->value<ocomplex>(0)), arg(_stack->value<ocomplex>(0)));
}

View file

@ -152,8 +152,15 @@ void program::rpn_inv() {
void program::rpn_power() {
MIN_ARGUMENTS(2);
if (_stack->type(0) == cmd_number && _stack->type(1) == cmd_number) {
_stack->value<number>(1) = pow(_stack->value<number>(1), _stack->value<number>(0));
_stack->pop();
if (_stack->value<number>(1) >= 0) {
_stack->value<number>(1) = pow(_stack->value<number>(1), _stack->value<number>(0));
_stack->pop();
} else {
mpreal zero;
_stack->push(new ocomplex(_stack->value<number>(1), zero, _stack->obj<number>(1)->base));
_stack->value<ocomplex>(0) = pow(_stack->value<ocomplex>(0), _stack->value<number>(1));
_stack->erase(1, 2);
}
} else if (_stack->type(0) == cmd_complex && _stack->type(1) == cmd_complex) {
_stack->value<ocomplex>(1) = pow(_stack->value<ocomplex>(1), _stack->value<ocomplex>(0));
_stack->pop();
@ -176,10 +183,11 @@ void program::rpn_squareroot() {
if (_stack->value<number>(0) >= 0) {
_stack->value<number>(0) = sqrt(_stack->value<number>(0));
} else {
// negative number -> square root is compl ex
_stack->push(new ocomplex); // TODO manage new errors
_stack->value<ocomplex>(0) = sqrt(_stack->value<number>(1));
_stack->pop_front(1);
// negative number -> square root is complex
mpreal zero;
_stack->push(new ocomplex(_stack->value<number>(0), zero, _stack->obj<number>(0)->base)); // TODO manage new errors
_stack->value<ocomplex>(0) = sqrt(_stack->value<ocomplex>(0));
_stack->erase(1);
}
} else if (_stack->type(0) == cmd_complex)
_stack->value<ocomplex>(0) = sqrt(_stack->value<ocomplex>(0));
@ -294,9 +302,10 @@ void program::rpn_abs() {
MIN_ARGUMENTS(1);
if (_stack->type(0) == cmd_number)
_stack->value<number>(0) = abs(_stack->value<number>(0));
else if (_stack->type(0) == cmd_complex)
_stack->value<ocomplex>(0) = norm(_stack->value<ocomplex>(0));
else
else if (_stack->type(0) == cmd_complex) {
_stack->push(new number(abs(_stack->value<ocomplex>(0))));
_stack->erase(1);
} else
ERR_CONTEXT(ret_bad_operand_type);
}
@ -316,7 +325,7 @@ void program::rpn_sign() {
if (_stack->type(0) == cmd_number)
_stack->value<number>(0) = sgn(_stack->value<number>(0));
else if (_stack->at(0)->_type == cmd_complex)
_stack->value<ocomplex>(0) = _stack->value<ocomplex>(0) / norm(_stack->value<ocomplex>(0));
_stack->value<ocomplex>(0) = _stack->value<ocomplex>(0) / abs(_stack->value<ocomplex>(0));
else
ERR_CONTEXT(ret_bad_operand_type);
}

View file

@ -1,4 +1,4 @@
# TEST the test framwork
# TEST FRAMEWORK
`default del`

View file

@ -1,4 +1,4 @@
# PARSE SYMBOL
# PARSE PROGRAM
`default del `

View file

@ -1,4 +1,4 @@
# REAL AND COMPLEX NUJMERICAL ENTRIES
# REAL AND COMPLEX NUMERICAL ENTRIES
`default del`

View file

@ -1,4 +1,4 @@
### COMPLEX
# COMPLEX
`default del`
@ -22,7 +22,7 @@
`(1,`
-> stack should be (1,0)
-> stack should be '(1,'
`del`
@ -46,7 +46,7 @@
`(0b11,0b101)`
-> stack should be (3,5)
-> stack should be (0b11,0b101)
`del`
@ -60,23 +60,15 @@
## add (2)
`(1.2,2.3) (1,2)+`
-> stack should be (2.2,4.3)
`del`
## add (3)
`(1.2,2.3) 3+`
`(1.2,2.3) 3 +`
-> stack should be (4.2,2.3)
`del`
## add (4)
## add (3)
`3 (1.2,2.3)+`
`3 (1.2,2.3) +`
-> stack should be (4.2,2.3)
@ -92,25 +84,17 @@
## sub (2)
`(1.2,2.3) (1,2)-`
-> stack should be (0.2,0.3)
`del`
## sub (3)
`(1.2,2.3) 1-`
`(1.2,2.3) 1 -`
-> stack should be (0.2,2.3)
`del`
## sub (4)
## sub (3)
`1 (1.2,2.3) -`
-> stack should be (-0.2,2.3)
-> stack should be (-0.2,-2.3)
`del`
@ -394,13 +378,21 @@
## r->c (2)
`0x12 0b1101 r->c`
-> stack should be (0x12,0b1101)
`del`
## r->c error (1)
`1 r->c`
-> error should be 2
`del`
## r->c (3)
## r->c error (2)
`r->c`
@ -408,7 +400,7 @@
`del`
## r->c (3)
## r->c error (3)
`'1' '2' r->c`
@ -426,13 +418,21 @@
## c->r (2)
`(0x12,0b1101) c->r`
-> stack should be 0x12, 0b1101
`del`
## c->r error (2)
`c->r`
-> error should be 2
`del`
## c->r (3)
## c->r error (2)
`'4' c->r`
@ -502,6 +502,22 @@
`del`
## ^ (4)
`-3 (1,2) ^`
-> stack should be (0.003284,-0.004539)
`del`
## ^ (5)
`(1,2) (1,2) ^`
-> stack should be (-0.222517,0.100709)
`del`
## sqrt (1)
`(3,4) sqrt`
@ -514,695 +530,6 @@
`-3 sqrt`
-> stack should be (-0.000000,1.732051)
`del`
## sin (1)
`(1,2) sin`
-> stack should be (3.165779,1.959601)
`del`
## sin (2)
`(1,-2) sin`
-> stack should be (3.165779,-1.959601)
`del`
## sin (3)
`(-1,-2) sin`
-> stack should be (-3.165779,-1.959601)
`del`
## sin (4)
`(-1,2) sin`
-> stack should be (-3.165779,1.959601)
`del`
## asin (1)
`(1,2) asin`
-> stack should be (0.427079,1.528571)
`del`
## asin (2)
`(1,-2) asin`
-> stack should be (0.427079,-1.528571)
`del`
## asin (3)
`(-1,-2) asin`
-> stack should be (-0.427079,-1.528571)
`del`
## asin (4)
`(-1,2) asin`
-> stack should be (-0.427079,1.528571)
`del`
## cos (1)
`(1,2) cos`
-> stack should be (2.032723,-3.051898)
`del`
## cos (2)
`(1,-2) cos`
-> stack should be (2.032723,3.051898)
`del`
## cos (3)
`(-1,-2) cos`
-> stack should be (2.032723,-3.051898)
`del`
## cos (4)
`(-1,2) sin`
-> stack should be (-3.165779,1.959601)
`del`
## acos (1)
`(1,2) acos`
-> stack should be (1.143718,-1.528571)
`del`
## acos (2)
`(1,-2) acos`
-> stack should be (1.143718,1.528571)
`del`
## acos (3)
`(-1,-2) acos`
-> stack should be (1.997875,1.528571)
`del`
## acos (4)
`(-1,2) acos`
-> stack should be (1.997875,-1.528571)
`del`
## tan (1)
`(1,2) tan`
-> stack should be (0.033813,1.014794)
`del`
## tan (2)
`(1,-2) tan`
-> stack should be (0.033813,-1.014794)
`del`
## tan (3)
`(-1,-2) tan`
-> stack should be (-0.033813,-1.014794)
`del`
## tan (4)
`(-1,2) tan`
-> stack should be (-0.033813,1.014794)
`del`
## atan (1)
`(1,2) atan`
-> stack should be (1.338973,0.402359)
`del`
## atan (2)
`(1,-2) atan`
-> stack should be (1.338973,-0.402359)
`del`
## atan (3)
`(-1,-2) atan`
-> stack should be (-1.338973,-0.402359)
`del`
## atan (4)
`(-1,2) atan`
-> stack should be (-1.338973,0.402359)
`del`
## ln (1)
`(1,2) ln`
-> stack should be (0.804719,1.107149)
`del`
## ln (2)
`(1,-2) ln`
-> stack should be (0.804719,-1.107149)
`del`
## ln (3)
`(-1,-2) ln`
-> stack should be (0.804719,-2.034444)
`del`
## ln (4)
`(-1,2) ln`
-> stack should be (0.804719,2.034444)
`del`
## lnp1 (1)
`(1,2) lnp1`
`(1,2) 1 + ln ==`
-> stack should be 1.000000
`del`
## lnp1 (2)
`(1,-2) lnp1`
`(1,-2) 1 + ln ==`
-> stack should be 1.000000
`del`
## lnp1 (3)
`(-1,-2) lnp1`
`(-1,-2) 1 + ln ==`
-> stack should be 1.000000
`del`
## lnp1 (4)
`(-1,2) lnp1`
`(-1,2) 1 + ln ==`
-> stack should be 1.000000
`del`
## log (1)
`(1,2) log`
-> stack should be (0.804719,1.107149)
`del`
## log (2)
`(1,-2) log`
-> stack should be (0.804719,-1.107149)
`del`
## log (3)
`(-1,-2) log`
-> stack should be (0.804719,-2.034444)
`del`
## log (4)
`(-1,2) log`
-> stack should be (0.804719,2.034444)
`del`
## log10 (1)
`(1,2) log10`
-> stack should be (0.349485,0.480829)
`del`
## log10 (2)
`(1,-2) log10`
-> stack should be (0.349485,-0.480829)
`del`
## log10 (3)
`(-1,-2) log10`
-> stack should be (0.349485,-0.883548)
`del`
## log10 (4)
`(-1,2) log10`
-> stack should be (0.349485,0.883548)
`del`
## log2 (1)
`(1,2) log2`
-> stack should be (1.160964,1.597278)
`del`
## log2 (2)
`(1,-2) log2`
-> stack should be (1.160964,-1.597278)
`del`
## log2 (3)
`(-1,-2) log2`
-> stack should be (1.160964,-2.935082)
`del`
## log2 (4)
`(-1,2) log2`
-> stack should be (1.160964,2.935082)
`del`
## exp (1)
`(1,2) exp`
-> stack should be (-1.131204,2.471727)
`del`
## exp (2)
`(1,-2) exp`
-> stack should be (-1.131204,-2.471727)
`del`
## exp (3)
`(-1,-2) exp`
-> stack should be (-0.153092,-0.334512)
`del`
## exp (4)
`(-1,2) exp`
-> stack should be (-0.153092,0.334512)
`del`
## expm (1)
`(1,2) expm`
`(1,2) exp 1 - ==`
-> stack should be 1.000000
`del`
## expm (2)
`(1,-2) expm`
`(1,-2) exp 1 - ==`
-> stack should be 1.000000
`del`
## expm (3)
`(-1,-2) expm`
`(-1,-2) exp 1 - ==`
-> stack should be 1.000000
`del`
## expm (4)
`(-1,2) expm`
`(-1,2) exp 1 - ==`
-> stack should be 1.000000
`del`
## alog2 (1)
`(1,2) alog2`
-> stack should be (0.366914,1.966055)
`del`
## alog2 (2)
`(1,-2) alog2`
-> stack should be (0.366914,-1.966055)
`del`
## alog2 (3)
`(-1,-2) alog2`
-> stack should be (0.091728,-0.491514)
`del`
## alog2 (4)
`(-1,2) alog2`
-> stack should be (0.091728,0.491514)
`del`
## alog10 (1)
`(1,2) alog10`
-> stack should be (-1.070135,-9.942576)
`del`
## alog10 (2)
`(1,-2) alog10`
-> stack should be (-1.070135,9.942576)
`del`
## alog10 (3)
`(-1,-2) alog10`
-> stack should be (-0.010701,0.099426)
`del`
## alog10 (4)
`(-1,2) alog10`
-> stack should be (-0.010701,-0.099426)
`del`
## sinh (1)
`(1,2) sinh`
-> stack should be (-0.489056,1.403119)
`del`
## sinh (2)
`(1,-2) sinh`
-> stack should be (-0.489056,-1.403119)
`del`
## sinh (3)
`(-1,-2) sinh`
-> stack should be (0.489056,-1.403119)
`del`
## sinh (4)
`(-1,2) sinh`
-> stack should be (0.489056,1.403119)
`del`
## asinh (1)
`(1,2) asinh`
-> stack should be (1.469352,1.063440)
`del`
## asinh (2)
`(1,-2) asinh`
-> stack should be (1.469352,-1.063440)
`del`
## asinh (3)
`(-1,-2) asinh`
-> stack should be (-1.469352,-1.063440)
`del`
## asinh (4)
`(-1,2) asinh`
-> stack should be (-1.469352,1.063440)
`del`
## cosh (1)
`(1,2) cosh`
-> stack should be (-0.489056,1.403119)
`del`
## cosh (2)
`(1,-2) cosh`
-> stack should be (-0.489056,-1.403119)
`del`
## cosh (3)
`(-1,-2) cosh`
-> stack should be (0.489056,-1.403119)
`del`
## cosh (4)
`(-1,2) cosh`
-> stack should be (0.489056,1.403119)
`del`
## acosh (1)
`(1,2) acosh`
-> stack should be (1.528571,1.143718)
`del`
## acosh (2)
`(1,-2) acosh`
-> stack should be (1.528571,-1.143718)
`del`
## acosh (3)
`(-1,-2) acosh`
-> stack should be (-1.528571,1.997875)
`del`
## acosh (4)
`(-1,2) acosh`
-> stack should be (-1.528571,-1.997875)
`del`
## tanh (1)
`(1,2) tanh`
-> stack should be (0.564133,-0.217934)
`del`
## tanh (2)
`(1,-2) tanh`
-> stack should be (0.564133,0.217934)
`del`
## tanh (3)
`(-1,-2) tanh`
-> stack should be (-0.564133,0.217934)
`del`
## tanh (4)
`(-1,2) tanh`
-> stack should be (-0.564133,-0.217934)
`del`
## atanh (1)
`(1,2) atanh`
-> stack should be (0.173287,1.178097)
`del`
## atanh (2)
`(1,-2) atanh`
-> stack should be (0.173287,-1.178097)
`del`
## atanh (3)
`(-1,-2) atanh`
-> stack should be (-0.173287,-1.178097)
`del`
## atanh (4)
`(-1,2) atanh`
-> stack should be (-0.173287,1.178097)
-> stack should be (0.000000,1.732051)
`del`

View file

@ -1,4 +1,4 @@
# date and time
# DATE AND TIME
`default del`

37
test/120-trig.md Normal file
View file

@ -0,0 +1,37 @@
# TRIGONOMETRY
`del default`
## pi
`6 fix pi`
-> stack should be 3.141593
`del default`
## real sin asin
`0 sin pi 2 / sin pi 6 / sin`
`0 asin 0 == 1 asin pi 2 / == 0.5 asin pi 6 / ==`
-> stack should be 0, 1, 0.5, 1, 1, 1
`del`
## real cos acos
`0 cos pi 3 / cos`
`1 acos 0 == 0.5 acos pi 3 / ==`
-> stack should be 1, 0.5, 1, 1
`del`
## real tan atan
`pi 4 / tan 1 == 1 atan pi 4 / ==`
-> stack should be 1, 1
`del`

498
test/130-logs.md Normal file
View file

@ -0,0 +1,498 @@
# LOGARITHMS
## complex ln (1)
`(1,2) ln`
-> stack should be (0.804719,1.107149)
`del`
## complex ln (2)
`(1,-2) ln`
-> stack should be (0.804719,-1.107149)
`del`
## complex ln (3)
`(-1,-2) ln`
-> stack should be (0.804719,-2.034444)
`del`
## complex ln (4)
`(-1,2) ln`
-> stack should be (0.804719,2.034444)
`del`
## complex lnp1 (1)
`(1,2) lnp1`
`(1,2) 1 + ln ==`
-> stack should be 1.000000
`del`
## complex lnp1 (2)
`(1,-2) lnp1`
`(1,-2) 1 + ln ==`
-> stack should be 1.000000
`del`
## complex lnp1 (3)
`(-1,-2) lnp1`
`(-1,-2) 1 + ln ==`
-> stack should be 1.000000
`del`
## complex lnp1 (4)
`(-1,2) lnp1`
`(-1,2) 1 + ln ==`
-> stack should be 1.000000
`del`
## complex log (1)
`(1,2) log`
-> stack should be (0.804719,1.107149)
`del`
## complex log (2)
`(1,-2) log`
-> stack should be (0.804719,-1.107149)
`del`
## complex log (3)
`(-1,-2) log`
-> stack should be (0.804719,-2.034444)
`del`
## complex log (4)
`(-1,2) log`
-> stack should be (0.804719,2.034444)
`del`
## complex log10 (1)
`(1,2) log10`
-> stack should be (0.349485,0.480829)
`del`
## complex log10 (2)
`(1,-2) log10`
-> stack should be (0.349485,-0.480829)
`del`
## complex log10 (3)
`(-1,-2) log10`
-> stack should be (0.349485,-0.883548)
`del`
## complex log10 (4)
`(-1,2) log10`
-> stack should be (0.349485,0.883548)
`del`
## complex log2 (1)
`(1,2) log2`
-> stack should be (1.160964,1.597278)
`del`
## complex log2 (2)
`(1,-2) log2`
-> stack should be (1.160964,-1.597278)
`del`
## complex log2 (3)
`(-1,-2) log2`
-> stack should be (1.160964,-2.935082)
`del`
## complex log2 (4)
`(-1,2) log2`
-> stack should be (1.160964,2.935082)
`del`
## complex exp (1)
`(1,2) exp`
-> stack should be (-1.131204,2.471727)
`del`
## complex exp (2)
`(1,-2) exp`
-> stack should be (-1.131204,-2.471727)
`del`
## complex exp (3)
`(-1,-2) exp`
-> stack should be (-0.153092,-0.334512)
`del`
## complex exp (4)
`(-1,2) exp`
-> stack should be (-0.153092,0.334512)
`del`
## complex expm (1)
`(1,2) expm`
`(1,2) exp 1 - ==`
-> stack should be 1.000000
`del`
## complex expm (2)
`(1,-2) expm`
`(1,-2) exp 1 - ==`
-> stack should be 1.000000
`del`
## complex expm (3)
`(-1,-2) expm`
`(-1,-2) exp 1 - ==`
-> stack should be 1.000000
`del`
## complex expm (4)
`(-1,2) expm`
`(-1,2) exp 1 - ==`
-> stack should be 1.000000
`del`
## complex alog2 (1)
`(1,2) alog2`
-> stack should be (0.366914,1.966055)
`del`
## complex alog2 (2)
`(1,-2) alog2`
-> stack should be (0.366914,-1.966055)
`del`
## complex alog2 (3)
`(-1,-2) alog2`
-> stack should be (0.091728,-0.491514)
`del`
## complex alog2 (4)
`(-1,2) alog2`
-> stack should be (0.091728,0.491514)
`del`
## complex alog10 (1)
`(1,2) alog10`
-> stack should be (-1.070135,-9.942576)
`del`
## complex alog10 (2)
`(1,-2) alog10`
-> stack should be (-1.070135,9.942576)
`del`
## complex alog10 (3)
`(-1,-2) alog10`
-> stack should be (-0.010701,0.099426)
`del`
## complex alog10 (4)
`(-1,2) alog10`
-> stack should be (-0.010701,-0.099426)
`del`
## complex sinh (1)
`(1,2) sinh`
-> stack should be (-0.489056,1.403119)
`del`
## complex sinh (2)
`(1,-2) sinh`
-> stack should be (-0.489056,-1.403119)
`del`
## complex sinh (3)
`(-1,-2) sinh`
-> stack should be (0.489056,-1.403119)
`del`
## complex sinh (4)
`(-1,2) sinh`
-> stack should be (0.489056,1.403119)
`del`
## complex asinh (1)
`(1,2) asinh`
-> stack should be (1.469352,1.063440)
`del`
## complex asinh (2)
`(1,-2) asinh`
-> stack should be (1.469352,-1.063440)
`del`
## complex asinh (3)
`(-1,-2) asinh`
-> stack should be (-1.469352,-1.063440)
`del`
## complex asinh (4)
`(-1,2) asinh`
-> stack should be (-1.469352,1.063440)
`del`
## complex cosh (1)
`(1,2) cosh`
-> stack should be (-0.489056,1.403119)
`del`
## complex cosh (2)
`(1,-2) cosh`
-> stack should be (-0.489056,-1.403119)
`del`
## complex cosh (3)
`(-1,-2) cosh`
-> stack should be (0.489056,-1.403119)
`del`
## complex cosh (4)
`(-1,2) cosh`
-> stack should be (0.489056,1.403119)
`del`
## complex acosh (1)
`(1,2) acosh`
-> stack should be (1.528571,1.143718)
`del`
## complex acosh (2)
`(1,-2) acosh`
-> stack should be (1.528571,-1.143718)
`del`
## complex acosh (3)
`(-1,-2) acosh`
-> stack should be (-1.528571,1.997875)
`del`
## complex acosh (4)
`(-1,2) acosh`
-> stack should be (-1.528571,-1.997875)
`del`
## complex tanh (1)
`(1,2) tanh`
-> stack should be (0.564133,-0.217934)
`del`
## complex tanh (2)
`(1,-2) tanh`
-> stack should be (0.564133,0.217934)
`del`
## complex tanh (3)
`(-1,-2) tanh`
-> stack should be (-0.564133,0.217934)
`del`
## complex tanh (4)
`(-1,2) tanh`
-> stack should be (-0.564133,-0.217934)
`del`
## complex atanh (1)
`(1,2) atanh`
-> stack should be (0.173287,1.178097)
`del`
## complex atanh (2)
`(1,-2) atanh`
-> stack should be (0.173287,-1.178097)
`del`
## complex atanh (3)
`(-1,-2) atanh`
-> stack should be (-0.173287,-1.178097)
`del`
## complex atanh (4)
`(-1,2) atanh`
-> stack should be (-0.173287,1.178097)
`del`

View file

@ -17,6 +17,8 @@
@include 070-test.md
@include 080-store.md
@include 090-program.md
# @include 100-complex.md
@include 100-complex.md
# @include 110-time.md
# @include 120-trig.md
# @include 120-logs.md
# @include 999-manual-tests.md