Re: Write an expression in a specific form
- To: mathgroup at smc.vnet.net
- Subject: [mg108025] Re: Write an expression in a specific form
- From: dh <dh at metrohm.com>
- Date: Fri, 5 Mar 2010 04:35:13 -0500 (EST)
- References: <hmo293$qbh$1@smc.vnet.net>
Hi Ares, Mathematica really seems to have difficulties (that is I do not have the nerves to wait so long) with a calculation that can done by hand. It look like it needs some human help. We may get an equation for the exponents with only 2 unknowns. We denot by m1,s1 and m2,s2 the parameters of the given Gaussian. m3,s3 and c3 denote the searched Gaussian: c4 G[m3,s3]. tmp is an intermediate result we are not interested in: sol1 = Reduce[{ForAll[ x, (x - m1)^2/(2 s1^2) + (x - m2)^2/(2 s2^2) == tmp + (x - m3)^2/(2 s3^2)], s1 > 0, s2 > 0, s3 > 0}, {m3, s3, tmp}, Reals] this gives us m3,s3 and an intermediate result tmp. With this we may solve the equation for the pre factor. Toward this aim we change sol1 to rules and use it in the equation: G[m1, s1, x] G[m2, s2, x] == c3 G[m3, s3, x] /. sol1 /. sol1 Note that in sol1 tmp is given in term of m3,s3. We must therefore apply /.sol1 twice. I also delete some superfluous info from the result. Here is the whole code: ================ G[m_, s_, x_] := (1/(s*Sqrt[2*Pi]))*Exp[-(x - m)^2/(2*s^2)]; sol1 = Reduce[{ForAll[ x, -((x - m1)^2/(2 s1^2)) - (x - m2)^2/(2 s2^2) == tmp - (x - m3)^2/(2 s3^2)], s1 > 0, s2 > 0, s3 > 0}, {m3, s3, tmp}, Reals]; sol1 = Drop[sol1, 2] // ToRules sol2 = Reduce[{G[m1, s1, x] G[m2, s2, x] == c3 G[m3, s3, x] /. sol1 /. sol1, s1 > 0, s2 > 0, s3 > 0, c3 > 0}, {c3}, Reals][[4]] // ToRules =============== Finally we may test if the calculation is correct: G[m1, s1, x] G[m2, s2, x] == c4 G[m3, s3, x] /. sol2 /. sol1 /. sol1 // Simplify Daniel On 04.03.2010 11:33, Ares Lagae wrote: > Hi all, > > I am a beginner in Mathematica, and I have the following "problem": How can > I write an expression in a specific form? > > For example: > > - Define a Gaussian: > > G[m_, s_, x_] := (1/(s*Sqrt[2*Pi]))*Exp[-(x - m)^2/(2*s^2)]; > > - Product of two Gaussians: > > G[m1, s1, x] * G[m2, s2, x] > > - How can I get Mathematica to write the result in terms of c * G[m_, s_, > x_]? I.e., get the values for c, m and s. > > Thanks, > > Ares Lagae > > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail:<mailto:dh at metrohm.com> Internet:<http://www.metrohm.com>
- Follow-Ups:
- Re: Re: Write an expression in a specific form
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: Re: Write an expression in a specific form
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: Re: Write an expression in a specific form