-1
$\begingroup$

Can I get some help with this:

Write a module which as an input receives two matrices, the first matrix transforms in to the same matrix, but in the new matrix occur absolute values of the first, the second matrix makes the upper triangle and returns the product of these matrices. If the product is not possible it should print a message.

$\endgroup$

closed as off-topic by Bob Hanlon, m_goldberg, chris, Sjoerd C. de Vries, bbgodfrey May 23 '15 at 12:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Bob Hanlon, m_goldberg, chris, Sjoerd C. de Vries, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    $\begingroup$ …and, what about your coding attempts? $\endgroup$ – J. M. is away May 23 '15 at 10:18
  • $\begingroup$ well i made the first matrix and i know how to make the second , but to make the second i have to make a matrix with absolute values of the first , which i don't know how . here is my code for the for the first matrix with negative values M = {}; For[i = -3, i <= -1, i++, redica = {}; For[j = -3, j <= -1, j++, AppendTo[redica, i + j] ]; AppendTo[M, redica] ]; M MatrixForm[M] , can you help me ? $\endgroup$ – TR19 May 23 '15 at 11:35
  • 1
    $\begingroup$ You should include your work-in-progress code in the question. If people see you are making effort they are much more likely to do the same on your behalf. $\endgroup$ – Mr.Wizard May 23 '15 at 11:37
  • 2
    $\begingroup$ We have had a lot of repeat questions with the same set of problems recently. I have to wonder if your instructor is doing a good job of preparing you to complete these assignments. The fact that you are writing in loops using For and AppendTo suggests to me that you have not had a good introduction to Mathematica. If this assignment was specific to Mathematica as I believe I suspect that this class is not well structured. $\endgroup$ – Mr.Wizard May 23 '15 at 11:45
  • 1
    $\begingroup$ this is for my discrete mathematics class , we don't have classes to explain how we could work in Mathematica they give us presentations where some functions are explained , but i don't know how to find the absolute values for the first matrix , because they didn't give us an explanation how to do it , so that is my question how to find the absolute values of the matrix i wrote above? Please help , I have to make this assignment to get a signаture $\endgroup$ – TR19 May 23 '15 at 11:55
2
$\begingroup$

In Mathematica Abs is a Listable function which means that it may be applied to a scalar, matrix, or tensor directly:

m1 = {{1, -8, 3}, {-1, -7, 9}, {-1, 0, -9}};

Abs[m1]
{{1, 8, 3}, {1, 7, 9}, {1, 0, 9}}

UpperTriangularize works like this:

UpperTriangularize[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}]
{{1, 2, 3}, {0, 5, 6}, {0, 0, 9}}

Matrix product is implemented in Dot.

For writing this as "a module which as an input receives two matrices" see:

Finally a Q&A that is intended to steer users toward an efficient coding style:

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.