1 /** @file inifcns_trans.cpp
3 * Implementation of transcendental (and trigonometric and hyperbolic)
7 * GiNaC Copyright (C) 1999-2023 Johannes Gutenberg University Mainz, Germany
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #include "operators.h"
32 #include "relational.h"
43 // exponential function
46 static ex exp_evalf(const ex & x)
48 if (is_exactly_a<numeric>(x))
49 return exp(ex_to<numeric>(x));
54 static ex exp_eval(const ex & x)
61 // exp(n*Pi*I/2) -> {+1|+I|-1|-I}
62 const ex TwoExOverPiI=(_ex2*x)/(Pi*I);
63 if (TwoExOverPiI.info(info_flags::integer)) {
64 const numeric z = mod(ex_to<numeric>(TwoExOverPiI),*_num4_p);
65 if (z.is_equal(*_num0_p))
67 if (z.is_equal(*_num1_p))
69 if (z.is_equal(*_num2_p))
71 if (z.is_equal(*_num3_p))
76 if (is_ex_the_function(x, log))
79 // exp(float) -> float
80 if (x.info(info_flags::numeric) && !x.info(info_flags::crational))
81 return exp(ex_to<numeric>(x));
86 static ex exp_expand(const ex & arg, unsigned options)
89 if (options & expand_options::expand_function_args)
90 exp_arg = arg.expand(options);
94 if ((options & expand_options::expand_transcendental)
95 && is_exactly_a<add>(exp_arg)) {
97 prodseq.reserve(exp_arg.nops());
98 for (const_iterator i = exp_arg.begin(); i != exp_arg.end(); ++i)
99 prodseq.push_back(exp(*i));
101 return dynallocate<mul>(prodseq).setflag(status_flags::expanded);
104 return exp(exp_arg).hold();
107 static ex exp_deriv(const ex & x, unsigned deriv_param)
109 GINAC_ASSERT(deriv_param==0);
111 // d/dx exp(x) -> exp(x)
115 static ex exp_real_part(const ex & x)
117 return exp(GiNaC::real_part(x))*cos(GiNaC::imag_part(x));
120 static ex exp_imag_part(const ex & x)
122 return exp(GiNaC::real_part(x))*sin(GiNaC::imag_part(x));
125 static ex exp_conjugate(const ex & x)
127 // conjugate(exp(x))==exp(conjugate(x))
128 return exp(x.conjugate());
131 static ex exp_power(const ex & x, const ex & a)
134 * The power law (e^x)^a=e^(x*a) is used in two cases:
135 * a) a is an integer and x may be complex;
136 * b) both x and a are reals.
137 * Negative a is excluded to keep automatic simplifications like exp(x)/exp(x)=1.
139 if (a.info(info_flags::nonnegative)
140 && (a.info(info_flags::integer) || (x.info(info_flags::real) && a.info(info_flags::real))))
142 else if (a.info(info_flags::negative)
143 && (a.info(info_flags::integer) || (x.info(info_flags::real) && a.info(info_flags::real))))
144 return power(exp(-x*a), _ex_1).hold();
146 return power(exp(x), a).hold();
149 static bool exp_info(const ex & x, unsigned inf)
152 case info_flags::numeric:
153 case info_flags::expanded:
154 case info_flags::real:
156 case info_flags::positive:
157 case info_flags::nonnegative:
158 return x.info(info_flags::real);
164 REGISTER_FUNCTION(exp, eval_func(exp_eval).
165 evalf_func(exp_evalf).
167 expand_func(exp_expand).
168 derivative_func(exp_deriv).
169 real_part_func(exp_real_part).
170 imag_part_func(exp_imag_part).
171 conjugate_func(exp_conjugate).
172 power_func(exp_power).
173 latex_name("\\exp"));
179 static ex log_evalf(const ex & x)
181 if (is_exactly_a<numeric>(x))
182 return log(ex_to<numeric>(x));
184 return log(x).hold();
187 static ex log_eval(const ex & x)
189 if (x.info(info_flags::numeric)) {
190 if (x.is_zero()) // log(0) -> infinity
191 throw(pole_error("log_eval(): log(0)",0));
192 if (x.info(info_flags::rational) && x.info(info_flags::negative))
193 return (log(-x)+I*Pi);
194 if (x.is_equal(_ex1)) // log(1) -> 0
196 if (x.is_equal(I)) // log(I) -> Pi*I/2
197 return (Pi*I*_ex1_2);
198 if (x.is_equal(-I)) // log(-I) -> -Pi*I/2
199 return (Pi*I*_ex_1_2);
201 // log(float) -> float
202 if (!x.info(info_flags::crational))
203 return log(ex_to<numeric>(x));
206 // log(exp(t)) -> t (if -Pi < t.imag() <= Pi):
207 if (is_ex_the_function(x, exp)) {
208 const ex &t = x.op(0);
209 if (t.info(info_flags::real))
213 return log(x).hold();
216 static ex log_deriv(const ex & x, unsigned deriv_param)
218 GINAC_ASSERT(deriv_param==0);
220 // d/dx log(x) -> 1/x
221 return power(x, _ex_1);
224 static ex log_series(const ex &arg,
225 const relational &rel,
229 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
231 bool must_expand_arg = false;
232 // maybe substitution of rel into arg fails because of a pole
234 arg_pt = arg.subs(rel, subs_options::no_pattern);
235 } catch (pole_error &) {
236 must_expand_arg = true;
238 // or we are at the branch point anyways
239 if (arg_pt.is_zero())
240 must_expand_arg = true;
242 if (arg.diff(ex_to<symbol>(rel.lhs())).is_zero()) {
246 if (must_expand_arg) {
248 // This is the branch point: Series expand the argument first, then
249 // trivially factorize it to isolate that part which has constant
250 // leading coefficient in this fashion:
251 // x^n + x^(n+1) +...+ Order(x^(n+m)) -> x^n * (1 + x +...+ Order(x^m)).
252 // Return a plain n*log(x) for the x^n part and series expand the
253 // other part. Add them together and reexpand again in order to have
254 // one unnested pseries object. All this also works for negative n.
255 pseries argser; // series expansion of log's argument
256 unsigned extra_ord = 0; // extra expansion order
258 // oops, the argument expanded to a pure Order(x^something)...
259 argser = ex_to<pseries>(arg.series(rel, order+extra_ord, options));
261 } while (!argser.is_terminating() && argser.nops()==1);
263 const symbol &s = ex_to<symbol>(rel.lhs());
264 const ex &point = rel.rhs();
265 const int n = argser.ldegree(s);
267 // construct what we carelessly called the n*log(x) term above
268 const ex coeff = argser.coeff(s, n);
269 // expand the log, but only if coeff is real and > 0, since otherwise
270 // it would make the branch cut run into the wrong direction
271 if (coeff.info(info_flags::positive))
272 seq.push_back(expair(n*log(s-point)+log(coeff), _ex0));
274 seq.push_back(expair(log(coeff*pow(s-point, n)), _ex0));
276 if (!argser.is_terminating() || argser.nops()!=1) {
277 // in this case n more (or less) terms are needed
278 // (sadly, to generate them, we have to start from the beginning)
279 if (n == 0 && coeff == 1) {
280 ex rest = pseries(rel, epvector{expair(-1, _ex0), expair(Order(_ex1), order)}).add_series(argser);
281 ex acc = dynallocate<pseries>(rel, epvector());
282 for (int i = order-1; i>0; --i) {
283 epvector cterm { expair(i%2 ? _ex1/i : _ex_1/i, _ex0) };
284 acc = pseries(rel, std::move(cterm)).add_series(ex_to<pseries>(acc));
285 acc = (ex_to<pseries>(rest)).mul_series(ex_to<pseries>(acc));
289 const ex newarg = ex_to<pseries>((arg/coeff).series(rel, order+n, options)).shift_exponents(-n).convert_to_poly(true);
290 return pseries(rel, std::move(seq)).add_series(ex_to<pseries>(log(newarg).series(rel, order, options)));
291 } else // it was a monomial
292 return pseries(rel, std::move(seq));
294 if (!(options & series_options::suppress_branchcut) &&
295 arg_pt.info(info_flags::negative)) {
297 // This is the branch cut: assemble the primitive series manually and
298 // then add the corresponding complex step function.
299 const symbol &s = ex_to<symbol>(rel.lhs());
300 const ex &point = rel.rhs();
302 const ex replarg = series(log(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
306 seq.push_back(expair(-I*csgn(arg*I)*Pi, _ex0));
308 seq.push_back(expair(Order(_ex1), order));
309 return series(replarg - I*Pi + pseries(rel, std::move(seq)), rel, order);
311 throw do_taylor(); // caught by function::series()
314 static ex log_real_part(const ex & x)
316 if (x.info(info_flags::nonnegative))
317 return log(x).hold();
321 static ex log_imag_part(const ex & x)
323 if (x.info(info_flags::nonnegative))
325 return atan2(GiNaC::imag_part(x), GiNaC::real_part(x));
328 static ex log_expand(const ex & arg, unsigned options)
330 if ((options & expand_options::expand_transcendental)
331 && is_exactly_a<mul>(arg) && !arg.info(info_flags::indefinite)) {
334 sumseq.reserve(arg.nops());
335 prodseq.reserve(arg.nops());
338 // searching for positive/negative factors
339 for (const_iterator i = arg.begin(); i != arg.end(); ++i) {
341 if (options & expand_options::expand_function_args)
342 e=i->expand(options);
345 if (e.info(info_flags::positive))
346 sumseq.push_back(log(e));
347 else if (e.info(info_flags::negative)) {
348 sumseq.push_back(log(-e));
351 prodseq.push_back(e);
354 if (sumseq.size() > 0) {
356 if (options & expand_options::expand_function_args)
357 newarg=((possign?_ex1:_ex_1)*mul(prodseq)).expand(options);
359 newarg=(possign?_ex1:_ex_1)*mul(prodseq);
360 ex_to<basic>(newarg).setflag(status_flags::purely_indefinite);
362 return add(sumseq)+log(newarg);
364 if (!(options & expand_options::expand_function_args))
365 ex_to<basic>(arg).setflag(status_flags::purely_indefinite);
369 if (options & expand_options::expand_function_args)
370 return log(arg.expand(options)).hold();
372 return log(arg).hold();
375 static ex log_conjugate(const ex & x)
377 // conjugate(log(x))==log(conjugate(x)) unless on the branch cut which
378 // runs along the negative real axis.
379 if (x.info(info_flags::positive)) {
382 if (is_exactly_a<numeric>(x) &&
383 !x.imag_part().is_zero()) {
384 return log(x.conjugate());
386 return conjugate_function(log(x)).hold();
389 static bool log_info(const ex & x, unsigned inf)
392 case info_flags::numeric:
393 case info_flags::expanded:
395 case info_flags::real:
396 return x.info(info_flags::positive);
402 REGISTER_FUNCTION(log, eval_func(log_eval).
403 evalf_func(log_evalf).
405 expand_func(log_expand).
406 derivative_func(log_deriv).
407 series_func(log_series).
408 real_part_func(log_real_part).
409 imag_part_func(log_imag_part).
410 conjugate_func(log_conjugate).
414 // sine (trigonometric function)
417 static ex sin_evalf(const ex & x)
419 if (is_exactly_a<numeric>(x))
420 return sin(ex_to<numeric>(x));
422 return sin(x).hold();
425 static ex sin_eval(const ex & x)
427 // sin(n/d*Pi) -> { all known non-nested radicals }
428 const ex SixtyExOverPi = _ex60*x/Pi;
430 if (SixtyExOverPi.info(info_flags::integer)) {
431 numeric z = mod(ex_to<numeric>(SixtyExOverPi),*_num120_p);
433 // wrap to interval [0, Pi)
438 // wrap to interval [0, Pi/2)
441 if (z.is_equal(*_num0_p)) // sin(0) -> 0
443 if (z.is_equal(*_num5_p)) // sin(Pi/12) -> sqrt(6)/4*(1-sqrt(3)/3)
444 return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex_1_3*sqrt(_ex3));
445 if (z.is_equal(*_num6_p)) // sin(Pi/10) -> sqrt(5)/4-1/4
446 return sign*(_ex1_4*sqrt(_ex5)+_ex_1_4);
447 if (z.is_equal(*_num10_p)) // sin(Pi/6) -> 1/2
449 if (z.is_equal(*_num15_p)) // sin(Pi/4) -> sqrt(2)/2
450 return sign*_ex1_2*sqrt(_ex2);
451 if (z.is_equal(*_num18_p)) // sin(3/10*Pi) -> sqrt(5)/4+1/4
452 return sign*(_ex1_4*sqrt(_ex5)+_ex1_4);
453 if (z.is_equal(*_num20_p)) // sin(Pi/3) -> sqrt(3)/2
454 return sign*_ex1_2*sqrt(_ex3);
455 if (z.is_equal(*_num25_p)) // sin(5/12*Pi) -> sqrt(6)/4*(1+sqrt(3)/3)
456 return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex1_3*sqrt(_ex3));
457 if (z.is_equal(*_num30_p)) // sin(Pi/2) -> 1
461 if (is_exactly_a<function>(x)) {
462 const ex &t = x.op(0);
465 if (is_ex_the_function(x, asin))
468 // sin(acos(x)) -> sqrt(1-x^2)
469 if (is_ex_the_function(x, acos))
470 return sqrt(_ex1-power(t,_ex2));
472 // sin(atan(x)) -> x/sqrt(1+x^2)
473 if (is_ex_the_function(x, atan))
474 return t*power(_ex1+power(t,_ex2),_ex_1_2);
477 // sin(float) -> float
478 if (x.info(info_flags::numeric) && !x.info(info_flags::crational))
479 return sin(ex_to<numeric>(x));
482 if (x.info(info_flags::negative))
485 return sin(x).hold();
488 static ex sin_deriv(const ex & x, unsigned deriv_param)
490 GINAC_ASSERT(deriv_param==0);
492 // d/dx sin(x) -> cos(x)
496 static ex sin_real_part(const ex & x)
498 return cosh(GiNaC::imag_part(x))*sin(GiNaC::real_part(x));
501 static ex sin_imag_part(const ex & x)
503 return sinh(GiNaC::imag_part(x))*cos(GiNaC::real_part(x));
506 static ex sin_conjugate(const ex & x)
508 // conjugate(sin(x))==sin(conjugate(x))
509 return sin(x.conjugate());
512 static bool trig_info(const ex & x, unsigned inf)
515 case info_flags::numeric:
516 case info_flags::expanded:
517 case info_flags::real:
524 REGISTER_FUNCTION(sin, eval_func(sin_eval).
525 evalf_func(sin_evalf).
526 info_func(trig_info).
527 derivative_func(sin_deriv).
528 real_part_func(sin_real_part).
529 imag_part_func(sin_imag_part).
530 conjugate_func(sin_conjugate).
531 latex_name("\\sin"));
534 // cosine (trigonometric function)
537 static ex cos_evalf(const ex & x)
539 if (is_exactly_a<numeric>(x))
540 return cos(ex_to<numeric>(x));
542 return cos(x).hold();
545 static ex cos_eval(const ex & x)
547 // cos(n/d*Pi) -> { all known non-nested radicals }
548 const ex SixtyExOverPi = _ex60*x/Pi;
550 if (SixtyExOverPi.info(info_flags::integer)) {
551 numeric z = mod(ex_to<numeric>(SixtyExOverPi),*_num120_p);
553 // wrap to interval [0, Pi)
557 // wrap to interval [0, Pi/2)
561 if (z.is_equal(*_num0_p)) // cos(0) -> 1
563 if (z.is_equal(*_num5_p)) // cos(Pi/12) -> sqrt(6)/4*(1+sqrt(3)/3)
564 return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex1_3*sqrt(_ex3));
565 if (z.is_equal(*_num10_p)) // cos(Pi/6) -> sqrt(3)/2
566 return sign*_ex1_2*sqrt(_ex3);
567 if (z.is_equal(*_num12_p)) // cos(Pi/5) -> sqrt(5)/4+1/4
568 return sign*(_ex1_4*sqrt(_ex5)+_ex1_4);
569 if (z.is_equal(*_num15_p)) // cos(Pi/4) -> sqrt(2)/2
570 return sign*_ex1_2*sqrt(_ex2);
571 if (z.is_equal(*_num20_p)) // cos(Pi/3) -> 1/2
573 if (z.is_equal(*_num24_p)) // cos(2/5*Pi) -> sqrt(5)/4-1/4x
574 return sign*(_ex1_4*sqrt(_ex5)+_ex_1_4);
575 if (z.is_equal(*_num25_p)) // cos(5/12*Pi) -> sqrt(6)/4*(1-sqrt(3)/3)
576 return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex_1_3*sqrt(_ex3));
577 if (z.is_equal(*_num30_p)) // cos(Pi/2) -> 0
581 if (is_exactly_a<function>(x)) {
582 const ex &t = x.op(0);
585 if (is_ex_the_function(x, acos))
588 // cos(asin(x)) -> sqrt(1-x^2)
589 if (is_ex_the_function(x, asin))
590 return sqrt(_ex1-power(t,_ex2));
592 // cos(atan(x)) -> 1/sqrt(1+x^2)
593 if (is_ex_the_function(x, atan))
594 return power(_ex1+power(t,_ex2),_ex_1_2);
597 // cos(float) -> float
598 if (x.info(info_flags::numeric) && !x.info(info_flags::crational))
599 return cos(ex_to<numeric>(x));
602 if (x.info(info_flags::negative))
605 return cos(x).hold();
608 static ex cos_deriv(const ex & x, unsigned deriv_param)
610 GINAC_ASSERT(deriv_param==0);
612 // d/dx cos(x) -> -sin(x)
616 static ex cos_real_part(const ex & x)
618 return cosh(GiNaC::imag_part(x))*cos(GiNaC::real_part(x));
621 static ex cos_imag_part(const ex & x)
623 return -sinh(GiNaC::imag_part(x))*sin(GiNaC::real_part(x));
626 static ex cos_conjugate(const ex & x)
628 // conjugate(cos(x))==cos(conjugate(x))
629 return cos(x.conjugate());
632 REGISTER_FUNCTION(cos, eval_func(cos_eval).
633 info_func(trig_info).
634 evalf_func(cos_evalf).
635 derivative_func(cos_deriv).
636 real_part_func(cos_real_part).
637 imag_part_func(cos_imag_part).
638 conjugate_func(cos_conjugate).
639 latex_name("\\cos"));
642 // tangent (trigonometric function)
645 static ex tan_evalf(const ex & x)
647 if (is_exactly_a<numeric>(x))
648 return tan(ex_to<numeric>(x));
650 return tan(x).hold();
653 static ex tan_eval(const ex & x)
655 // tan(n/d*Pi) -> { all known non-nested radicals }
656 const ex SixtyExOverPi = _ex60*x/Pi;
658 if (SixtyExOverPi.info(info_flags::integer)) {
659 numeric z = mod(ex_to<numeric>(SixtyExOverPi),*_num60_p);
661 // wrap to interval [0, Pi)
665 // wrap to interval [0, Pi/2)
669 if (z.is_equal(*_num0_p)) // tan(0) -> 0
671 if (z.is_equal(*_num5_p)) // tan(Pi/12) -> 2-sqrt(3)
672 return sign*(_ex2-sqrt(_ex3));
673 if (z.is_equal(*_num10_p)) // tan(Pi/6) -> sqrt(3)/3
674 return sign*_ex1_3*sqrt(_ex3);
675 if (z.is_equal(*_num15_p)) // tan(Pi/4) -> 1
677 if (z.is_equal(*_num20_p)) // tan(Pi/3) -> sqrt(3)
678 return sign*sqrt(_ex3);
679 if (z.is_equal(*_num25_p)) // tan(5/12*Pi) -> 2+sqrt(3)
680 return sign*(sqrt(_ex3)+_ex2);
681 if (z.is_equal(*_num30_p)) // tan(Pi/2) -> infinity
682 throw (pole_error("tan_eval(): simple pole",1));
685 if (is_exactly_a<function>(x)) {
686 const ex &t = x.op(0);
689 if (is_ex_the_function(x, atan))
692 // tan(asin(x)) -> x/sqrt(1+x^2)
693 if (is_ex_the_function(x, asin))
694 return t*power(_ex1-power(t,_ex2),_ex_1_2);
696 // tan(acos(x)) -> sqrt(1-x^2)/x
697 if (is_ex_the_function(x, acos))
698 return power(t,_ex_1)*sqrt(_ex1-power(t,_ex2));
701 // tan(float) -> float
702 if (x.info(info_flags::numeric) && !x.info(info_flags::crational)) {
703 return tan(ex_to<numeric>(x));
707 if (x.info(info_flags::negative))
710 return tan(x).hold();
713 static ex tan_deriv(const ex & x, unsigned deriv_param)
715 GINAC_ASSERT(deriv_param==0);
717 // d/dx tan(x) -> 1+tan(x)^2;
718 return (_ex1+power(tan(x),_ex2));
721 static ex tan_real_part(const ex & x)
723 ex a = GiNaC::real_part(x);
724 ex b = GiNaC::imag_part(x);
725 return tan(a)/(1+power(tan(a),2)*power(tan(b),2));
728 static ex tan_imag_part(const ex & x)
730 ex a = GiNaC::real_part(x);
731 ex b = GiNaC::imag_part(x);
732 return tanh(b)/(1+power(tan(a),2)*power(tan(b),2));
735 static ex tan_series(const ex &x,
736 const relational &rel,
740 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
742 // Taylor series where there is no pole falls back to tan_deriv.
743 // On a pole simply expand sin(x)/cos(x).
744 const ex x_pt = x.subs(rel, subs_options::no_pattern);
745 if (!(2*x_pt/Pi).info(info_flags::odd))
746 throw do_taylor(); // caught by function::series()
747 // if we got here we have to care for a simple pole
748 return (sin(x)/cos(x)).series(rel, order, options);
751 static ex tan_conjugate(const ex & x)
753 // conjugate(tan(x))==tan(conjugate(x))
754 return tan(x.conjugate());
757 REGISTER_FUNCTION(tan, eval_func(tan_eval).
758 evalf_func(tan_evalf).
759 info_func(trig_info).
760 derivative_func(tan_deriv).
761 series_func(tan_series).
762 real_part_func(tan_real_part).
763 imag_part_func(tan_imag_part).
764 conjugate_func(tan_conjugate).
765 latex_name("\\tan"));
768 // inverse sine (arc sine)
771 static ex asin_evalf(const ex & x)
773 if (is_exactly_a<numeric>(x))
774 return asin(ex_to<numeric>(x));
776 return asin(x).hold();
779 static ex asin_eval(const ex & x)
781 if (x.info(info_flags::numeric)) {
788 if (x.is_equal(_ex1_2))
789 return numeric(1,6)*Pi;
792 if (x.is_equal(_ex1))
795 // asin(-1/2) -> -Pi/6
796 if (x.is_equal(_ex_1_2))
797 return numeric(-1,6)*Pi;
800 if (x.is_equal(_ex_1))
803 // asin(float) -> float
804 if (!x.info(info_flags::crational))
805 return asin(ex_to<numeric>(x));
808 if (x.info(info_flags::negative))
812 return asin(x).hold();
815 static ex asin_deriv(const ex & x, unsigned deriv_param)
817 GINAC_ASSERT(deriv_param==0);
819 // d/dx asin(x) -> 1/sqrt(1-x^2)
820 return power(1-power(x,_ex2),_ex_1_2);
823 static ex asin_conjugate(const ex & x)
825 // conjugate(asin(x))==asin(conjugate(x)) unless on the branch cuts which
826 // run along the real axis outside the interval [-1, +1].
827 if (is_exactly_a<numeric>(x) &&
828 (!x.imag_part().is_zero() || (x > *_num_1_p && x < *_num1_p))) {
829 return asin(x.conjugate());
831 return conjugate_function(asin(x)).hold();
834 static bool asin_info(const ex & x, unsigned inf)
837 case info_flags::numeric:
838 case info_flags::expanded:
845 REGISTER_FUNCTION(asin, eval_func(asin_eval).
846 evalf_func(asin_evalf).
847 info_func(asin_info).
848 derivative_func(asin_deriv).
849 conjugate_func(asin_conjugate).
850 latex_name("\\arcsin"));
853 // inverse cosine (arc cosine)
856 static ex acos_evalf(const ex & x)
858 if (is_exactly_a<numeric>(x))
859 return acos(ex_to<numeric>(x));
861 return acos(x).hold();
864 static ex acos_eval(const ex & x)
866 if (x.info(info_flags::numeric)) {
869 if (x.is_equal(_ex1))
873 if (x.is_equal(_ex1_2))
880 // acos(-1/2) -> 2/3*Pi
881 if (x.is_equal(_ex_1_2))
882 return numeric(2,3)*Pi;
885 if (x.is_equal(_ex_1))
888 // acos(float) -> float
889 if (!x.info(info_flags::crational))
890 return acos(ex_to<numeric>(x));
892 // acos(-x) -> Pi-acos(x)
893 if (x.info(info_flags::negative))
897 return acos(x).hold();
900 static ex acos_deriv(const ex & x, unsigned deriv_param)
902 GINAC_ASSERT(deriv_param==0);
904 // d/dx acos(x) -> -1/sqrt(1-x^2)
905 return -power(1-power(x,_ex2),_ex_1_2);
908 static ex acos_conjugate(const ex & x)
910 // conjugate(acos(x))==acos(conjugate(x)) unless on the branch cuts which
911 // run along the real axis outside the interval [-1, +1].
912 if (is_exactly_a<numeric>(x) &&
913 (!x.imag_part().is_zero() || (x > *_num_1_p && x < *_num1_p))) {
914 return acos(x.conjugate());
916 return conjugate_function(acos(x)).hold();
919 REGISTER_FUNCTION(acos, eval_func(acos_eval).
920 evalf_func(acos_evalf).
921 info_func(asin_info). // Flags of acos are shared with asin functions
922 derivative_func(acos_deriv).
923 conjugate_func(acos_conjugate).
924 latex_name("\\arccos"));
927 // inverse tangent (arc tangent)
930 static ex atan_evalf(const ex & x)
932 if (is_exactly_a<numeric>(x))
933 return atan(ex_to<numeric>(x));
935 return atan(x).hold();
938 static ex atan_eval(const ex & x)
940 if (x.info(info_flags::numeric)) {
947 if (x.is_equal(_ex1))
951 if (x.is_equal(_ex_1))
954 if (x.is_equal(I) || x.is_equal(-I))
955 throw (pole_error("atan_eval(): logarithmic pole",0));
957 // atan(float) -> float
958 if (!x.info(info_flags::crational))
959 return atan(ex_to<numeric>(x));
962 if (x.info(info_flags::negative))
966 return atan(x).hold();
969 static ex atan_deriv(const ex & x, unsigned deriv_param)
971 GINAC_ASSERT(deriv_param==0);
973 // d/dx atan(x) -> 1/(1+x^2)
974 return power(_ex1+power(x,_ex2), _ex_1);
977 static ex atan_series(const ex &arg,
978 const relational &rel,
982 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
984 // Taylor series where there is no pole or cut falls back to atan_deriv.
985 // There are two branch cuts, one runnig from I up the imaginary axis and
986 // one running from -I down the imaginary axis. The points I and -I are
988 // On the branch cuts and the poles series expand
989 // (log(1+I*x)-log(1-I*x))/(2*I)
991 const ex arg_pt = arg.subs(rel, subs_options::no_pattern);
992 if (!(I*arg_pt).info(info_flags::real))
993 throw do_taylor(); // Re(x) != 0
994 if ((I*arg_pt).info(info_flags::real) && abs(I*arg_pt)<_ex1)
995 throw do_taylor(); // Re(x) == 0, but abs(x)<1
996 // care for the poles, using the defining formula for atan()...
997 if (arg_pt.is_equal(I) || arg_pt.is_equal(-I))
998 return ((log(1+I*arg)-log(1-I*arg))/(2*I)).series(rel, order, options);
999 if (!(options & series_options::suppress_branchcut)) {
1001 // This is the branch cut: assemble the primitive series manually and
1002 // then add the corresponding complex step function.
1003 const symbol &s = ex_to<symbol>(rel.lhs());
1004 const ex &point = rel.rhs();
1006 const ex replarg = series(atan(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
1007 ex Order0correction = replarg.op(0)+csgn(arg)*Pi*_ex_1_2;
1008 if ((I*arg_pt)<_ex0)
1009 Order0correction += log((I*arg_pt+_ex_1)/(I*arg_pt+_ex1))*I*_ex_1_2;
1011 Order0correction += log((I*arg_pt+_ex1)/(I*arg_pt+_ex_1))*I*_ex1_2;
1015 seq.push_back(expair(Order0correction, _ex0));
1017 seq.push_back(expair(Order(_ex1), order));
1018 return series(replarg - pseries(rel, std::move(seq)), rel, order);
1023 static ex atan_conjugate(const ex & x)
1025 // conjugate(atan(x))==atan(conjugate(x)) unless on the branch cuts which
1026 // run along the imaginary axis outside the interval [-I, +I].
1027 if (x.info(info_flags::real))
1029 if (is_exactly_a<numeric>(x)) {
1030 const numeric x_re = ex_to<numeric>(x.real_part());
1031 const numeric x_im = ex_to<numeric>(x.imag_part());
1032 if (!x_re.is_zero() ||
1033 (x_im > *_num_1_p && x_im < *_num1_p))
1034 return atan(x.conjugate());
1036 return conjugate_function(atan(x)).hold();
1039 static bool atan_info(const ex & x, unsigned inf)
1042 case info_flags::numeric:
1043 case info_flags::expanded:
1044 case info_flags::real:
1046 case info_flags::positive:
1047 case info_flags::negative:
1048 case info_flags::nonnegative:
1049 return x.info(info_flags::real) && x.info(inf);
1055 REGISTER_FUNCTION(atan, eval_func(atan_eval).
1056 evalf_func(atan_evalf).
1057 info_func(atan_info).
1058 derivative_func(atan_deriv).
1059 series_func(atan_series).
1060 conjugate_func(atan_conjugate).
1061 latex_name("\\arctan"));
1064 // inverse tangent (atan2(y,x))
1067 static ex atan2_evalf(const ex &y, const ex &x)
1069 if (is_exactly_a<numeric>(y) && is_exactly_a<numeric>(x))
1070 return atan(ex_to<numeric>(y), ex_to<numeric>(x));
1072 return atan2(y, x).hold();
1075 static ex atan2_eval(const ex & y, const ex & x)
1083 // atan2(0, x), x real and positive -> 0
1084 if (x.info(info_flags::positive))
1087 // atan2(0, x), x real and negative -> Pi
1088 if (x.info(info_flags::negative))
1094 // atan2(y, 0), y real and positive -> Pi/2
1095 if (y.info(info_flags::positive))
1098 // atan2(y, 0), y real and negative -> -Pi/2
1099 if (y.info(info_flags::negative))
1103 if (y.is_equal(x)) {
1105 // atan2(y, y), y real and positive -> Pi/4
1106 if (y.info(info_flags::positive))
1109 // atan2(y, y), y real and negative -> -3/4*Pi
1110 if (y.info(info_flags::negative))
1111 return numeric(-3, 4)*Pi;
1114 if (y.is_equal(-x)) {
1116 // atan2(y, -y), y real and positive -> 3*Pi/4
1117 if (y.info(info_flags::positive))
1118 return numeric(3, 4)*Pi;
1120 // atan2(y, -y), y real and negative -> -Pi/4
1121 if (y.info(info_flags::negative))
1125 // atan2(float, float) -> float
1126 if (is_a<numeric>(y) && !y.info(info_flags::crational) &&
1127 is_a<numeric>(x) && !x.info(info_flags::crational))
1128 return atan(ex_to<numeric>(y), ex_to<numeric>(x));
1130 // atan2(real, real) -> atan(y/x) +/- Pi
1131 if (y.info(info_flags::real) && x.info(info_flags::real)) {
1132 if (x.info(info_flags::positive))
1135 if (x.info(info_flags::negative)) {
1136 if (y.info(info_flags::positive))
1137 return atan(y/x)+Pi;
1138 if (y.info(info_flags::negative))
1139 return atan(y/x)-Pi;
1143 return atan2(y, x).hold();
1146 static ex atan2_deriv(const ex & y, const ex & x, unsigned deriv_param)
1148 GINAC_ASSERT(deriv_param<2);
1150 if (deriv_param==0) {
1152 return x*power(power(x,_ex2)+power(y,_ex2),_ex_1);
1155 return -y*power(power(x,_ex2)+power(y,_ex2),_ex_1);
1158 static bool atan2_info(const ex & y, const ex & x, unsigned inf)
1161 case info_flags::numeric:
1162 case info_flags::expanded:
1163 case info_flags::real:
1164 return y.info(inf) && x.info(inf);
1165 case info_flags::positive:
1166 case info_flags::negative:
1167 case info_flags::nonnegative:
1168 return y.info(info_flags::real) && x.info(info_flags::real)
1175 REGISTER_FUNCTION(atan2, eval_func(atan2_eval).
1176 evalf_func(atan2_evalf).
1177 info_func(atan2_info).
1178 evalf_func(atan2_evalf).
1179 derivative_func(atan2_deriv));
1182 // hyperbolic sine (trigonometric function)
1185 static ex sinh_evalf(const ex & x)
1187 if (is_exactly_a<numeric>(x))
1188 return sinh(ex_to<numeric>(x));
1190 return sinh(x).hold();
1193 static ex sinh_eval(const ex & x)
1195 if (x.info(info_flags::numeric)) {
1201 // sinh(float) -> float
1202 if (!x.info(info_flags::crational))
1203 return sinh(ex_to<numeric>(x));
1206 if (x.info(info_flags::negative))
1210 if ((x/Pi).info(info_flags::numeric) &&
1211 ex_to<numeric>(x/Pi).real().is_zero()) // sinh(I*x) -> I*sin(x)
1214 if (is_exactly_a<function>(x)) {
1215 const ex &t = x.op(0);
1217 // sinh(asinh(x)) -> x
1218 if (is_ex_the_function(x, asinh))
1221 // sinh(acosh(x)) -> sqrt(x-1) * sqrt(x+1)
1222 if (is_ex_the_function(x, acosh))
1223 return sqrt(t-_ex1)*sqrt(t+_ex1);
1225 // sinh(atanh(x)) -> x/sqrt(1-x^2)
1226 if (is_ex_the_function(x, atanh))
1227 return t*power(_ex1-power(t,_ex2),_ex_1_2);
1230 return sinh(x).hold();
1233 static ex sinh_deriv(const ex & x, unsigned deriv_param)
1235 GINAC_ASSERT(deriv_param==0);
1237 // d/dx sinh(x) -> cosh(x)
1241 static ex sinh_real_part(const ex & x)
1243 return sinh(GiNaC::real_part(x))*cos(GiNaC::imag_part(x));
1246 static ex sinh_imag_part(const ex & x)
1248 return cosh(GiNaC::real_part(x))*sin(GiNaC::imag_part(x));
1251 static ex sinh_conjugate(const ex & x)
1253 // conjugate(sinh(x))==sinh(conjugate(x))
1254 return sinh(x.conjugate());
1257 REGISTER_FUNCTION(sinh, eval_func(sinh_eval).
1258 evalf_func(sinh_evalf).
1259 info_func(atan_info). // Flags of sinh are shared with atan functions
1260 derivative_func(sinh_deriv).
1261 real_part_func(sinh_real_part).
1262 imag_part_func(sinh_imag_part).
1263 conjugate_func(sinh_conjugate).
1264 latex_name("\\sinh"));
1267 // hyperbolic cosine (trigonometric function)
1270 static ex cosh_evalf(const ex & x)
1272 if (is_exactly_a<numeric>(x))
1273 return cosh(ex_to<numeric>(x));
1275 return cosh(x).hold();
1278 static ex cosh_eval(const ex & x)
1280 if (x.info(info_flags::numeric)) {
1286 // cosh(float) -> float
1287 if (!x.info(info_flags::crational))
1288 return cosh(ex_to<numeric>(x));
1291 if (x.info(info_flags::negative))
1295 if ((x/Pi).info(info_flags::numeric) &&
1296 ex_to<numeric>(x/Pi).real().is_zero()) // cosh(I*x) -> cos(x)
1299 if (is_exactly_a<function>(x)) {
1300 const ex &t = x.op(0);
1302 // cosh(acosh(x)) -> x
1303 if (is_ex_the_function(x, acosh))
1306 // cosh(asinh(x)) -> sqrt(1+x^2)
1307 if (is_ex_the_function(x, asinh))
1308 return sqrt(_ex1+power(t,_ex2));
1310 // cosh(atanh(x)) -> 1/sqrt(1-x^2)
1311 if (is_ex_the_function(x, atanh))
1312 return power(_ex1-power(t,_ex2),_ex_1_2);
1315 return cosh(x).hold();
1318 static ex cosh_deriv(const ex & x, unsigned deriv_param)
1320 GINAC_ASSERT(deriv_param==0);
1322 // d/dx cosh(x) -> sinh(x)
1326 static ex cosh_real_part(const ex & x)
1328 return cosh(GiNaC::real_part(x))*cos(GiNaC::imag_part(x));
1331 static ex cosh_imag_part(const ex & x)
1333 return sinh(GiNaC::real_part(x))*sin(GiNaC::imag_part(x));
1336 static ex cosh_conjugate(const ex & x)
1338 // conjugate(cosh(x))==cosh(conjugate(x))
1339 return cosh(x.conjugate());
1342 REGISTER_FUNCTION(cosh, eval_func(cosh_eval).
1343 evalf_func(cosh_evalf).
1344 info_func(exp_info). // Flags of cosh are shared with exp functions
1345 derivative_func(cosh_deriv).
1346 real_part_func(cosh_real_part).
1347 imag_part_func(cosh_imag_part).
1348 conjugate_func(cosh_conjugate).
1349 latex_name("\\cosh"));
1352 // hyperbolic tangent (trigonometric function)
1355 static ex tanh_evalf(const ex & x)
1357 if (is_exactly_a<numeric>(x))
1358 return tanh(ex_to<numeric>(x));
1360 return tanh(x).hold();
1363 static ex tanh_eval(const ex & x)
1365 if (x.info(info_flags::numeric)) {
1371 // tanh(float) -> float
1372 if (!x.info(info_flags::crational))
1373 return tanh(ex_to<numeric>(x));
1376 if (x.info(info_flags::negative))
1380 if ((x/Pi).info(info_flags::numeric) &&
1381 ex_to<numeric>(x/Pi).real().is_zero()) // tanh(I*x) -> I*tan(x);
1384 if (is_exactly_a<function>(x)) {
1385 const ex &t = x.op(0);
1387 // tanh(atanh(x)) -> x
1388 if (is_ex_the_function(x, atanh))
1391 // tanh(asinh(x)) -> x/sqrt(1+x^2)
1392 if (is_ex_the_function(x, asinh))
1393 return t*power(_ex1+power(t,_ex2),_ex_1_2);
1395 // tanh(acosh(x)) -> sqrt(x-1)*sqrt(x+1)/x
1396 if (is_ex_the_function(x, acosh))
1397 return sqrt(t-_ex1)*sqrt(t+_ex1)*power(t,_ex_1);
1400 return tanh(x).hold();
1403 static ex tanh_deriv(const ex & x, unsigned deriv_param)
1405 GINAC_ASSERT(deriv_param==0);
1407 // d/dx tanh(x) -> 1-tanh(x)^2
1408 return _ex1-power(tanh(x),_ex2);
1411 static ex tanh_series(const ex &x,
1412 const relational &rel,
1416 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
1418 // Taylor series where there is no pole falls back to tanh_deriv.
1419 // On a pole simply expand sinh(x)/cosh(x).
1420 const ex x_pt = x.subs(rel, subs_options::no_pattern);
1421 if (!(2*I*x_pt/Pi).info(info_flags::odd))
1422 throw do_taylor(); // caught by function::series()
1423 // if we got here we have to care for a simple pole
1424 return (sinh(x)/cosh(x)).series(rel, order, options);
1427 static ex tanh_real_part(const ex & x)
1429 ex a = GiNaC::real_part(x);
1430 ex b = GiNaC::imag_part(x);
1431 return tanh(a)/(1+power(tanh(a),2)*power(tan(b),2));
1434 static ex tanh_imag_part(const ex & x)
1436 ex a = GiNaC::real_part(x);
1437 ex b = GiNaC::imag_part(x);
1438 return tan(b)/(1+power(tanh(a),2)*power(tan(b),2));
1441 static ex tanh_conjugate(const ex & x)
1443 // conjugate(tanh(x))==tanh(conjugate(x))
1444 return tanh(x.conjugate());
1447 REGISTER_FUNCTION(tanh, eval_func(tanh_eval).
1448 evalf_func(tanh_evalf).
1449 info_func(atan_info). // Flags of tanh are shared with atan functions
1450 derivative_func(tanh_deriv).
1451 series_func(tanh_series).
1452 real_part_func(tanh_real_part).
1453 imag_part_func(tanh_imag_part).
1454 conjugate_func(tanh_conjugate).
1455 latex_name("\\tanh"));
1458 // inverse hyperbolic sine (trigonometric function)
1461 static ex asinh_evalf(const ex & x)
1463 if (is_exactly_a<numeric>(x))
1464 return asinh(ex_to<numeric>(x));
1466 return asinh(x).hold();
1469 static ex asinh_eval(const ex & x)
1471 if (x.info(info_flags::numeric)) {
1477 // asinh(float) -> float
1478 if (!x.info(info_flags::crational))
1479 return asinh(ex_to<numeric>(x));
1482 if (x.info(info_flags::negative))
1486 return asinh(x).hold();
1489 static ex asinh_deriv(const ex & x, unsigned deriv_param)
1491 GINAC_ASSERT(deriv_param==0);
1493 // d/dx asinh(x) -> 1/sqrt(1+x^2)
1494 return power(_ex1+power(x,_ex2),_ex_1_2);
1497 static ex asinh_conjugate(const ex & x)
1499 // conjugate(asinh(x))==asinh(conjugate(x)) unless on the branch cuts which
1500 // run along the imaginary axis outside the interval [-I, +I].
1501 if (x.info(info_flags::real))
1503 if (is_exactly_a<numeric>(x)) {
1504 const numeric x_re = ex_to<numeric>(x.real_part());
1505 const numeric x_im = ex_to<numeric>(x.imag_part());
1506 if (!x_re.is_zero() ||
1507 (x_im > *_num_1_p && x_im < *_num1_p))
1508 return asinh(x.conjugate());
1510 return conjugate_function(asinh(x)).hold();
1513 REGISTER_FUNCTION(asinh, eval_func(asinh_eval).
1514 evalf_func(asinh_evalf).
1515 info_func(atan_info). // Flags of asinh are shared with atan functions
1516 derivative_func(asinh_deriv).
1517 conjugate_func(asinh_conjugate));
1520 // inverse hyperbolic cosine (trigonometric function)
1523 static ex acosh_evalf(const ex & x)
1525 if (is_exactly_a<numeric>(x))
1526 return acosh(ex_to<numeric>(x));
1528 return acosh(x).hold();
1531 static ex acosh_eval(const ex & x)
1533 if (x.info(info_flags::numeric)) {
1535 // acosh(0) -> Pi*I/2
1537 return Pi*I*numeric(1,2);
1540 if (x.is_equal(_ex1))
1543 // acosh(-1) -> Pi*I
1544 if (x.is_equal(_ex_1))
1547 // acosh(float) -> float
1548 if (!x.info(info_flags::crational))
1549 return acosh(ex_to<numeric>(x));
1551 // acosh(-x) -> Pi*I-acosh(x)
1552 if (x.info(info_flags::negative))
1553 return Pi*I-acosh(-x);
1556 return acosh(x).hold();
1559 static ex acosh_deriv(const ex & x, unsigned deriv_param)
1561 GINAC_ASSERT(deriv_param==0);
1563 // d/dx acosh(x) -> 1/(sqrt(x-1)*sqrt(x+1))
1564 return power(x+_ex_1,_ex_1_2)*power(x+_ex1,_ex_1_2);
1567 static ex acosh_conjugate(const ex & x)
1569 // conjugate(acosh(x))==acosh(conjugate(x)) unless on the branch cut
1570 // which runs along the real axis from +1 to -inf.
1571 if (is_exactly_a<numeric>(x) &&
1572 (!x.imag_part().is_zero() || x > *_num1_p)) {
1573 return acosh(x.conjugate());
1575 return conjugate_function(acosh(x)).hold();
1578 REGISTER_FUNCTION(acosh, eval_func(acosh_eval).
1579 evalf_func(acosh_evalf).
1580 info_func(asin_info). // Flags of acosh are shared with asin functions
1581 derivative_func(acosh_deriv).
1582 conjugate_func(acosh_conjugate));
1585 // inverse hyperbolic tangent (trigonometric function)
1588 static ex atanh_evalf(const ex & x)
1590 if (is_exactly_a<numeric>(x))
1591 return atanh(ex_to<numeric>(x));
1593 return atanh(x).hold();
1596 static ex atanh_eval(const ex & x)
1598 if (x.info(info_flags::numeric)) {
1604 // atanh({+|-}1) -> throw
1605 if (x.is_equal(_ex1) || x.is_equal(_ex_1))
1606 throw (pole_error("atanh_eval(): logarithmic pole",0));
1608 // atanh(float) -> float
1609 if (!x.info(info_flags::crational))
1610 return atanh(ex_to<numeric>(x));
1613 if (x.info(info_flags::negative))
1617 return atanh(x).hold();
1620 static ex atanh_deriv(const ex & x, unsigned deriv_param)
1622 GINAC_ASSERT(deriv_param==0);
1624 // d/dx atanh(x) -> 1/(1-x^2)
1625 return power(_ex1-power(x,_ex2),_ex_1);
1628 static ex atanh_series(const ex &arg,
1629 const relational &rel,
1633 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
1635 // Taylor series where there is no pole or cut falls back to atanh_deriv.
1636 // There are two branch cuts, one runnig from 1 up the real axis and one
1637 // one running from -1 down the real axis. The points 1 and -1 are poles
1638 // On the branch cuts and the poles series expand
1639 // (log(1+x)-log(1-x))/2
1641 const ex arg_pt = arg.subs(rel, subs_options::no_pattern);
1642 if (!(arg_pt).info(info_flags::real))
1643 throw do_taylor(); // Im(x) != 0
1644 if ((arg_pt).info(info_flags::real) && abs(arg_pt)<_ex1)
1645 throw do_taylor(); // Im(x) == 0, but abs(x)<1
1646 // care for the poles, using the defining formula for atanh()...
1647 if (arg_pt.is_equal(_ex1) || arg_pt.is_equal(_ex_1))
1648 return ((log(_ex1+arg)-log(_ex1-arg))*_ex1_2).series(rel, order, options);
1649 // ...and the branch cuts (the discontinuity at the cut being just I*Pi)
1650 if (!(options & series_options::suppress_branchcut)) {
1652 // This is the branch cut: assemble the primitive series manually and
1653 // then add the corresponding complex step function.
1654 const symbol &s = ex_to<symbol>(rel.lhs());
1655 const ex &point = rel.rhs();
1657 const ex replarg = series(atanh(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
1658 ex Order0correction = replarg.op(0)+csgn(I*arg)*Pi*I*_ex1_2;
1660 Order0correction += log((arg_pt+_ex_1)/(arg_pt+_ex1))*_ex1_2;
1662 Order0correction += log((arg_pt+_ex1)/(arg_pt+_ex_1))*_ex_1_2;
1666 seq.push_back(expair(Order0correction, _ex0));
1668 seq.push_back(expair(Order(_ex1), order));
1669 return series(replarg - pseries(rel, std::move(seq)), rel, order);
1674 static ex atanh_conjugate(const ex & x)
1676 // conjugate(atanh(x))==atanh(conjugate(x)) unless on the branch cuts which
1677 // run along the real axis outside the interval [-1, +1].
1678 if (is_exactly_a<numeric>(x) &&
1679 (!x.imag_part().is_zero() || (x > *_num_1_p && x < *_num1_p))) {
1680 return atanh(x.conjugate());
1682 return conjugate_function(atanh(x)).hold();
1685 REGISTER_FUNCTION(atanh, eval_func(atanh_eval).
1686 evalf_func(atanh_evalf).
1687 info_func(asin_info). // Flags of atanh are shared with asin functions
1688 derivative_func(atanh_deriv).
1689 series_func(atanh_series).
1690 conjugate_func(atanh_conjugate));
1693 } // namespace GiNaC