"Nasser M. Abbasi" <nma@12000.org> wrote in message <k7p79m$lbr$1@speranza.aioe.org>...
> On 11/11/2012 3:02 PM, Xu wrote:
> > Hello everyone,
> >
> > For example, my function is x1^2*t^2 + x2^2*t^2+ .... + xn^2*t^2 + t^2, where n is any integer,
> >I want to get the derivative wrt t at x1=1, x2=1, ..., xn=1, t=1.
> >
> > For example, if n=2, f = x1^2*t^2 + x2^2*t^2 + t^2, I can use 'subs' to get the derivative
> > answer=subs(diff(f,t), {x1,x2,t}, {1,1,1}) .
> >
> > However, since n is not fixed, how can I get the solution if n is very large, I cannot input
> > subs(diff(f,t), {x1,x2,x3.......x100}).
> >
> > I tried
> > subs(diff(f,t), {x,t}, {zeros(1,100),1})
> > Does not work.
> >
> > I will appreciate if anyone can give me some advice. Thanks.
> >
>
>
> Isn't your function simply
>
> f(t)=(x1^2+x2^2+....+xn^2)*t^2?
>
> then the derivative is
>
> 2*t*(x1^2+x2^2+....+xn^2)
>
> So you do not need to call diff at all. Simply subs values
> for t and all the x's in the above expression. Easier to use
> numerics here.
>
> If your x values are in a vector X for example, you can do
> something like
>
> sum(X.^2) * 2*t
>
> Nasser
No, that was my example. My function is much more complex. So I need to use
subs(diff(f,t), {X,t}, (Xvalue, tvalue))
where X is a vector.
