-1

I'm quite new on Jupiter Notebook and I don't really know phyton, could someone tell me how to define a matrix? I mean, what should I write after:

A = [···]

I've tried "A=Matrix(QQbar, 2, 2, [1,2],[3,4])" and some similiar options but it always report "too many arguments in matrix constructor".

Thanks

Vitalizzare
  • 4,496
  • 7
  • 13
  • 32
ORIOL BF
  • 11
  • 2
  • Describe your environment and a package which you are trying to use, please. It's not `numpy.matrix`, and jupyter-notebook with python seems not to have any `show` method by default, which you mention in the answer. – Vitalizzare Aug 18 '22 at 20:44
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 19 '22 at 07:03

3 Answers3

1

After a while I was able to find it out by myself, I'm not sure if that's the proper way to do it but since it works it helped me:

A = Matrix(2, 2, [1,2,3,4])

This code will define A and when you write A and press Ctrl+enter you will get something like this:

[1 2]
[3 4]

It may not seem to be a Matrix but if you write the following then it will print a real matrix:

show(A)

Hope I can help someone!

ORIOL BF
  • 11
  • 2
1

you can use a numpy array:

import numpy as np

m1=np.array([[1,2,3],[4,5,6]])  # this will result a 2x3 matrix
m2=np.array([3,6,9])  # and this will result in a 1x3 matrix

Also, as a bonus you can make a vector matrix multiplication with m1.dot(m2) and this result is a 2x1 matrix. Multiplication result will take the row count of m1 and column count of m2.

M.H. Tajaddini
  • 776
  • 4
  • 20
minemu
  • 11
  • 1
0

The Matrix function has a function definition after you type Matrix() which shows the arguments required to run which are row, col, [listed matrix]

We use

init_printing()

after importing Sympy in my math course.

Using that, you can just simply type the variable or multiple using

(a,b,c,d)

as a code line.

buddemat
  • 4,552
  • 14
  • 29
  • 49