0
$\begingroup$

I would like to be able to extract terms that contain either a symbol or a small expression from a larger one.

Example (with a somewhat complicated function to give the idea of what I am after):

-R (δt + 2 θ2t Sin[θ1]) + 
 2 Cos[ϕ/
   2] (Sin[δ/
      2] (vz Sin[θ2] + 
       Cos[θ2] (vy Cos[θ3] + 
          h θ3t Sin[θ1] - vx Sin[θ3])) + 
    Cos[δ/
      2] (h (θ1t + θ3t Sin[θ2]) - 
       Sin[θ1] (vz Cos[θ2] - 
          vy Cos[θ3] Sin[θ2] + 
          vx Sin[θ2] Sin[θ3]))) - 
 2 l θ2t Cos[δ/2] Sin[θ1] Sin[ϕ/2] - 
 2 Cos[θ1] (-Cos[ϕ/2] (-h θ2t Sin[δ/2] + 
       Cos[δ/
         2] (vx Cos[θ3] + 
          vy Sin[θ3])) + θ3t Cos[θ2] (R + 
       l Cos[δ/2] Sin[ϕ/2]))

I would like Mma to return all the terms that multiply vx:

2 Cos[ϕ/
  2] (Sin[δ/
    2]Sin[θ3]))-2 Cos[θ1] -Cos[ϕ/2] 
     Cos[δ/2] Cos[θ3]
$\endgroup$
2
$\begingroup$
Coefficient[expr, vx] // Simplify

enter image description here

where expr is your expression.


Update

Coefficient[expr, Sin[\[Theta]2]] // Simplify

enter image description here

$\endgroup$
  • $\begingroup$ Would this work if instead of vx I had an expression like $\sin\theta_2$? $\endgroup$ – usumdelphini Jan 29 at 14:16
  • $\begingroup$ @usumdelphini Yes, I think so. Please see the updated part. $\endgroup$ – Αλέξανδρος Ζεγγ Jan 29 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.