From 4a05a42695e4974078a0b3734e9224c246739715 Mon Sep 17 00:00:00 2001 From: oldk1331 Date: Wed, 12 Apr 2017 14:48:49 +0800 Subject: [PATCH] improve tantrick --- src/algebra/irexpand.spad | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/algebra/irexpand.spad b/src/algebra/irexpand.spad index 68984ef8d..fa77a8500 100644 --- a/src/algebra/irexpand.spad +++ b/src/algebra/irexpand.spad @@ -102,13 +102,17 @@ IntegrationResultToFunction(R, F) : Exports == Implementation where -- returns 2 atan(a/b) or 2 atan(-b/a) whichever looks better -- they differ by a constant so it's ok to do it from an IR tantrick(a, b) == - retractIfCan(a)@Union(Q, "failed") case Q => 2 * atan(-b/a) - sb := sign b - if sb case Z then return 2 * atan(a/b) - sa := sign a - if sa case Z then return 2 * atan(-b/a) - -- print("potentially noncontinuous"::OutputForm) - 2 * atan(a/b) + f := a/b + a := numerator(f) + b := denominator(f) + AN ==> AlgebraicNumber + TryRetract x ==> retractIfCan(x)@Union(Q, "failed") case Q or + retractIfCan(x)@Union(AN, "failed") case AN + TryRetract(b) => 2 * atan(f) + TryRetract(a) => 2 * atan(-b/a) + sign(a) case Z => 2 * atan(-b/a) + -- print("potentially noncontinuous"::OutputForm) + 2 * atan(f) var_kers(p : P, x : Symbol) : List(K) == [k for k in variables(p) | D(k::F, x) ~= 0]