-2

Given that $x$ and $y$ are column vectors and $A$ is a matrix, I figured out the result $y^{T}y-2y^{T}Ax +x^{T}A^{T}A\,x$

I want to use Mathematica to make such calculations. how do I enter them into a notebook?

Below is my attempt

1]

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
tiankonghewo
  • 605
  • 4
  • 10
  • 1
    It would be beneficial if you could show what you have already tried with a short description why it does not fulfil your requirements. This would allow others to give you a better answer. – e.doroskevic Dec 07 '15 at 12:48
  • This may be a duplicate of: http://mathematica.stackexchange.com/q/3242/131 and/or http://mathematica.stackexchange.com/q/52213/131 (both deal with symbolic vector notation). – Yves Klett Dec 07 '15 at 13:01
  • Also relevant: http://mathematica.stackexchange.com/a/40368/242 (esp. the first three paragraphs) – Niki Estner Dec 07 '15 at 15:00

1 Answers1

2

Without the addition of third-party symbolic algebra packages, Mathematica does symbolic algebra best with definite dimensions. You can do things like

With[{m = 3, n = 4},
  Module[{A, xx, yy},
    A = Array[a, {m, n}];
    xx = Array[x, n];
    yy = Array[y, m];
    (yy - A.xx).(yy - A.xx)]]
(-a[1, 1] x[1] - a[1, 2] x[2] - a[1, 3] x[3] - a[1, 4] x[4] + y[1])^2 + 
(-a[2, 1] x[1] - a[2, 2] x[2] - a[2, 3] x[3] - a[2, 4] x[4] + y[2])^2 + 
(-a[3, 1] x[1] - a[3, 2] x[2] - a[3, 3] x[3] - a[3, 4] x[4] + y[3])^2

Note that Mathematica does not distinguish between row and column vectors and will not transpose vectors.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257