Thread Subject: quadratic form with symbolic vectors?

Subject: quadratic form with symbolic vectors?

From: David Doria

Date: 25 Feb, 2008 19:36:02

Message: 1 of 5

I would like to differentiate x'Ax. Here my x is y-B*u and
A is the identity matrix

syms B u1 u2 y1 y2 real
u=[u1; u2]
y=[y1; y2]
I=eye(2);
pretty(diff((y-B*u)'*I*(y-B*u),B))

I don't know how to interpret the output:

-2 (y1~ - B~ u1~) u1~ - 2 (y2~ - B~ u2~) u2~

what are all the tilda's for? Am I doing this correctly?

Thanks!

David

Subject: quadratic form with symbolic vectors?

From: Ashish Uthama

Date: 25 Feb, 2008 20:05:28

Message: 2 of 5


looks like 'pretty' is messing things up (or rather, I do not know how t=
o =

interepret this..)

>> (diff((y-B*u)'*I*(y-B*u),B))

ans =3D

-2*(y1-B*u1)*u1-2*(y2-B*u2)*u2

(if you did not know, PRETTY just not change the answer, just tries to =

print the ans in a 'nice' way)


On Mon, 25 Feb 2008 14:36:02 -0500, David Doria <daviddoria@gmail.com> =

wrote:

> syms B u1 u2 y1 y2 real
> u=3D[u1; u2]
> y=3D[y1; y2]
> I=3Deye(2);
> pretty(diff((y-B*u)'*I*(y-B*u),B))

Subject: quadratic form with symbolic vectors?

From: David Doria

Date: 25 Feb, 2008 20:28:01

Message: 3 of 5

I did know that pretty tried to make it display nice, so
then I guess question 1 is why does pretty put ~ all over??

Then Question 2: If i run the following:

--------
%throughout, sigma = sigma^2
clear;clc;close all;
syms N sigma B u1 u2 y1 y2 real

u=[u1; u2]
y=[y1; y2]
I = eye(2);
%diff((y-B*u)'*I*(y-B*u),B)

lnf = -N/2*log(2*pi) - N/2 * log(sigma) + -1/(2*sigma)*(y -
B*u)'*(y-B*u);

%first derivatives
pretty(diff(lnf,B))

--------

it gives me the sum of 2 things, which are each the same
because it should just be something in terms of a vector
(the 2 components are what got broken up). Is there a way
for it to give back the result in vector form?

Thanks,

Dave

Subject: quadratic form with symbolic vectors?

From: David Doria

Date: 26 Feb, 2008 12:24:01

Message: 4 of 5

am I doing something wrong? Or is this for some reason not
supposed to work?
bump

Subject: quadratic form with symbolic vectors?

From: Ashish Uthama

Date: 26 Feb, 2008 13:33:56

Message: 5 of 5

My basic take is that the symbolic toolbox does not work with matrices as
you expect.
looks like you have to deal with seperating each row


On Tue, 26 Feb 2008 07:24:01 -0500, David Doria <daviddoria@gmail.com>
wrote:

> am I doing something wrong? Or is this for some reason not
> supposed to work?
> bump

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