Skip to content

Applying sin(-x)=-sin(x) with SymbolicUtils #683

@valtersomlai

Description

@valtersomlai

Hi, I am trying to simplify some trigonometric expressions using SymbolicUtils. After applying the product rules for sine and cosine terms, you can end up with negative arguments and I would like to implement the following rules for these:

sin(-x) = -sin(x) & cos(-x) = cos(x)

However, this works only in some cases because my trigonometric expressions have arguments of the type nwt where n can be any integer, together with a negative sign. Using the following code:

r8 = @acrule sin(~x)cos(~y) => 0.5(sin(~x + ~y) + sin(~x - ~y))
r12 = @rule sin(-1(~x)) => -1 * sin((~x))

expr20 = simplify(expand(Asin(2wt)cos(13wt)), RuleSet([r8, r12]))
println(expr20)
expr21 = simplify(expand(expr20), RuleSet([r12]))
println(expr21)

Returns the following:

0.5A(sin(-11tw) + sin(15tw))
0.5Asin(-11tw) + 0.5Asin(15tw)

As you can see, it does not catch the negative argument and I have tried a bunch of ways. Would anyone know how I could perform this simplification?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions