y:x^2-4;

x:5;

trigrat(y);

Calculate

? trigrat;

Calculate

? trigrat;

Calculate

y:x^2-4;

x:5;

trigrat(y);

Calculate

? trigrat;

Calculate

? trigrat;

Calculate

### trigrat

Run Example
```(%i1)f:1/(1+sin(x))+1/(1-sin(x));
1            1
(%o1)                       ---------- + ----------
sin(x) + 1   1 - sin(x)
(%i2) g:2*(1+tan(x)^2);
2
(%o2)                           2 (tan (x) + 1)
(%i3) f1:trigrat(f);
4
(%o3)                            ------------
cos(2 x) + 1
(%i4) g1:trigrat(g);
4
(%o4)                            ------------
cos(2 x) + 1
(%i5) trigrat(f-g);
(%o5)                                  0
(%i6) ```
Run Example
```declare(z, [scalar, real]);
(%o1)                                done
(%i2) declare(q, [scalar, real]);
(%o2)                                done
(%i3) declare(a, [scalar, real]);
(%o3)                                done
(%i4) declare(b, [scalar, real]);
(%o4)                                done
(%i5) declare(c, [scalar, real]);
(%o5)                                done
(%i6) declare(d, [scalar, real]);
(%o6)                                done
(%i7) halfangles:true;
(%o7)                                true
(%i8) trigexpand:true;
(%o8)                                true
(%i9) z : 0.5 * q * %pi;
(%o9)                              0.5 %pi q
(%i10) basesin(q) := sin(''z);
(%o10)                   basesin(q) := sin(0.5 %pi q)
(%i11) deltasin(q) := 0.5 * %pi * cos(''z);
(%o11)               deltasin(q) := 0.5 %pi cos(0.5 %pi q)
(%i12) S7(q) := a*q + b*q^3 + c*q^5 + d*q^7;
3      5      7
(%o12)                 S7(q) := a q + b q  + c q  + d q
(%i13) s7diff: derivative(S7(q),q);
6        4        2
(%o13)                   7 d q  + 5 c q  + 3 b q  + a
(%i14) S7p(q) := ''s7diff;
6        4        2
(%o14)              S7p(q) := 7 d q  + 5 c q  + 3 b q  + a
(%i15) trigsimp(trigrat(solve([S7(1)=basesin(1), S7p(0)=deltasin(0), S7p(1)=deltasin(1), S7p(.5)=deltasin(0.5)], [a,b,c,d])));

rat: replaced -0.5 by -1/2 = -0.5

rat: replaced -0.5 by -1/2 = -0.5

rat: replaced -0.5 by -1/2 = -0.5

rat: replaced 0.75 by 3/4 = 0.75

rat: replaced 0.3125 by 5/16 = 0.3125

rat: replaced 0.109375 by 7/64 = 0.109375

rat: replaced 0.25 by 1/4 = 0.25

rat: replaced -0.25 by -1/4 = -0.25

rat: replaced 210.0 by 210/1 = 210.0

rat: replaced 36.0 by 36/1 = 36.0

rat: replaced 0.25 by 1/4 = 0.25

rat: replaced -0.25 by -1/4 = -0.25

rat: replaced 630.0 by 630/1 = 630.0

rat: replaced -18.0 by -18/1 = -18.0

rat: replaced 0.25 by 1/4 = 0.25

rat: replaced -0.25 by -1/4 = -0.25

rat: replaced 90.0 by 90/1 = 90.0

rat: replaced -6.0 by -6/1 = -6.0
11/2                          13/2
%pi      (2     - 18) %pi - 105        (2     + 9) %pi - 315
(%o15) [[a = ---, b = ----------------------, c = - ---------------------,
2                 30                           30
9/2
(2    + 6) %pi - 90
d = -------------------]]
15
(%i16) ```
Run Example
```display2d:false;

(%o1) false
(%i2)
px(t):= 2*cos(t) + (1 - 2*sin(t)^2);

(%o2) px(t):=2*cos(t)+(1-2*sin(t)^2)
(%i3)
py(t):= 2*sin(t) - (2*cos(t)*sin(t));

(%o3) py(t):=2*sin(t)-2*cos(t)*sin(t)
(%i4)
m(t) := (cos(t) - 1)/sin(t);

(%o4) m(t):=(cos(t)-1)/sin(t)
(%i5)
sols: solve([(oy - py(t1)) = (ox - px(t1)) * m(t1), (oy - py(t2)) = (ox - px(t2)) * m(t2)], [ox,oy]);

(%o5) [[ox = (-2*cos(t1)^2*sin(t2)+cos(t1)*sin(t2)+sin(t2)
+sin(t1)*(2*cos(t2)^2-cos(t2)-1))
/(-cos(t1)*sin(t2)+sin(t2)+sin(t1)*(cos(t2)-1)),
oy = -(2*cos(t2)^2+cos(t1)*(2-2*cos(t2)^2)+cos(t1)^2*(2*cos(t2)-2)
-2*cos(t2))
/(-cos(t1)*sin(t2)+sin(t2)+sin(t1)*(cos(t2)-1))]]
(%i6)
ox12: ox, sols[1];

(%o6) (-2*cos(t1)^2*sin(t2)+cos(t1)*sin(t2)+sin(t2)
+sin(t1)*(2*cos(t2)^2-cos(t2)-1))
/(-cos(t1)*sin(t2)+sin(t2)+sin(t1)*(cos(t2)-1))
(%i7)
ox23: ox12, t2=t3, t1=t2;

(%o7) (-2*cos(t2)^2*sin(t3)+cos(t2)*sin(t3)+sin(t3)
+sin(t2)*(2*cos(t3)^2-cos(t3)-1))
/(-cos(t2)*sin(t3)+sin(t3)+sin(t2)*(cos(t3)-1))
(%i8)
zz:trigreduce(ox23-ox12);

(%o8) -sin(2*t3+t2)/(2*sin(t3-t2)-2*sin(t3)+2*sin(t2))
+sin(2*t3-t2)/(2*sin(t3-t2)-2*sin(t3)+2*sin(t2))
+sin(t3+2*t2)/(2*sin(t3-t2)-2*sin(t3)+2*sin(t2))
+sin(t3-2*t2)/(2*sin(t3-t2)-2*sin(t3)+2*sin(t2))
-sin(t3-t2)/(sin(t3-t2)-sin(t3)+sin(t2))
+sin(2*t2+t1)/(2*sin(t2-t1)-2*sin(t2)+2*sin(t1))
-sin(2*t2-t1)/(2*sin(t2-t1)-2*sin(t2)+2*sin(t1))
-sin(t2+2*t1)/(2*sin(t2-t1)-2*sin(t2)+2*sin(t1))
-sin(t2-2*t1)/(2*sin(t2-t1)-2*sin(t2)+2*sin(t1))
+sin(t2-t1)/(sin(t2-t1)-sin(t2)+sin(t1))
(%i9)
trigrat(zz);

(%o9) cos(t3+t2)+cos(t3)-cos(t2+t1)-cos(t1)
(%i10)
trigrat(ox12);

(%o10) cos(t2+t1)+cos(t2)+cos(t1)
(%i11)
trigrat(sin(x)/cos(x));

(%o11) sin(x)/cos(x)
(%i12)
```

Help for Trigrat