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::expanded:
153 case info_flags::real:
155 case info_flags::positive:
156 case info_flags::nonnegative:
157 return x.info(info_flags::real);
163 REGISTER_FUNCTION(exp, eval_func(exp_eval).
164 evalf_func(exp_evalf).
166 expand_func(exp_expand).
167 derivative_func(exp_deriv).
168 real_part_func(exp_real_part).
169 imag_part_func(exp_imag_part).
170 conjugate_func(exp_conjugate).
171 power_func(exp_power).
172 latex_name("\\exp"));
178 static ex log_evalf(const ex & x)
180 if (is_exactly_a<numeric>(x))
181 return log(ex_to<numeric>(x));
183 return log(x).hold();
186 static ex log_eval(const ex & x)
188 if (x.info(info_flags::numeric)) {
189 if (x.is_zero()) // log(0) -> infinity
190 throw(pole_error("log_eval(): log(0)",0));
191 if (x.info(info_flags::rational) && x.info(info_flags::negative))
192 return (log(-x)+I*Pi);
193 if (x.is_equal(_ex1)) // log(1) -> 0
195 if (x.is_equal(I)) // log(I) -> Pi*I/2
196 return (Pi*I*_ex1_2);
197 if (x.is_equal(-I)) // log(-I) -> -Pi*I/2
198 return (Pi*I*_ex_1_2);
200 // log(float) -> float
201 if (!x.info(info_flags::crational))
202 return log(ex_to<numeric>(x));
205 // log(exp(t)) -> t (if -Pi < t.imag() <= Pi):
206 if (is_ex_the_function(x, exp)) {
207 const ex &t = x.op(0);
208 if (t.info(info_flags::real))
212 return log(x).hold();
215 static ex log_deriv(const ex & x, unsigned deriv_param)
217 GINAC_ASSERT(deriv_param==0);
219 // d/dx log(x) -> 1/x
220 return power(x, _ex_1);
223 static ex log_series(const ex &arg,
224 const relational &rel,
228 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
230 bool must_expand_arg = false;
231 // maybe substitution of rel into arg fails because of a pole
233 arg_pt = arg.subs(rel, subs_options::no_pattern);
234 } catch (pole_error &) {
235 must_expand_arg = true;
237 // or we are at the branch point anyways
238 if (arg_pt.is_zero())
239 must_expand_arg = true;
241 if (arg.diff(ex_to<symbol>(rel.lhs())).is_zero()) {
245 if (must_expand_arg) {
247 // This is the branch point: Series expand the argument first, then
248 // trivially factorize it to isolate that part which has constant
249 // leading coefficient in this fashion:
250 // x^n + x^(n+1) +...+ Order(x^(n+m)) -> x^n * (1 + x +...+ Order(x^m)).
251 // Return a plain n*log(x) for the x^n part and series expand the
252 // other part. Add them together and reexpand again in order to have
253 // one unnested pseries object. All this also works for negative n.
254 pseries argser; // series expansion of log's argument
255 unsigned extra_ord = 0; // extra expansion order
257 // oops, the argument expanded to a pure Order(x^something)...
258 argser = ex_to<pseries>(arg.series(rel, order+extra_ord, options));
260 } while (!argser.is_terminating() && argser.nops()==1);
262 const symbol &s = ex_to<symbol>(rel.lhs());
263 const ex &point = rel.rhs();
264 const int n = argser.ldegree(s);
266 // construct what we carelessly called the n*log(x) term above
267 const ex coeff = argser.coeff(s, n);
268 // expand the log, but only if coeff is real and > 0, since otherwise
269 // it would make the branch cut run into the wrong direction
270 if (coeff.info(info_flags::positive))
271 seq.push_back(expair(n*log(s-point)+log(coeff), _ex0));
273 seq.push_back(expair(log(coeff*pow(s-point, n)), _ex0));
275 if (!argser.is_terminating() || argser.nops()!=1) {
276 // in this case n more (or less) terms are needed
277 // (sadly, to generate them, we have to start from the beginning)
278 if (n == 0 && coeff == 1) {
279 ex rest = pseries(rel, epvector{expair(-1, _ex0), expair(Order(_ex1), order)}).add_series(argser);
280 ex acc = dynallocate<pseries>(rel, epvector());
281 for (int i = order-1; i>0; --i) {
282 epvector cterm { expair(i%2 ? _ex1/i : _ex_1/i, _ex0) };
283 acc = pseries(rel, std::move(cterm)).add_series(ex_to<pseries>(acc));
284 acc = (ex_to<pseries>(rest)).mul_series(ex_to<pseries>(acc));
288 const ex newarg = ex_to<pseries>((arg/coeff).series(rel, order+n, options)).shift_exponents(-n).convert_to_poly(true);
289 return pseries(rel, std::move(seq)).add_series(ex_to<pseries>(log(newarg).series(rel, order, options)));
290 } else // it was a monomial
291 return pseries(rel, std::move(seq));
293 if (!(options & series_options::suppress_branchcut) &&
294 arg_pt.info(info_flags::negative)) {
296 // This is the branch cut: assemble the primitive series manually and
297 // then add the corresponding complex step function.
298 const symbol &s = ex_to<symbol>(rel.lhs());
299 const ex &point = rel.rhs();
301 const ex replarg = series(log(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
305 seq.push_back(expair(-I*csgn(arg*I)*Pi, _ex0));
307 seq.push_back(expair(Order(_ex1), order));
308 return series(replarg - I*Pi + pseries(rel, std::move(seq)), rel, order);
310 throw do_taylor(); // caught by function::series()
313 static ex log_real_part(const ex & x)
315 if (x.info(info_flags::nonnegative))
316 return log(x).hold();
320 static ex log_imag_part(const ex & x)
322 if (x.info(info_flags::nonnegative))
324 return atan2(GiNaC::imag_part(x), GiNaC::real_part(x));
327 static ex log_expand(const ex & arg, unsigned options)
329 if ((options & expand_options::expand_transcendental)
330 && is_exactly_a<mul>(arg) && !arg.info(info_flags::indefinite)) {
333 sumseq.reserve(arg.nops());
334 prodseq.reserve(arg.nops());
337 // searching for positive/negative factors
338 for (const_iterator i = arg.begin(); i != arg.end(); ++i) {
340 if (options & expand_options::expand_function_args)
341 e=i->expand(options);
344 if (e.info(info_flags::positive))
345 sumseq.push_back(log(e));
346 else if (e.info(info_flags::negative)) {
347 sumseq.push_back(log(-e));
350 prodseq.push_back(e);
353 if (sumseq.size() > 0) {
355 if (options & expand_options::expand_function_args)
356 newarg=((possign?_ex1:_ex_1)*mul(prodseq)).expand(options);
358 newarg=(possign?_ex1:_ex_1)*mul(prodseq);
359 ex_to<basic>(newarg).setflag(status_flags::purely_indefinite);
361 return add(sumseq)+log(newarg);
363 if (!(options & expand_options::expand_function_args))
364 ex_to<basic>(arg).setflag(status_flags::purely_indefinite);
368 if (options & expand_options::expand_function_args)
369 return log(arg.expand(options)).hold();
371 return log(arg).hold();
374 static ex log_conjugate(const ex & x)
376 // conjugate(log(x))==log(conjugate(x)) unless on the branch cut which
377 // runs along the negative real axis.
378 if (x.info(info_flags::positive)) {
381 if (is_exactly_a<numeric>(x) &&
382 !x.imag_part().is_zero()) {
383 return log(x.conjugate());
385 return conjugate_function(log(x)).hold();
388 static bool log_info(const ex & x, unsigned inf)
391 case info_flags::expanded:
393 case info_flags::real:
394 return x.info(info_flags::positive);
400 REGISTER_FUNCTION(log, eval_func(log_eval).
401 evalf_func(log_evalf).
403 expand_func(log_expand).
404 derivative_func(log_deriv).
405 series_func(log_series).
406 real_part_func(log_real_part).
407 imag_part_func(log_imag_part).
408 conjugate_func(log_conjugate).
412 // sine (trigonometric function)
415 static ex sin_evalf(const ex & x)
417 if (is_exactly_a<numeric>(x))
418 return sin(ex_to<numeric>(x));
420 return sin(x).hold();
423 static ex sin_eval(const ex & x)
425 // sin(n/d*Pi) -> { all known non-nested radicals }
426 const ex SixtyExOverPi = _ex60*x/Pi;
428 if (SixtyExOverPi.info(info_flags::integer)) {
429 numeric z = mod(ex_to<numeric>(SixtyExOverPi),*_num120_p);
431 // wrap to interval [0, Pi)
436 // wrap to interval [0, Pi/2)
439 if (z.is_equal(*_num0_p)) // sin(0) -> 0
441 if (z.is_equal(*_num5_p)) // sin(Pi/12) -> sqrt(6)/4*(1-sqrt(3)/3)
442 return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex_1_3*sqrt(_ex3));
443 if (z.is_equal(*_num6_p)) // sin(Pi/10) -> sqrt(5)/4-1/4
444 return sign*(_ex1_4*sqrt(_ex5)+_ex_1_4);
445 if (z.is_equal(*_num10_p)) // sin(Pi/6) -> 1/2
447 if (z.is_equal(*_num15_p)) // sin(Pi/4) -> sqrt(2)/2
448 return sign*_ex1_2*sqrt(_ex2);
449 if (z.is_equal(*_num18_p)) // sin(3/10*Pi) -> sqrt(5)/4+1/4
450 return sign*(_ex1_4*sqrt(_ex5)+_ex1_4);
451 if (z.is_equal(*_num20_p)) // sin(Pi/3) -> sqrt(3)/2
452 return sign*_ex1_2*sqrt(_ex3);
453 if (z.is_equal(*_num25_p)) // sin(5/12*Pi) -> sqrt(6)/4*(1+sqrt(3)/3)
454 return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex1_3*sqrt(_ex3));
455 if (z.is_equal(*_num30_p)) // sin(Pi/2) -> 1
459 if (is_exactly_a<function>(x)) {
460 const ex &t = x.op(0);
463 if (is_ex_the_function(x, asin))
466 // sin(acos(x)) -> sqrt(1-x^2)
467 if (is_ex_the_function(x, acos))
468 return sqrt(_ex1-power(t,_ex2));
470 // sin(atan(x)) -> x/sqrt(1+x^2)
471 if (is_ex_the_function(x, atan))
472 return t*power(_ex1+power(t,_ex2),_ex_1_2);
475 // sin(float) -> float
476 if (x.info(info_flags::numeric) && !x.info(info_flags::crational))
477 return sin(ex_to<numeric>(x));
480 if (x.info(info_flags::negative))
483 return sin(x).hold();
486 static ex sin_deriv(const ex & x, unsigned deriv_param)
488 GINAC_ASSERT(deriv_param==0);
490 // d/dx sin(x) -> cos(x)
494 static ex sin_real_part(const ex & x)
496 return cosh(GiNaC::imag_part(x))*sin(GiNaC::real_part(x));
499 static ex sin_imag_part(const ex & x)
501 return sinh(GiNaC::imag_part(x))*cos(GiNaC::real_part(x));
504 static ex sin_conjugate(const ex & x)
506 // conjugate(sin(x))==sin(conjugate(x))
507 return sin(x.conjugate());
510 static bool trig_info(const ex & x, unsigned inf)
513 case info_flags::expanded:
514 case info_flags::real:
521 REGISTER_FUNCTION(sin, eval_func(sin_eval).
522 evalf_func(sin_evalf).
523 info_func(trig_info).
524 derivative_func(sin_deriv).
525 real_part_func(sin_real_part).
526 imag_part_func(sin_imag_part).
527 conjugate_func(sin_conjugate).
528 latex_name("\\sin"));
531 // cosine (trigonometric function)
534 static ex cos_evalf(const ex & x)
536 if (is_exactly_a<numeric>(x))
537 return cos(ex_to<numeric>(x));
539 return cos(x).hold();
542 static ex cos_eval(const ex & x)
544 // cos(n/d*Pi) -> { all known non-nested radicals }
545 const ex SixtyExOverPi = _ex60*x/Pi;
547 if (SixtyExOverPi.info(info_flags::integer)) {
548 numeric z = mod(ex_to<numeric>(SixtyExOverPi),*_num120_p);
550 // wrap to interval [0, Pi)
554 // wrap to interval [0, Pi/2)
558 if (z.is_equal(*_num0_p)) // cos(0) -> 1
560 if (z.is_equal(*_num5_p)) // cos(Pi/12) -> sqrt(6)/4*(1+sqrt(3)/3)
561 return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex1_3*sqrt(_ex3));
562 if (z.is_equal(*_num10_p)) // cos(Pi/6) -> sqrt(3)/2
563 return sign*_ex1_2*sqrt(_ex3);
564 if (z.is_equal(*_num12_p)) // cos(Pi/5) -> sqrt(5)/4+1/4
565 return sign*(_ex1_4*sqrt(_ex5)+_ex1_4);
566 if (z.is_equal(*_num15_p)) // cos(Pi/4) -> sqrt(2)/2
567 return sign*_ex1_2*sqrt(_ex2);
568 if (z.is_equal(*_num20_p)) // cos(Pi/3) -> 1/2
570 if (z.is_equal(*_num24_p)) // cos(2/5*Pi) -> sqrt(5)/4-1/4x
571 return sign*(_ex1_4*sqrt(_ex5)+_ex_1_4);
572 if (z.is_equal(*_num25_p)) // cos(5/12*Pi) -> sqrt(6)/4*(1-sqrt(3)/3)
573 return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex_1_3*sqrt(_ex3));
574 if (z.is_equal(*_num30_p)) // cos(Pi/2) -> 0
578 if (is_exactly_a<function>(x)) {
579 const ex &t = x.op(0);
582 if (is_ex_the_function(x, acos))
585 // cos(asin(x)) -> sqrt(1-x^2)
586 if (is_ex_the_function(x, asin))
587 return sqrt(_ex1-power(t,_ex2));
589 // cos(atan(x)) -> 1/sqrt(1+x^2)
590 if (is_ex_the_function(x, atan))
591 return power(_ex1+power(t,_ex2),_ex_1_2);
594 // cos(float) -> float
595 if (x.info(info_flags::numeric) && !x.info(info_flags::crational))
596 return cos(ex_to<numeric>(x));
599 if (x.info(info_flags::negative))
602 return cos(x).hold();
605 static ex cos_deriv(const ex & x, unsigned deriv_param)
607 GINAC_ASSERT(deriv_param==0);
609 // d/dx cos(x) -> -sin(x)
613 static ex cos_real_part(const ex & x)
615 return cosh(GiNaC::imag_part(x))*cos(GiNaC::real_part(x));
618 static ex cos_imag_part(const ex & x)
620 return -sinh(GiNaC::imag_part(x))*sin(GiNaC::real_part(x));
623 static ex cos_conjugate(const ex & x)
625 // conjugate(cos(x))==cos(conjugate(x))
626 return cos(x.conjugate());
629 REGISTER_FUNCTION(cos, eval_func(cos_eval).
630 info_func(trig_info).
631 evalf_func(cos_evalf).
632 derivative_func(cos_deriv).
633 real_part_func(cos_real_part).
634 imag_part_func(cos_imag_part).
635 conjugate_func(cos_conjugate).
636 latex_name("\\cos"));
639 // tangent (trigonometric function)
642 static ex tan_evalf(const ex & x)
644 if (is_exactly_a<numeric>(x))
645 return tan(ex_to<numeric>(x));
647 return tan(x).hold();
650 static ex tan_eval(const ex & x)
652 // tan(n/d*Pi) -> { all known non-nested radicals }
653 const ex SixtyExOverPi = _ex60*x/Pi;
655 if (SixtyExOverPi.info(info_flags::integer)) {
656 numeric z = mod(ex_to<numeric>(SixtyExOverPi),*_num60_p);
658 // wrap to interval [0, Pi)
662 // wrap to interval [0, Pi/2)
666 if (z.is_equal(*_num0_p)) // tan(0) -> 0
668 if (z.is_equal(*_num5_p)) // tan(Pi/12) -> 2-sqrt(3)
669 return sign*(_ex2-sqrt(_ex3));
670 if (z.is_equal(*_num10_p)) // tan(Pi/6) -> sqrt(3)/3
671 return sign*_ex1_3*sqrt(_ex3);
672 if (z.is_equal(*_num15_p)) // tan(Pi/4) -> 1
674 if (z.is_equal(*_num20_p)) // tan(Pi/3) -> sqrt(3)
675 return sign*sqrt(_ex3);
676 if (z.is_equal(*_num25_p)) // tan(5/12*Pi) -> 2+sqrt(3)
677 return sign*(sqrt(_ex3)+_ex2);
678 if (z.is_equal(*_num30_p)) // tan(Pi/2) -> infinity
679 throw (pole_error("tan_eval(): simple pole",1));
682 if (is_exactly_a<function>(x)) {
683 const ex &t = x.op(0);
686 if (is_ex_the_function(x, atan))
689 // tan(asin(x)) -> x/sqrt(1+x^2)
690 if (is_ex_the_function(x, asin))
691 return t*power(_ex1-power(t,_ex2),_ex_1_2);
693 // tan(acos(x)) -> sqrt(1-x^2)/x
694 if (is_ex_the_function(x, acos))
695 return power(t,_ex_1)*sqrt(_ex1-power(t,_ex2));
698 // tan(float) -> float
699 if (x.info(info_flags::numeric) && !x.info(info_flags::crational)) {
700 return tan(ex_to<numeric>(x));
704 if (x.info(info_flags::negative))
707 return tan(x).hold();
710 static ex tan_deriv(const ex & x, unsigned deriv_param)
712 GINAC_ASSERT(deriv_param==0);
714 // d/dx tan(x) -> 1+tan(x)^2;
715 return (_ex1+power(tan(x),_ex2));
718 static ex tan_real_part(const ex & x)
720 ex a = GiNaC::real_part(x);
721 ex b = GiNaC::imag_part(x);
722 return tan(a)/(1+power(tan(a),2)*power(tan(b),2));
725 static ex tan_imag_part(const ex & x)
727 ex a = GiNaC::real_part(x);
728 ex b = GiNaC::imag_part(x);
729 return tanh(b)/(1+power(tan(a),2)*power(tan(b),2));
732 static ex tan_series(const ex &x,
733 const relational &rel,
737 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
739 // Taylor series where there is no pole falls back to tan_deriv.
740 // On a pole simply expand sin(x)/cos(x).
741 const ex x_pt = x.subs(rel, subs_options::no_pattern);
742 if (!(2*x_pt/Pi).info(info_flags::odd))
743 throw do_taylor(); // caught by function::series()
744 // if we got here we have to care for a simple pole
745 return (sin(x)/cos(x)).series(rel, order, options);
748 static ex tan_conjugate(const ex & x)
750 // conjugate(tan(x))==tan(conjugate(x))
751 return tan(x.conjugate());
754 REGISTER_FUNCTION(tan, eval_func(tan_eval).
755 evalf_func(tan_evalf).
756 info_func(trig_info).
757 derivative_func(tan_deriv).
758 series_func(tan_series).
759 real_part_func(tan_real_part).
760 imag_part_func(tan_imag_part).
761 conjugate_func(tan_conjugate).
762 latex_name("\\tan"));
765 // inverse sine (arc sine)
768 static ex asin_evalf(const ex & x)
770 if (is_exactly_a<numeric>(x))
771 return asin(ex_to<numeric>(x));
773 return asin(x).hold();
776 static ex asin_eval(const ex & x)
778 if (x.info(info_flags::numeric)) {
785 if (x.is_equal(_ex1_2))
786 return numeric(1,6)*Pi;
789 if (x.is_equal(_ex1))
792 // asin(-1/2) -> -Pi/6
793 if (x.is_equal(_ex_1_2))
794 return numeric(-1,6)*Pi;
797 if (x.is_equal(_ex_1))
800 // asin(float) -> float
801 if (!x.info(info_flags::crational))
802 return asin(ex_to<numeric>(x));
805 if (x.info(info_flags::negative))
809 return asin(x).hold();
812 static ex asin_deriv(const ex & x, unsigned deriv_param)
814 GINAC_ASSERT(deriv_param==0);
816 // d/dx asin(x) -> 1/sqrt(1-x^2)
817 return power(1-power(x,_ex2),_ex_1_2);
820 static ex asin_conjugate(const ex & x)
822 // conjugate(asin(x))==asin(conjugate(x)) unless on the branch cuts which
823 // run along the real axis outside the interval [-1, +1].
824 if (is_exactly_a<numeric>(x) &&
825 (!x.imag_part().is_zero() || (x > *_num_1_p && x < *_num1_p))) {
826 return asin(x.conjugate());
828 return conjugate_function(asin(x)).hold();
831 static bool asin_info(const ex & x, unsigned inf)
834 case info_flags::expanded:
841 REGISTER_FUNCTION(asin, eval_func(asin_eval).
842 evalf_func(asin_evalf).
843 info_func(asin_info).
844 derivative_func(asin_deriv).
845 conjugate_func(asin_conjugate).
846 latex_name("\\arcsin"));
849 // inverse cosine (arc cosine)
852 static ex acos_evalf(const ex & x)
854 if (is_exactly_a<numeric>(x))
855 return acos(ex_to<numeric>(x));
857 return acos(x).hold();
860 static ex acos_eval(const ex & x)
862 if (x.info(info_flags::numeric)) {
865 if (x.is_equal(_ex1))
869 if (x.is_equal(_ex1_2))
876 // acos(-1/2) -> 2/3*Pi
877 if (x.is_equal(_ex_1_2))
878 return numeric(2,3)*Pi;
881 if (x.is_equal(_ex_1))
884 // acos(float) -> float
885 if (!x.info(info_flags::crational))
886 return acos(ex_to<numeric>(x));
888 // acos(-x) -> Pi-acos(x)
889 if (x.info(info_flags::negative))
893 return acos(x).hold();
896 static ex acos_deriv(const ex & x, unsigned deriv_param)
898 GINAC_ASSERT(deriv_param==0);
900 // d/dx acos(x) -> -1/sqrt(1-x^2)
901 return -power(1-power(x,_ex2),_ex_1_2);
904 static ex acos_conjugate(const ex & x)
906 // conjugate(acos(x))==acos(conjugate(x)) unless on the branch cuts which
907 // run along the real axis outside the interval [-1, +1].
908 if (is_exactly_a<numeric>(x) &&
909 (!x.imag_part().is_zero() || (x > *_num_1_p && x < *_num1_p))) {
910 return acos(x.conjugate());
912 return conjugate_function(acos(x)).hold();
915 REGISTER_FUNCTION(acos, eval_func(acos_eval).
916 evalf_func(acos_evalf).
917 info_func(asin_info). // Flags of acos are shared with asin functions
918 derivative_func(acos_deriv).
919 conjugate_func(acos_conjugate).
920 latex_name("\\arccos"));
923 // inverse tangent (arc tangent)
926 static ex atan_evalf(const ex & x)
928 if (is_exactly_a<numeric>(x))
929 return atan(ex_to<numeric>(x));
931 return atan(x).hold();
934 static ex atan_eval(const ex & x)
936 if (x.info(info_flags::numeric)) {
943 if (x.is_equal(_ex1))
947 if (x.is_equal(_ex_1))
950 if (x.is_equal(I) || x.is_equal(-I))
951 throw (pole_error("atan_eval(): logarithmic pole",0));
953 // atan(float) -> float
954 if (!x.info(info_flags::crational))
955 return atan(ex_to<numeric>(x));
958 if (x.info(info_flags::negative))
962 return atan(x).hold();
965 static ex atan_deriv(const ex & x, unsigned deriv_param)
967 GINAC_ASSERT(deriv_param==0);
969 // d/dx atan(x) -> 1/(1+x^2)
970 return power(_ex1+power(x,_ex2), _ex_1);
973 static ex atan_series(const ex &arg,
974 const relational &rel,
978 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
980 // Taylor series where there is no pole or cut falls back to atan_deriv.
981 // There are two branch cuts, one runnig from I up the imaginary axis and
982 // one running from -I down the imaginary axis. The points I and -I are
984 // On the branch cuts and the poles series expand
985 // (log(1+I*x)-log(1-I*x))/(2*I)
987 const ex arg_pt = arg.subs(rel, subs_options::no_pattern);
988 if (!(I*arg_pt).info(info_flags::real))
989 throw do_taylor(); // Re(x) != 0
990 if ((I*arg_pt).info(info_flags::real) && abs(I*arg_pt)<_ex1)
991 throw do_taylor(); // Re(x) == 0, but abs(x)<1
992 // care for the poles, using the defining formula for atan()...
993 if (arg_pt.is_equal(I) || arg_pt.is_equal(-I))
994 return ((log(1+I*arg)-log(1-I*arg))/(2*I)).series(rel, order, options);
995 if (!(options & series_options::suppress_branchcut)) {
997 // This is the branch cut: assemble the primitive series manually and
998 // then add the corresponding complex step function.
999 const symbol &s = ex_to<symbol>(rel.lhs());
1000 const ex &point = rel.rhs();
1002 const ex replarg = series(atan(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
1003 ex Order0correction = replarg.op(0)+csgn(arg)*Pi*_ex_1_2;
1004 if ((I*arg_pt)<_ex0)
1005 Order0correction += log((I*arg_pt+_ex_1)/(I*arg_pt+_ex1))*I*_ex_1_2;
1007 Order0correction += log((I*arg_pt+_ex1)/(I*arg_pt+_ex_1))*I*_ex1_2;
1011 seq.push_back(expair(Order0correction, _ex0));
1013 seq.push_back(expair(Order(_ex1), order));
1014 return series(replarg - pseries(rel, std::move(seq)), rel, order);
1019 static ex atan_conjugate(const ex & x)
1021 // conjugate(atan(x))==atan(conjugate(x)) unless on the branch cuts which
1022 // run along the imaginary axis outside the interval [-I, +I].
1023 if (x.info(info_flags::real))
1025 if (is_exactly_a<numeric>(x)) {
1026 const numeric x_re = ex_to<numeric>(x.real_part());
1027 const numeric x_im = ex_to<numeric>(x.imag_part());
1028 if (!x_re.is_zero() ||
1029 (x_im > *_num_1_p && x_im < *_num1_p))
1030 return atan(x.conjugate());
1032 return conjugate_function(atan(x)).hold();
1035 static bool atan_info(const ex & x, unsigned inf)
1038 case info_flags::expanded:
1039 case info_flags::real:
1041 case info_flags::positive:
1042 case info_flags::negative:
1043 case info_flags::nonnegative:
1044 return x.info(info_flags::real) && x.info(inf);
1050 REGISTER_FUNCTION(atan, eval_func(atan_eval).
1051 evalf_func(atan_evalf).
1052 info_func(atan_info).
1053 derivative_func(atan_deriv).
1054 series_func(atan_series).
1055 conjugate_func(atan_conjugate).
1056 latex_name("\\arctan"));
1059 // inverse tangent (atan2(y,x))
1062 static ex atan2_evalf(const ex &y, const ex &x)
1064 if (is_exactly_a<numeric>(y) && is_exactly_a<numeric>(x))
1065 return atan(ex_to<numeric>(y), ex_to<numeric>(x));
1067 return atan2(y, x).hold();
1070 static ex atan2_eval(const ex & y, const ex & x)
1078 // atan2(0, x), x real and positive -> 0
1079 if (x.info(info_flags::positive))
1082 // atan2(0, x), x real and negative -> Pi
1083 if (x.info(info_flags::negative))
1089 // atan2(y, 0), y real and positive -> Pi/2
1090 if (y.info(info_flags::positive))
1093 // atan2(y, 0), y real and negative -> -Pi/2
1094 if (y.info(info_flags::negative))
1098 if (y.is_equal(x)) {
1100 // atan2(y, y), y real and positive -> Pi/4
1101 if (y.info(info_flags::positive))
1104 // atan2(y, y), y real and negative -> -3/4*Pi
1105 if (y.info(info_flags::negative))
1106 return numeric(-3, 4)*Pi;
1109 if (y.is_equal(-x)) {
1111 // atan2(y, -y), y real and positive -> 3*Pi/4
1112 if (y.info(info_flags::positive))
1113 return numeric(3, 4)*Pi;
1115 // atan2(y, -y), y real and negative -> -Pi/4
1116 if (y.info(info_flags::negative))
1120 // atan2(float, float) -> float
1121 if (is_a<numeric>(y) && !y.info(info_flags::crational) &&
1122 is_a<numeric>(x) && !x.info(info_flags::crational))
1123 return atan(ex_to<numeric>(y), ex_to<numeric>(x));
1125 // atan2(real, real) -> atan(y/x) +/- Pi
1126 if (y.info(info_flags::real) && x.info(info_flags::real)) {
1127 if (x.info(info_flags::positive))
1130 if (x.info(info_flags::negative)) {
1131 if (y.info(info_flags::positive))
1132 return atan(y/x)+Pi;
1133 if (y.info(info_flags::negative))
1134 return atan(y/x)-Pi;
1138 return atan2(y, x).hold();
1141 static ex atan2_deriv(const ex & y, const ex & x, unsigned deriv_param)
1143 GINAC_ASSERT(deriv_param<2);
1145 if (deriv_param==0) {
1147 return x*power(power(x,_ex2)+power(y,_ex2),_ex_1);
1150 return -y*power(power(x,_ex2)+power(y,_ex2),_ex_1);
1153 static bool atan2_info(const ex & y, const ex & x, unsigned inf)
1156 case info_flags::expanded:
1157 case info_flags::real:
1158 return y.info(inf) && x.info(inf);
1159 case info_flags::positive:
1160 case info_flags::negative:
1161 case info_flags::nonnegative:
1162 return y.info(info_flags::real) && x.info(info_flags::real)
1169 REGISTER_FUNCTION(atan2, eval_func(atan2_eval).
1170 evalf_func(atan2_evalf).
1171 info_func(atan2_info).
1172 evalf_func(atan2_evalf).
1173 derivative_func(atan2_deriv));
1176 // hyperbolic sine (trigonometric function)
1179 static ex sinh_evalf(const ex & x)
1181 if (is_exactly_a<numeric>(x))
1182 return sinh(ex_to<numeric>(x));
1184 return sinh(x).hold();
1187 static ex sinh_eval(const ex & x)
1189 if (x.info(info_flags::numeric)) {
1195 // sinh(float) -> float
1196 if (!x.info(info_flags::crational))
1197 return sinh(ex_to<numeric>(x));
1200 if (x.info(info_flags::negative))
1204 if ((x/Pi).info(info_flags::numeric) &&
1205 ex_to<numeric>(x/Pi).real().is_zero()) // sinh(I*x) -> I*sin(x)
1208 if (is_exactly_a<function>(x)) {
1209 const ex &t = x.op(0);
1211 // sinh(asinh(x)) -> x
1212 if (is_ex_the_function(x, asinh))
1215 // sinh(acosh(x)) -> sqrt(x-1) * sqrt(x+1)
1216 if (is_ex_the_function(x, acosh))
1217 return sqrt(t-_ex1)*sqrt(t+_ex1);
1219 // sinh(atanh(x)) -> x/sqrt(1-x^2)
1220 if (is_ex_the_function(x, atanh))
1221 return t*power(_ex1-power(t,_ex2),_ex_1_2);
1224 return sinh(x).hold();
1227 static ex sinh_deriv(const ex & x, unsigned deriv_param)
1229 GINAC_ASSERT(deriv_param==0);
1231 // d/dx sinh(x) -> cosh(x)
1235 static ex sinh_real_part(const ex & x)
1237 return sinh(GiNaC::real_part(x))*cos(GiNaC::imag_part(x));
1240 static ex sinh_imag_part(const ex & x)
1242 return cosh(GiNaC::real_part(x))*sin(GiNaC::imag_part(x));
1245 static ex sinh_conjugate(const ex & x)
1247 // conjugate(sinh(x))==sinh(conjugate(x))
1248 return sinh(x.conjugate());
1251 REGISTER_FUNCTION(sinh, eval_func(sinh_eval).
1252 evalf_func(sinh_evalf).
1253 info_func(atan_info). // Flags of sinh are shared with atan functions
1254 derivative_func(sinh_deriv).
1255 real_part_func(sinh_real_part).
1256 imag_part_func(sinh_imag_part).
1257 conjugate_func(sinh_conjugate).
1258 latex_name("\\sinh"));
1261 // hyperbolic cosine (trigonometric function)
1264 static ex cosh_evalf(const ex & x)
1266 if (is_exactly_a<numeric>(x))
1267 return cosh(ex_to<numeric>(x));
1269 return cosh(x).hold();
1272 static ex cosh_eval(const ex & x)
1274 if (x.info(info_flags::numeric)) {
1280 // cosh(float) -> float
1281 if (!x.info(info_flags::crational))
1282 return cosh(ex_to<numeric>(x));
1285 if (x.info(info_flags::negative))
1289 if ((x/Pi).info(info_flags::numeric) &&
1290 ex_to<numeric>(x/Pi).real().is_zero()) // cosh(I*x) -> cos(x)
1293 if (is_exactly_a<function>(x)) {
1294 const ex &t = x.op(0);
1296 // cosh(acosh(x)) -> x
1297 if (is_ex_the_function(x, acosh))
1300 // cosh(asinh(x)) -> sqrt(1+x^2)
1301 if (is_ex_the_function(x, asinh))
1302 return sqrt(_ex1+power(t,_ex2));
1304 // cosh(atanh(x)) -> 1/sqrt(1-x^2)
1305 if (is_ex_the_function(x, atanh))
1306 return power(_ex1-power(t,_ex2),_ex_1_2);
1309 return cosh(x).hold();
1312 static ex cosh_deriv(const ex & x, unsigned deriv_param)
1314 GINAC_ASSERT(deriv_param==0);
1316 // d/dx cosh(x) -> sinh(x)
1320 static ex cosh_real_part(const ex & x)
1322 return cosh(GiNaC::real_part(x))*cos(GiNaC::imag_part(x));
1325 static ex cosh_imag_part(const ex & x)
1327 return sinh(GiNaC::real_part(x))*sin(GiNaC::imag_part(x));
1330 static ex cosh_conjugate(const ex & x)
1332 // conjugate(cosh(x))==cosh(conjugate(x))
1333 return cosh(x.conjugate());
1336 REGISTER_FUNCTION(cosh, eval_func(cosh_eval).
1337 evalf_func(cosh_evalf).
1338 info_func(exp_info). // Flags of cosh are shared with exp functions
1339 derivative_func(cosh_deriv).
1340 real_part_func(cosh_real_part).
1341 imag_part_func(cosh_imag_part).
1342 conjugate_func(cosh_conjugate).
1343 latex_name("\\cosh"));
1346 // hyperbolic tangent (trigonometric function)
1349 static ex tanh_evalf(const ex & x)
1351 if (is_exactly_a<numeric>(x))
1352 return tanh(ex_to<numeric>(x));
1354 return tanh(x).hold();
1357 static ex tanh_eval(const ex & x)
1359 if (x.info(info_flags::numeric)) {
1365 // tanh(float) -> float
1366 if (!x.info(info_flags::crational))
1367 return tanh(ex_to<numeric>(x));
1370 if (x.info(info_flags::negative))
1374 if ((x/Pi).info(info_flags::numeric) &&
1375 ex_to<numeric>(x/Pi).real().is_zero()) // tanh(I*x) -> I*tan(x);
1378 if (is_exactly_a<function>(x)) {
1379 const ex &t = x.op(0);
1381 // tanh(atanh(x)) -> x
1382 if (is_ex_the_function(x, atanh))
1385 // tanh(asinh(x)) -> x/sqrt(1+x^2)
1386 if (is_ex_the_function(x, asinh))
1387 return t*power(_ex1+power(t,_ex2),_ex_1_2);
1389 // tanh(acosh(x)) -> sqrt(x-1)*sqrt(x+1)/x
1390 if (is_ex_the_function(x, acosh))
1391 return sqrt(t-_ex1)*sqrt(t+_ex1)*power(t,_ex_1);
1394 return tanh(x).hold();
1397 static ex tanh_deriv(const ex & x, unsigned deriv_param)
1399 GINAC_ASSERT(deriv_param==0);
1401 // d/dx tanh(x) -> 1-tanh(x)^2
1402 return _ex1-power(tanh(x),_ex2);
1405 static ex tanh_series(const ex &x,
1406 const relational &rel,
1410 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
1412 // Taylor series where there is no pole falls back to tanh_deriv.
1413 // On a pole simply expand sinh(x)/cosh(x).
1414 const ex x_pt = x.subs(rel, subs_options::no_pattern);
1415 if (!(2*I*x_pt/Pi).info(info_flags::odd))
1416 throw do_taylor(); // caught by function::series()
1417 // if we got here we have to care for a simple pole
1418 return (sinh(x)/cosh(x)).series(rel, order, options);
1421 static ex tanh_real_part(const ex & x)
1423 ex a = GiNaC::real_part(x);
1424 ex b = GiNaC::imag_part(x);
1425 return tanh(a)/(1+power(tanh(a),2)*power(tan(b),2));
1428 static ex tanh_imag_part(const ex & x)
1430 ex a = GiNaC::real_part(x);
1431 ex b = GiNaC::imag_part(x);
1432 return tan(b)/(1+power(tanh(a),2)*power(tan(b),2));
1435 static ex tanh_conjugate(const ex & x)
1437 // conjugate(tanh(x))==tanh(conjugate(x))
1438 return tanh(x.conjugate());
1441 REGISTER_FUNCTION(tanh, eval_func(tanh_eval).
1442 evalf_func(tanh_evalf).
1443 info_func(atan_info). // Flags of tanh are shared with atan functions
1444 derivative_func(tanh_deriv).
1445 series_func(tanh_series).
1446 real_part_func(tanh_real_part).
1447 imag_part_func(tanh_imag_part).
1448 conjugate_func(tanh_conjugate).
1449 latex_name("\\tanh"));
1452 // inverse hyperbolic sine (trigonometric function)
1455 static ex asinh_evalf(const ex & x)
1457 if (is_exactly_a<numeric>(x))
1458 return asinh(ex_to<numeric>(x));
1460 return asinh(x).hold();
1463 static ex asinh_eval(const ex & x)
1465 if (x.info(info_flags::numeric)) {
1471 // asinh(float) -> float
1472 if (!x.info(info_flags::crational))
1473 return asinh(ex_to<numeric>(x));
1476 if (x.info(info_flags::negative))
1480 return asinh(x).hold();
1483 static ex asinh_deriv(const ex & x, unsigned deriv_param)
1485 GINAC_ASSERT(deriv_param==0);
1487 // d/dx asinh(x) -> 1/sqrt(1+x^2)
1488 return power(_ex1+power(x,_ex2),_ex_1_2);
1491 static ex asinh_conjugate(const ex & x)
1493 // conjugate(asinh(x))==asinh(conjugate(x)) unless on the branch cuts which
1494 // run along the imaginary axis outside the interval [-I, +I].
1495 if (x.info(info_flags::real))
1497 if (is_exactly_a<numeric>(x)) {
1498 const numeric x_re = ex_to<numeric>(x.real_part());
1499 const numeric x_im = ex_to<numeric>(x.imag_part());
1500 if (!x_re.is_zero() ||
1501 (x_im > *_num_1_p && x_im < *_num1_p))
1502 return asinh(x.conjugate());
1504 return conjugate_function(asinh(x)).hold();
1507 REGISTER_FUNCTION(asinh, eval_func(asinh_eval).
1508 evalf_func(asinh_evalf).
1509 info_func(atan_info). // Flags of asinh are shared with atan functions
1510 derivative_func(asinh_deriv).
1511 conjugate_func(asinh_conjugate));
1514 // inverse hyperbolic cosine (trigonometric function)
1517 static ex acosh_evalf(const ex & x)
1519 if (is_exactly_a<numeric>(x))
1520 return acosh(ex_to<numeric>(x));
1522 return acosh(x).hold();
1525 static ex acosh_eval(const ex & x)
1527 if (x.info(info_flags::numeric)) {
1529 // acosh(0) -> Pi*I/2
1531 return Pi*I*numeric(1,2);
1534 if (x.is_equal(_ex1))
1537 // acosh(-1) -> Pi*I
1538 if (x.is_equal(_ex_1))
1541 // acosh(float) -> float
1542 if (!x.info(info_flags::crational))
1543 return acosh(ex_to<numeric>(x));
1545 // acosh(-x) -> Pi*I-acosh(x)
1546 if (x.info(info_flags::negative))
1547 return Pi*I-acosh(-x);
1550 return acosh(x).hold();
1553 static ex acosh_deriv(const ex & x, unsigned deriv_param)
1555 GINAC_ASSERT(deriv_param==0);
1557 // d/dx acosh(x) -> 1/(sqrt(x-1)*sqrt(x+1))
1558 return power(x+_ex_1,_ex_1_2)*power(x+_ex1,_ex_1_2);
1561 static ex acosh_conjugate(const ex & x)
1563 // conjugate(acosh(x))==acosh(conjugate(x)) unless on the branch cut
1564 // which runs along the real axis from +1 to -inf.
1565 if (is_exactly_a<numeric>(x) &&
1566 (!x.imag_part().is_zero() || x > *_num1_p)) {
1567 return acosh(x.conjugate());
1569 return conjugate_function(acosh(x)).hold();
1572 REGISTER_FUNCTION(acosh, eval_func(acosh_eval).
1573 evalf_func(acosh_evalf).
1574 info_func(asin_info). // Flags of acosh are shared with asin functions
1575 derivative_func(acosh_deriv).
1576 conjugate_func(acosh_conjugate));
1579 // inverse hyperbolic tangent (trigonometric function)
1582 static ex atanh_evalf(const ex & x)
1584 if (is_exactly_a<numeric>(x))
1585 return atanh(ex_to<numeric>(x));
1587 return atanh(x).hold();
1590 static ex atanh_eval(const ex & x)
1592 if (x.info(info_flags::numeric)) {
1598 // atanh({+|-}1) -> throw
1599 if (x.is_equal(_ex1) || x.is_equal(_ex_1))
1600 throw (pole_error("atanh_eval(): logarithmic pole",0));
1602 // atanh(float) -> float
1603 if (!x.info(info_flags::crational))
1604 return atanh(ex_to<numeric>(x));
1607 if (x.info(info_flags::negative))
1611 return atanh(x).hold();
1614 static ex atanh_deriv(const ex & x, unsigned deriv_param)
1616 GINAC_ASSERT(deriv_param==0);
1618 // d/dx atanh(x) -> 1/(1-x^2)
1619 return power(_ex1-power(x,_ex2),_ex_1);
1622 static ex atanh_series(const ex &arg,
1623 const relational &rel,
1627 GINAC_ASSERT(is_a<symbol>(rel.lhs()));
1629 // Taylor series where there is no pole or cut falls back to atanh_deriv.
1630 // There are two branch cuts, one runnig from 1 up the real axis and one
1631 // one running from -1 down the real axis. The points 1 and -1 are poles
1632 // On the branch cuts and the poles series expand
1633 // (log(1+x)-log(1-x))/2
1635 const ex arg_pt = arg.subs(rel, subs_options::no_pattern);
1636 if (!(arg_pt).info(info_flags::real))
1637 throw do_taylor(); // Im(x) != 0
1638 if ((arg_pt).info(info_flags::real) && abs(arg_pt)<_ex1)
1639 throw do_taylor(); // Im(x) == 0, but abs(x)<1
1640 // care for the poles, using the defining formula for atanh()...
1641 if (arg_pt.is_equal(_ex1) || arg_pt.is_equal(_ex_1))
1642 return ((log(_ex1+arg)-log(_ex1-arg))*_ex1_2).series(rel, order, options);
1643 // ...and the branch cuts (the discontinuity at the cut being just I*Pi)
1644 if (!(options & series_options::suppress_branchcut)) {
1646 // This is the branch cut: assemble the primitive series manually and
1647 // then add the corresponding complex step function.
1648 const symbol &s = ex_to<symbol>(rel.lhs());
1649 const ex &point = rel.rhs();
1651 const ex replarg = series(atanh(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
1652 ex Order0correction = replarg.op(0)+csgn(I*arg)*Pi*I*_ex1_2;
1654 Order0correction += log((arg_pt+_ex_1)/(arg_pt+_ex1))*_ex1_2;
1656 Order0correction += log((arg_pt+_ex1)/(arg_pt+_ex_1))*_ex_1_2;
1660 seq.push_back(expair(Order0correction, _ex0));
1662 seq.push_back(expair(Order(_ex1), order));
1663 return series(replarg - pseries(rel, std::move(seq)), rel, order);
1668 static ex atanh_conjugate(const ex & x)
1670 // conjugate(atanh(x))==atanh(conjugate(x)) unless on the branch cuts which
1671 // run along the real axis outside the interval [-1, +1].
1672 if (is_exactly_a<numeric>(x) &&
1673 (!x.imag_part().is_zero() || (x > *_num_1_p && x < *_num1_p))) {
1674 return atanh(x.conjugate());
1676 return conjugate_function(atanh(x)).hold();
1679 REGISTER_FUNCTION(atanh, eval_func(atanh_eval).
1680 evalf_func(atanh_evalf).
1681 info_func(asin_info). // Flags of atanh are shared with asin functions
1682 derivative_func(atanh_deriv).
1683 series_func(atanh_series).
1684 conjugate_func(atanh_conjugate));
1687 } // namespace GiNaC