RE: arguments of the function
- To: mathgroup at smc.vnet.net
- Subject: [mg35427] RE: [mg35402] arguments of the function
- From: "David Park" <djmp at earthlink.net>
- Date: Fri, 12 Jul 2002 04:28:41 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
It is a little difficult to understand what you really want. Is it just the
particular expression
expr1 = a1* Cos[Sin[u[t + 2]]]/Tan[u[t + 1]] - Cot[u[t + 3]] + a2
that you want to make the substitutions in? Why don't you want Sin[u[t + 2]]
to be considered as an argument? Or a1, which is an argument of Times, or
a2, which is an argument of Plus? What is the purpose of making the
substitution? Is it just to obtain a shorter display?
If you are only seeking arguments that fit the pattern u[_] (or if they can
be described by a more general pattern) then you could use the following
routine:
GenSubstitutionRules[expr_] :=
Module[{work, xsyms, i},
work = Union[Cases[expr, u[_], Infinity]];
xsyms = Table[Symbol["x" <> ToString[i]], {i, Length[work]}];
Thread[work -> xsyms]
]
subrules = GenSubstitutionRules[expr1]
expr1 /. subrules
{u[1 + t] -> x1, u[2 + t] -> x2, u[3 + t] -> x3}
a2 + a1 Cos[Sin[x2]] Cot[x1] - Cot[x3]
In using Mathematica to solve real problems, you will very often have to
write some of your own routines. Mathematica couldn't possibly have a
specific routine for every task.
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
> From: fee eerr [mailto:eleri111 at hot.ee]
To: mathgroup at smc.vnet.net
>
> Hi.
> I am using Mathematica 4.0
> I can't find a function that would find arguments of the function.
> For example I have an equation:
> y[t+3]=a1* Cos[Sin[u[t+2]]]/Tan[u[t+1]]-Cot[u[t+3]]+a2
>
> and I would like to get those argumets u[t+3], u[t+2], u[t+1]
> and give them new values
> for example:
>
> x1=u[t+3]
> x2=u[t+2]
> x3=u[t+1]
>
> and then print that equation with new values:
> y[t+3]=a1* Cos[Sin[x2]]/Tan[x3]-Cot[x1]+a2
>
> Can you tell me how to do that?
> Thank you.
>