MathGroup Archive 2008

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

Search the Archive

I am having some problem manipulating mathematica expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91633] I am having some problem manipulating mathematica expressions
  • From: pratip <pratip.official at gmail.com>
  • Date: Sat, 30 Aug 2008 01:51:10 -0400 (EDT)

Hallo everybody,

I am having a small problem while dealing with the parts of a Mathematica expression. Here I give an example.
take the LHS of a  system of equations
{a*Sin[y*x]*x^2-x^3+Cos[b*(y/Exp[c*x])]==0,
c*x^2+Log[d*(x*y)]==0}
Hence the expression is
{
a*Sin[y*x]*x^2-x^3+Cos[Tan[x+y]+b*(y/Exp[c*x])],
c*x^2+Log[d*(x*y)]
}
Now take the first expression
There we can see the three first level terms
{
a*Sin[y*x]*x^2,
x^3,
Cos[Tan[x+y]+b*(y/Exp[c*x])
}
separated with {+,-,+}
Now how to Count how many such parts exists in general?
Because I want to get every single term multiplied with different symbols. Here we have three terms in the first expression so we must get
{p$1*(a*Sin[y*x]*x^2)-p$2*(x^3)+p$3*(Cos[Tan[x+y]+b*(y/Exp[c*x])]}
Hence I am trying to write a function that is defined like this

MyFunction[x_List]:={List[y],List[p]}
and works like this
Input:
{
a*Sin[y*x]*x^2-x^3+Cos[Tan[x+y]+b*(y/Exp[c*x])],
c*x^2+Log[d*(x*y)]
}
Output:
{
{p$11*(a*Sin[y*x]*x^2)-p$12*(x^3)+p$13*(Cos[Tan[x+y]+b*(y/Exp[c*x])]),p$21*(c*x^2)+p$22*(Log[d*(x*y)])},
{p$11,p$12,p$13,p$21,p$22}
}
I don't think it is too difficult for people of your skills. But I don't know a very nice way to do it when the starting equation system can have any number of equations and LHS of every equation can have any number of first level terms combined with "+" or "-". It might also occur that some equations will have just a single term LHS e.g "x^2==0".

So that was the primary problem. It will be even better (actually that is the real thing I am looking for) if it is possible to extend this operation on every higher part level recursively. That means to multiply part of a part with symbols like before. For example if we have the following equation
Cos[Tan[x+y]+b*(y/Exp[c*x])]==0 we have

Input:
{Cos[Tan[x+y]+b*(y/Exp[c*(x+Sin[x+y])])]}

Output:
{
{p$1$1$1*(Cos[Tan[p$1$2$1*x+p$1$2$2*y])+p$1$1$2*(b*(y/Exp[p$1$2$3*c*(x+Sin[p$1$3$1*x+p$1$3$2*y])]))])},
{{p$1$1$1,p$1$1$2},
{p$1$2$1,p$1$2$2,p$1$2$3},
{p$1$3$1,p$1$3$2}}
}

Down is the explanation of this above notation

*****What is i*****
The meaning of the symbol p$i$j$k is as follows
"i" denotes the number of main expression p occurs. Here we had only one expression so all i is equal to one. If we had two expressions some p will be like "p$2$j$k".

*****What is j*****
"j" denotes the level in the expression where p is getting multiplied. In the above example there are three parameter that occurs in the second level namely {p$1$2$1,p$1$2$2,p$1$2$3}.

*****What is k*****
"k" is meant for counting the p that occurs in a fixed level in a fixed expression.

I finally re grate that my message may seem too long for many of you though the question in it is not that much challenging at least mathematically. But I hope some of you might have a nice answer. My skill in Mathematica seems to be not enough to deal with this problem.I am feeling kind of hopeless.

Pratip


  • Prev by Date: Re: light-weight PC to run Mathematica?
  • Next by Date: Debugger
  • Previous by thread: Re: animated faces of polygon
  • Next by thread: Debugger