Loïc Grenié on Sun, 15 Sep 2024 10:22:44 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: trying to find 1/2 angle tangent formuli for rationals




Le dim. 15 sept. 2024 à 00:40, American Citizen <website.reader3@gmail.com> a écrit :

Loïc

Your derivation matches mine, after working this afternoon with both GP-Pari and Maxima, to simplify the denominators. In my program I check for pure algebraic content versus some rational or integer values for a,b and then use the lcm of the denominator and then gcd of the numerators to simplify to lowest integer _expression_.


      You can simplify the if() to return([R,S,T]/content([R,S,T]));
 

{tsides_from_halftans(a,b)=
my(r,s,t,R,S,T,u,v);
r=2*a/(a^2+1);
R=2*a*(b^2+1);
s=2*b/(b^2+1);
S=2*b*(a^2+1);
t=2*(a+b)*(1-a*b)/((a^2+1)*(b^2+1));
T=2*(a+b)*(1-a*b);
if(type(T)=="t_FRAC",
  u=lcm(denominator(R),lcm(denominator(S),denominator(T)));
  R=R/u; S=S/u; T=T/u;
  v=gcd(R,gcd(S,T));
  R=R/v; S=S/v; T=T/v;
  u=1;
,
  u=1;
);
return(u*[R,S,T]);
}

     Hope this helps,

           Loïc