# Question:applyrule and half-angle relations

## Question:applyrule and half-angle relations

Maple

Following an earlier thread (Collect-And-Sqrt) where a solution using applyrule was proposed (and that solution works), I tried to use applyrule to implement some of the trig half-angle relationships. Immediately I ran into trouble:

Say I want to use the rule

r:=cos(th::algebraic)=2*cos(th/2)^2-1;

so I say

applyrule(r,cos(alpha));

and Maple promptly goes into an infinite loop somewhere. It works if I use an intermediate name different from cos (in this example):

r:=cos(th::algebraic)=2*Cos(th/2)^2-1;

and then in a 2nd step replace Cos with cos using another applyrule. E.g.:

applyrule(Cos(b::algebraic)=cos(b),applyrule(r,cos(alpha)));

I concluded that applyrule must work in a looping (or maybe recursive) fashion replacing terms until it can do no more. The docs hint at that. The double-application of the rule seems inefficient and clumsy.

I know I can use simplify with side relations to get a similar effect but sometimes that isn't what one wants. Neither subs nor algsubs work for arbitrary arguments like applyrule so they cannot substitute for applyrule.

Is there any known way to prevent applyrule from looping?

M. D.

﻿