TransWikia.com

How to extract terms from equation, and then set each of them to 0?

Mathematica Asked by PureLine on September 2, 2020

I have a long equation, namely,

equ = 4576.66 a[1] Cos[t] + 3.3877 a[1]^3 Cos[t]^3 + 4576.65 a[2] Cos[2 t] + 10.1631 a[1]^2 a[2] Cos[t]^2 Cos[2 t] + 10.1631 a[1] a[2]^2 Cos[t] Cos[2 t]^2 + 3.3877 a[2]^3 Cos[2 t]^3 + 4576.63 a[3] Cos[3 t] + 10.1631 a[1]^2 a[3] Cos[t]^2 Cos[3 t] + 20.3262 a[1] a[2] a[3] Cos[t] Cos[2 t] Cos[3 t] + 10.1631 a[2]^2 a[3] Cos[2 t]^2 Cos[3 t] + 10.1631 a[1] a[3]^2 Cos[t] Cos[3 t]^2 + 10.1631 a[2] a[3]^2 Cos[2 t] Cos[3 t]^2 + 3.3877 a[3]^3 Cos[3 t]^3 - 0.415 a[1] Sin[t] - 0.83 a[2] Sin[2 t] - 1.245 a[3] Sin[3 t] == 2/625 Cos[theta] Cos[t w] - 2/625 Sin[theta] Sin[t w]

Since Sin[t]*Cos[t]^3 and so on is a small term, we can take it as 0. Consequently, we would like to eliminate sin[t] and cos[t] to the power of n. My instinct is to use Cases to achieve it, but I don’t how to make it.

For example, I want keep 4576.66 a[1] Cos[t] and 4576.65 a[2] Cos[2 t], but set 4576.65 a[2] Cos[2 t] and 10.1631 a[1]^2 a[2] Cos[t]^2 Cos[2 t] to 0.

More Information

  1. Aside from Cos[t]^2 and Cos[2t]^3, Sin[t]*Cos[t] and Sin[t]^2*Sin[2t] and so on should be eliminate. In other words, only Sin[t] Sin[2t] Sin[3t]Sin[n*t] and Cos[t] Cos[2t] Cos[3t]Cos[n*t] should be left.

  2. Terms like Sin[theta] Sin[t w] should survive, because Sin[theta] is a constant.

Summary of the solution

Use the following wolfram language grammar to extract the expected term: _ h any expression with head h. Please refer to Patterns and Transformation Rules

One Answer

equ /. HoldPattern[ Power[_Cos | _Sin, _] | 
   Times[(Cos | Sin)[Except[theta]], (Cos | Sin)[Except[theta]], ___]] -> 0

enter image description here

Correct answer by kglr on September 2, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP