Message Boards Message Boards

1
|
4656 Views
|
5 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Simplify the mathematical expression in any desired form?

Posted 4 years ago

Dear All,

I want to write the following expression

f[x_] := (E^(-h k0 x) + E^(
     h k0 x)) (-(-1 + 
         1/4 E^(-h (n1 + n2) x) (1 + E^(2 h n1 x)) (1 + E^(
            2 h n2 x))) m1 m2 (-2 Z13 + m1 n1 Z33 + m2 n2 Z33) - 
     1/4 E^(-h (n1 + n2) x) (-1 + E^(2 h n1 x)) (-1 + E^(
        2 h n2 x)) (m2^2 Z13 - m1 m2^2 n1 Z33 + 
        m1^2 (Z13 - m2 n2 Z33)));

grouping by the exponential parts, that is, f[x]=A1* Exp(B1x)+ A2 * Exp(B2x)…. +An * Exp(Bn*x) + C0

How can I do it?

Thanks

Isa

Attachments:
POSTED BY: Isa Comez
5 Replies
Posted 4 years ago

@Bill Nelson Great ! Many thanks.

@Henrik Schachner I also thank you so much. That is what i want.

POSTED BY: Isa Comez
Posted 4 years ago

Asking for "any desired form" probably doesn't have an answer.

Asking it to group by exponents is more feasible.

I believe this will accomplish that

f[x_] := (E^(-h k0 x) + E^(h k0 x)) (-(-1 + 1/4 E^(-h (n1 + n2) x) (1 + E^(2 h n1 x)) (1 + E^(
2 h n2 x))) m1 m2 (-2 Z13 + m1 n1 Z33 + m2 n2 Z33) - 1/4 E^(-h (n1 + n2) x) (-1 + E^(2 h n1 x)
)(-1 + E^(2 h n2 x)) (m2^2 Z13 - m1 m2^2 n1 Z33 + m1^2 (Z13 - m2 n2 Z33)));
Expand[f[x]] //. a_*Exp[c_]+b_*Exp[c_] :> (a+b)*Exp[c]
POSTED BY: Bill Nelson

@Bill Nelson Terrific solution! I did learn something - thank you! Just for the record: I was going to come up with something terrible (doing by hand what Simplify is supposed to do):

f1 = Simplify[Expand[f[x]] /. Exp[a__] :> \[FormalE][a]];
terms = Table[f1[[2, n]], {n, 1, Length[f1[[2]]]}];
termSum = Total[Simplify@*Total /@ GatherBy[terms, Last]];
result = f1[[1]] termSum /. \[FormalE][a_] :> Exp[a]

enter image description here

which basically gives the same output as yours.

Addendum:

For still nice-ing it up one might modify your solution into:

Simplify /@ (Expand[f[x]] //. a_*Exp[c_] + b_*Exp[c_] :> (a + b)*Exp[c])
POSTED BY: Henrik Schachner
Posted 4 years ago

Thanks Dr Schachner for your reply. However this code does not gather the terms that have the same exponential expressions. Please see the following and attached file

1/4 (-E^(h (k0 - n1 - n2) x) m1^2 Z13 + 
   E^(-h (k0 + n1 - n2) x) m1^2 Z13 + 
   E^(h (k0 + n1 - n2) x) m1^2 Z13 + 
   E^(-h (k0 - n1 + n2) x) m1^2 Z13 + 
   E^(h (k0 - n1 + n2) x) m1^2 Z13 - 
   E^(h (-k0 + n1 + n2) x) m1^2 Z13 - 
   E^(-h (k0 + n1 + n2) x) m1^2 Z13 + 
   2 E^(h (k0 - n1 - n2) x) m1 m2 Z13 + 
   2 E^(-h (k0 + n1 - n2) x) m1 m2 Z13 + 
   2 E^(h (k0 + n1 - n2) x) m1 m2 Z13 + 
   2 E^(-h (k0 - n1 + n2) x) m1 m2 Z13 + 
   2 E^(h (k0 - n1 + n2) x) m1 m2 Z13 + 
   2 E^(h (-k0 + n1 + n2) x) m1 m2 Z13 + 
   2 E^(-h (k0 + n1 + n2) x) m1 m2 Z13 - 
   E^(h (k0 - n1 - n2) x) m2^2 Z13 + 
   E^(-h (k0 + n1 - n2) x) m2^2 Z13 + 
   E^(h (k0 + n1 - n2) x) m2^2 Z13 + 
   E^(-h (k0 - n1 + n2) x) m2^2 Z13 + 
   E^(h (k0 - n1 + n2) x) m2^2 Z13 - 
   E^(h (-k0 + n1 + n2) x) m2^2 Z13 - 
   E^(-h (k0 + n1 + n2) x) m2^2 Z13 - 
   E^(h (k0 - n1 - n2) x) m1^2 m2 n1 Z33 - 
   E^(-h (k0 + n1 - n2) x) m1^2 m2 n1 Z33 - 
   E^(h (k0 + n1 - n2) x) m1^2 m2 n1 Z33 - 
   E^(-h (k0 - n1 + n2) x) m1^2 m2 n1 Z33 - 
   E^(h (k0 - n1 + n2) x) m1^2 m2 n1 Z33 - 
   E^(h (-k0 + n1 + n2) x) m1^2 m2 n1 Z33 - 
   E^(-h (k0 + n1 + n2) x) m1^2 m2 n1 Z33 + 
   E^(h (k0 - n1 - n2) x) m1 m2^2 n1 Z33 - 
   E^(-h (k0 + n1 - n2) x) m1 m2^2 n1 Z33 - 
   E^(h (k0 + n1 - n2) x) m1 m2^2 n1 Z33 - 
   E^(-h (k0 - n1 + n2) x) m1 m2^2 n1 Z33 - 
   E^(h (k0 - n1 + n2) x) m1 m2^2 n1 Z33 + 
   E^(h (-k0 + n1 + n2) x) m1 m2^2 n1 Z33 + 
   E^(-h (k0 + n1 + n2) x) m1 m2^2 n1 Z33 + 
   E^(h (k0 - n1 - n2) x) m1^2 m2 n2 Z33 - 
   E^(-h (k0 + n1 - n2) x) m1^2 m2 n2 Z33 - 
   E^(h (k0 + n1 - n2) x) m1^2 m2 n2 Z33 - 
   E^(-h (k0 - n1 + n2) x) m1^2 m2 n2 Z33 - 
   E^(h (k0 - n1 + n2) x) m1^2 m2 n2 Z33 + 
   E^(h (-k0 + n1 + n2) x) m1^2 m2 n2 Z33 + 
   E^(-h (k0 + n1 + n2) x) m1^2 m2 n2 Z33 - 
   E^(h (k0 - n1 - n2) x) m1 m2^2 n2 Z33 - 
   E^(-h (k0 + n1 - n2) x) m1 m2^2 n2 Z33 - 
   E^(h (k0 + n1 - n2) x) m1 m2^2 n2 Z33 - 
   E^(-h (k0 - n1 + n2) x) m1 m2^2 n2 Z33 - 
   E^(h (k0 - n1 + n2) x) m1 m2^2 n2 Z33 - 
   E^(h (-k0 + n1 + n2) x) m1 m2^2 n2 Z33 - 
   E^(-h (k0 + n1 + n2) x) m1 m2^2 n2 Z33 - 
   E^(h (k0 + n1 + n2) x) (m1 - m2) ((m1 - m2) Z13 + 
      m1 m2 (n1 - n2) Z33) + 
   4 E^(-h k0 x) m1 m2 (-2 Z13 + m1 n1 Z33 + m2 n2 Z33) + 
   4 E^(h k0 x) m1 m2 (-2 Z13 + m1 n1 Z33 + m2 n2 Z33))
Attachments:
POSTED BY: Isa Comez

Maybe like so:

Simplify[Expand[f[x]] /. Exp[a__] :> \[FormalE][a]] /. \[FormalE][a__] :> Exp[a]
POSTED BY: Henrik Schachner
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