Thread Subject: product rule derivative

Subject: product rule derivative

From: maria

Date: 30 Jan, 2012 15:44:08

Message: 1 of 3

hello,

I have:

x' = - 2 * sin(g);

g' = w; (w=1 for this experiment)

c' = 1;

V(x,g,c)=2*(1 - cos(g)) + w*x +c -1;

I would like to calculate V'. (By hand V'(x,g,c) = -w * 2 *sin (g) +
w*2* sin(g) + 1 -1 =0)

I wrote the following code but it is not completed

syms t; (t is a help variable)
 v=vpa('cos(g(t))');
 w=1;
 V=2*(1-v) + w*vpa('x(t)') + vpa('c(t)') -1;
 par=diff(V,t)

par =

2*sin(g(t))*diff(g(t), t) + diff(c(t), t) + diff(x(t), t)

and then ....

Thank you for your time.
Maria Kourkouli

Subject: product rule derivative

From: Christopher Creutzig

Date: 1 Feb, 2012 15:22:09

Message: 2 of 3

On 30.01.12 16:44, maria wrote:
> hello,
>
> I have:
>
> x' = - 2 * sin(g);
>
> g' = w; (w=1 for this experiment)
>
> c' = 1;
>
> V(x,g,c)=2*(1 - cos(g)) + w*x +c -1;
>
> I would like to calculate V'. (By hand V'(x,g,c) = -w * 2 *sin (g) +
> w*2* sin(g) + 1 -1 =0)

I don't follow. I'm not even sure what V'(x,g,c) is supposed to mean, I
only know f'(x) for univariate functions f. Assuming ' always should
mean derivative with respect to t: Are you sure the -1 at the end is right?

> I wrote the following code but it is not completed
>
> syms t; (t is a help variable)
> v=vpa('cos(g(t))');

That should be sym('cos(g(t))'), since you're not aiming for variable
precision floating point numbers.

> w=1;
> V=2*(1-v) + w*vpa('x(t)') + vpa('c(t)') -1;
> par=diff(V,t)
>
> par =
>
> 2*sin(g(t))*diff(g(t), t) + diff(c(t), t) + diff(x(t), t)

That looks right.

> and then ....

Insert your definitions from above:


>> subs(par, ...
 {diff(sym('x(t)'), t), diff(sym('g(t)'), t), diff(sym('c(t)'), t)}, ...
 {-2*sin(sym('g(t)')), w, 1})

ans =

1


Of course, you can reduce the amount of typing with definitions like

syms t;
c = sym('c(t)');
g = sym('g(t)');
x = sym('x(t)');

v = cos(g);
w = 1;
V = 2*(1-v) + w*x+c-1;
subs(diff(V, t), ...
     {diff(x, t), diff(g, t), diff(c, t)}, ...
     {-2*sin(g), w, 1})



Christopher

Subject: product rule derivative

From: maria

Date: 2 Feb, 2012 10:38:15

Message: 3 of 3

On 1 Φεβ, 17:22, Christopher Creutzig
<Christopher.Creut...@mathworks.com> wrote:
> On 30.01.12 16:44, maria wrote:
>
> > hello,
>
> > I have:
>
> > x' = - 2 * sin(g);
>
> > g' = w; (w=1 for this experiment)
>
> > c' = 1;
>
> > V(x,g,c)=2*(1 - cos(g)) + w*x +c -1;
>
> > I would like to calculate V'.   (By hand V'(x,g,c) = -w * 2 *sin (g) +
> > w*2* sin(g) + 1 -1 =0)
>
> I don't follow. I'm not even sure what V'(x,g,c) is supposed to mean, I
> only know f'(x) for univariate functions f. Assuming ' always should
> meanderivativewith respect to t: Are you sure the -1 at the end is right?
>
> > I wrote the following code but it is not completed
>
> > syms t; (t is a help variable)
> >  v=vpa('cos(g(t))');
>
> That should be sym('cos(g(t))'), since you're not aiming for variable
> precision floating point numbers.
>
> >  w=1;
> >  V=2*(1-v) + w*vpa('x(t)') + vpa('c(t)') -1;
> >  par=diff(V,t)
>
> > par =
>
> > 2*sin(g(t))*diff(g(t), t) + diff(c(t), t) + diff(x(t), t)
>
> That looks right.
>
> > and then ....
>
> Insert your definitions from above:
>
> >> subs(par, ...
>
>  {diff(sym('x(t)'), t), diff(sym('g(t)'), t), diff(sym('c(t)'), t)}, ...
>  {-2*sin(sym('g(t)')), w, 1})
>
> ans =
>
> 1
>
> Of course, you can reduce the amount of typing with definitions like
>
> syms t;
> c = sym('c(t)');
> g = sym('g(t)');
> x = sym('x(t)');
>
> v = cos(g);
> w = 1;
> V = 2*(1-v) + w*x+c-1;
> subs(diff(V, t), ...
>      {diff(x, t), diff(g, t), diff(c, t)}, ...
>      {-2*sin(g), w, 1})
>
> Christopher

thank you Cristopher!

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com