Maybe something like atoms():
http://docs.sympy.org/dev/modules/core.html#sympy.core.basic.Basic.atoms
is going to help

On Apr 2, 8:47 pm, Manoj babu <[email protected]> wrote:
> Hi
>         This is Manoj doing my Btech 3rd year at IIT Kharagpur.I am
> working on trigonometric simplication by fu..http://rfdz.ph-noe.ac.at/
> fileadmin/Mathematik_Uploads/ACDCA/DESTIME2006/DES_contribs/Fu/
> simplification.pdf
> i have samll query
> this is the code i have written
>
> matchers = (
>         (a*sin(b+c)**d, (a*sin(b)*cos(c) + a* sin(c)*cos(b))**d, 4),
>         (a*cos(b+c)**d, (a*cos(b)*cos(c) - a* sin(c)*sin(b))**d, 4),
>         #(a*tan(b + c)**d, (a*(tan(b) + tan(c))/(1 -
> tan(c)*tan(b)))**d),
>
>         (a*cos(2*b)**c, (1 - 2*a*sin(b)**2)**c, 3),
>         (a*sin(2*b)**c, (2*a*sin(b)*cos(b))**c, 3)
>         )
>
> elif expr.is_Add:
>         expr = expr.n()
>         if expr.has(sin,cos) and not expr.has(tan):
>             for pattern,result,n in matchers:
>                 ret = S.Zero
>                 res = None
>                 if expr.is_Add:
>                     for term in expr.args:
>                         res = term.match(pattern)
>                         if res is not None:
>                             if len(res) == n and (0 not in
> res.values()):
>                             <b>   # if pattern == (matchers[2][0] or
> matchers[3,0]) and res[b].is_Mul:
>                                  #   ret += term </b>
>                                 ret += result.subs(res).expand()
>                             else:
>                                 ret += term
>                         if res is None:
>                             ret += term
>                     expr = ret.n()
>                 else:
>                     break
>     return expr
>
> in trigsimp_recursive simplify.py
>
> The code is not yet completed...i am presetly working on Rule list 2
> TR 10-TR 4-TR3 -''TR 11''-TR5.
> The problem is (bolded in the code) if the expr contains sin(x).cos(x)
> etc which were expanded in TR10 ... now using the TR 11 for expr.args
> its converting sin(x),cos(x) into half angle arguements which is not
> required and aslo converting cos(2x) in terms of x which is
> required.What can a solution so that it understands that there is a
> double angle and converts only that.
> Is there any sympy function that analyses the arg..ie if there is an
> expression sin(x) + sin(y) + sin(x/2) then it should return all the
> symbols in the expr as a tuple (x,y,x/2)..so that it can understand
> there is a double angle and it can covert only that.
> or please suggest me some other matcher which evaluates the expansion
> of only double angle..

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to