Skip to content

Simplifying simple trigonometric expressions using Symbolics and SymbolicUtils does not work #1644

@Shuvomoy

Description

@Shuvomoy

I trying to verify the following trigonometric expression arising in energy system:

$$v_k(t) = \bar{V} \cos(\omega t + \phi_k)$$

$$i_k(t) = \bar{I} \cos(\omega t + \phi_k - \psi)$$

$$v_k(t) \times i_k(t) = \frac{\bar{V}\bar{I}}{2}\cos(\psi)(1 + \cos(2(\omega t + \phi_k))) + \frac{\bar{V}\bar{I}}{2}\sin(\psi)\sin(2(\omega t + \phi_k))$$

Verifying such trigonometric identities are very easy in Wolfram Mathematica:

(*Define voltage and current waveforms*)
vk[t_] := Vbar Cost + ϕk];
ik[t_] := Ibar Cost + ϕk - ψ];

(*Define instantaneous power as their product*)
pk[t_] := vk[t] ik[t];

(*Use TrigReduce to expand the product of cosines*)
expandedProduct = TrigReduce[pk[t]];

(*Define the target expression from the screenshot*)
targetExpression[
   t_] := (Vbar Ibar/2) Cos[ψ] (1 + 
      Cos[2t + ϕk)]) + (Vbar Ibar/
       2) Sin[ψ] Sin[2t + ϕk)];
	   
(*Verify if both terms are equal*)	   
Simplify[pk[t] - targetExpression[t]]

which outputs 0. However, when I try in Julia:

using Symbolics, SymbolicUtils

@variables t Vbar Ibar ω φk ψ

vk(t) = Vbar * cos*t + φk)
ik(t) = Ibar * cos*t + φk - ψ)
pk(t) = vk(t) * ik(t)
expandedProduct = simplify(pk(t), expand=true)
targetExpression(t) = (Vbar * Ibar / 2) * cos(ψ) * (1 + cos(2 **t + φk))) +
                      (Vbar * Ibar / 2) * sin(ψ) * sin(2 **t + φk))
difference = pk(t) - targetExpression(t)
simplified_difference = simplify(difference, expand=true)

The output is -(1//2)*Ibar*Vbar*cos(ψ) + Ibar*Vbar*cos(φk + t*ω)*cos(φk - ψ + t*ω) - (1//2)*Ibar*Vbar*sin(2φk + 2t*ω)*sin(ψ) - (1//2)*Ibar*Vbar*cos(2φk + 2t*ω)*cos(ψ). Is there any function similar to TrigExpand in Julia? Any tips regarding how to simplify the term in Symbolics will be much appreciated.

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