Message Boards Message Boards

Find the coefficient of an equation?

Posted 6 years ago

I have an equation which involves a lot of trigonometric functions. I want to find the coefficients of function Y (also include trigonometric functions) and without Y. I have tried Coefficient command but could not get the desired result because this command is only for the polynomial. So, which command I need to use to find the results. Anyone can help me it will be very appreciable.

Attachments:
4 Replies

What is wrong with the results you found? They seem correct to me. Here is a variation:

expr = 1/(
   8 Bi (1 + k)^2 S^2 (Bi + Bi k - 
      4 k S^2)) (-2 Bi (1 + 
        k) (-(1 + k) (Bi - 4 S^2) Cosh[2 S (-1 + Y)] + 
        Cosh[2 S] (Bi + Bi k - 4 k S^2 - 
           4 S^2 Cos[(Sqrt[Bi] Sqrt[-1 - k] (-1 + Y))/Sqrt[k]] Sec[(
             Sqrt[Bi] Sqrt[-1 - k])/Sqrt[k]])) Subscript[A, 2] + 
     1/(Bi + Bi k - k S^2) 8 Sqrt[
      Bi] (Bi + Bi k - 
        4 k S^2) (Sqrt[Bi] (1 + k) S (Bi + Bi k - k S^2) Y + 
        Sqrt[-1 - k] Sqrt[k]
          S^3 Sec[(Sqrt[Bi] Sqrt[-1 - k])/Sqrt[k]] Sin[(
          Sqrt[Bi] Sqrt[-1 - k] Y)/Sqrt[k]] + 
        Sqrt[Bi] (1 + 
           k) ((-Bi (1 + k) + k S^2 + 
              S^2 Cos[(Sqrt[Bi] Sqrt[-1 - k] (-1 + Y))/Sqrt[k]] Sec[(
                Sqrt[Bi] Sqrt[-1 - k])/Sqrt[k]]) Sinh[
             S] + (1 + k) (Bi - S^2) Sinh[S - S Y])) Subscript[A, 
      3]);
vars = {Y, Cosh[2 S (-1 + Y)], 
   Cos[(Sqrt[Bi] Sqrt[-1 - k] (-1 + Y))/Sqrt[k]], 
   Sin[(Sqrt[Bi] Sqrt[-1 - k] Y)/Sqrt[k]], Sinh[S - S Y]};
coeff = Coefficient[expr, vars, 1] // Simplify
withoutY = expr - coeff.vars // Simplify
coeff.vars + withoutY - expr // Simplify
Collect[expr, vars, Simplify]
POSTED BY: Gianluca Gorni

Thanks, for your help. I got my results. When I solved for 1, it gives me the coefficients of all the functions of Y but without Y it does not give me the same result as yours. I directly used the coefficient command and find for 0 (without Y), it gives me the very complicated answers involving all the functions of Y. See the attached file.

Attachments:

You are using Coefficient with a list as second argument. This usage does not seem to be documented. I don't understand what you are trying to do. However, you can turn your expression into a polynomial with a replacement rule:

expr = 1/(
   8 Bi (1 + k)^2 S^2 (Bi + Bi k - 
      4 k S^2)) (-2 Bi (1 + 
        k) (-(1 + k) (Bi - 4 S^2) Cosh[2 S (-1 + Y)] + 
        Cosh[2 S] (Bi + Bi k - 4 k S^2 - 
           4 S^2 Cos[(Sqrt[Bi] Sqrt[-1 - k] (-1 + Y))/Sqrt[k]] Sec[(
             Sqrt[Bi] Sqrt[-1 - k])/Sqrt[k]])) Subscript[A, 2] + 
     1/(Bi + Bi k - k S^2) 8 Sqrt[
      Bi] (Bi + Bi k - 
        4 k S^2) (Sqrt[Bi] (1 + k) S (Bi + Bi k - k S^2) Y + 
        Sqrt[-1 - k] Sqrt[k]
          S^3 Sec[(Sqrt[Bi] Sqrt[-1 - k])/Sqrt[k]] Sin[(
          Sqrt[Bi] Sqrt[-1 - k] Y)/Sqrt[k]] + 
        Sqrt[Bi] (1 + 
           k) ((-Bi (1 + k) + k S^2 + 
              S^2 Cos[(Sqrt[Bi] Sqrt[-1 - k] (-1 + Y))/Sqrt[k]] Sec[(
                Sqrt[Bi] Sqrt[-1 - k])/Sqrt[k]]) Sinh[
             S] + (1 + k) (Bi - S^2) Sinh[S - S Y])) Subscript[A, 
      3]);
vars = {Y, Cosh[2 S (-1 + Y)], 
   Cos[(Sqrt[Bi] Sqrt[-1 - k] (-1 + Y))/Sqrt[k]], 
   Sin[(Sqrt[Bi] Sqrt[-1 - k] Y)/Sqrt[k]], Sinh[S - S Y]};
Collect[expr /. Thread[vars -> {a, b, c, d, e}], {a, b, c, d, e}]
POSTED BY: Gianluca Gorni

Thank you for your help. I understand I was solving without converting into a polynomial.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract