Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How do I create a parametric expression?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68609] Re: How do I create a parametric expression?
  • From: axlq at spamcop.net (axlq)
  • Date: Fri, 11 Aug 2006 04:40:53 -0400 (EDT)
  • References: <200608090819.EAA21141@smc.vnet.net> <ebebuu$lhj$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <ebebuu$lhj$1 at smc.vnet.net>,
Daniel Lichtblau  <danl at wolfram.com> wrote:
>This is probably best done with a form of algebraic replacement. I seem 
>to revisit this from time to time, for example see the URLs below. But 
>each time the code gets a bit longer.
>
>http://forums.wolfram.com/mathgroup/archive/2005/Apr/msg00273.html
>
>http://forums.wolfram.com/mathgroup/archive/2002/Jan/msg00354.html
>
>The code in those threads will not go inside transcendental functions. 
>So below is a modification that will.

Wow.  Thanks.  I have bookmarked the links.  The function leaves
instances of Sqrt[R^2] behind, and one instance of (R^2)^(5/2), but
those are easy to fix.

>replacementFunction[expr_,rep_,vars_] := With[
>   {num=Numerator[expr],den=Denominator[expr],hed=Head[expr]},
>   If [PolynomialQ[num,vars] && PolynomialQ[den,vars],
>     PolynomialReduce[num, rep, vars][[2]] /
>     PolynomialReduce[den, rep, vars][[2]]
>     , (* else *)
>     If [Head[hed]===Symbol&&MemberQ[Attributes[hed],NumericFunction],
>       Map[replacementFunction[#,rep,vars]&, expr]
>       , (* else *)expr]
>     ]
>   ]
>
>Your example:
>
>expr = -((1 + 2*n)*((a^4*k^2 + a^2*(-1 + k^2*(q - z)^2) + 2*(q - z)^2)*
>      Cos[k*Sqrt[a^2 + (q - z)^2]] - k*(a^2 - 2*(q - z)^2)*
>      Sqrt[a^2 + (q - z)^2]*Sin[k*Sqrt[a^2 + (q - z)^2]])*
>    Sin[((1 + 2*n)*Pi*z)/L])/(8*Pi*w*(a^2 + (q - z)^2)^(5/2));
>
>It appears to work best here if we do not encapsulate the thing we 
>replace in a square root.
>
>In[20]:= InputForm[replacementFunction[expr, a^2+(q-z)^2-R^2, {a,q,z}]]
>
>Out[20]//InputForm=
>-((1 + 2*n)*((-R^2 + k^2*R^4 + q^2*(3 - k^2*R^2) +
>   q*(-6 + 2*k^2*R^2)*z + (3 - k^2*R^2)*z^2)*Cos[k*Sqrt[R^2]] -
>     k*Sqrt[R^2]*(-3*q^2 + R^2 + 6*q*z - 3*z^2)*Sin[k*Sqrt[R^2]])*
>    Sin[((Pi + 2*n*Pi)*z)/L])/(8*Pi*(R^2)^(5/2)*w)

-Alex


  • Prev by Date: Re: Re: need mathematica's help for exploring a certain type of mapping
  • Next by Date: RE: Re: NDSolve with boundary condition(s) at infinity?
  • Previous by thread: Re: How do I create a parametric expression?
  • Next by thread: Re: [TS 19859]--Re:creating code that writes other code ...