FAQ overflow

QUESTION

A problem I am occasionally facing is to simplify an equation not to it's shortest form but to a form that is simple by other means. Often, this is grouping the term according to certain functions, for example exponential functions from a Fourier series.

For example,

1 Exp[i k t] + 2 x Exp[i k t] + (2 x + 1) Exp[i k t]^2 // Simplify



will give E^(i k t) (1 + E^(i k t)) (1 + 2 x). Instead,

(2 x + 1) Exp[i k t] + (2 x + 1) Exp[i 2 k t]



is often desired.

Is there any simple[1] way to achieve that?

[1] I once achieved that using the FourierTransform and replacing the DiracDelta with 1 or 0 to get the coefficients, but that is neither elegant nor always possible.

There is no need to play around with Simplify, since to achive what you need one can use Collect, e.g.

expr = Exp[i k t] + 2 x Exp[i k t] + (2 x + 1) Exp[i k t]^2;
Collect[expr, Exp[i k t]]


E^(i k t) (1 + 2 x) + E^(2 i k t) (1 + 2 x)



If there are more variables you can use a list of them as the second argument, look also at Simplify as the third argument in Collect. As J.M. pointed out one could use also PolynomialForm, to transform the expression into a more expected form, e.g.

Collect[expr, {Exp[i k t], x}] // PolynomialForm[#, TraditionalOrder -> True] &


 E^(i k t)(2 x + 1) + E^(2 i k t)(2 x + 1)



Although it seems that Collect is more appropriate for your task than Simplify, you can still take advantage of the latter if you make use of options like ExcludedForms to get what you would like, e.g.

Simplify[expr, ExcludedForms -> Exp[_]]


(E^(i k t) + E^(2 i k t)) (1 + 2 x)



or if you prefer an expanded form

Expand[%, E^(i k t)]


E^(i k t) (1 + 2 x) + E^(2 i k t) (1 + 2 x)



For the sake of completeness there is also Apart available (it seems the simplest way) :

Apart[expr]


E^(i k t) (1 + 2 x) + E^(2 i k t) (1 + 2 x)



in more general cases, there is also the second argument, e.g. Apart[expr, Exp[i k t]] returns the result as above.

To sum up there is no way to decide what is the best method, since all of them have their advantages, but as said before I suggest to use Collect.
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://faqoverflow.kranzky.com/mathematica/5946.html", "fetch_time": 1653598618000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2022-21/segments/1652662625600.87/warc/CC-MAIN-20220526193923-20220526223923-00666.warc.gz", "warc_record_offset": 290868516, "warc_record_length": 3773, "token_count": 633, "char_count": 2124, "score": 3.75, "int_score": 4, "crawl": "CC-MAIN-2022-21", "snapshot_type": "latest", "language": "en", "language_score": 0.8590043783187866, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00028-of-00064.parquet"}