How to resolve the algorithm Element-wise operations step by step in the Mathematica / Wolfram Language programming language
How to resolve the algorithm Element-wise operations step by step in the Mathematica / Wolfram Language programming language
Table of Contents
Problem Statement
This task is similar to:
Implement basic element-wise matrix-matrix and scalar-matrix operations, which can be referred to in other, higher-order tasks. Implement:
Extend the task if necessary to include additional basic operations, which should not require their own specialised task.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Element-wise operations step by step in the Mathematica / Wolfram Language programming language
The Wolfram code you provided performs various element-wise operations on two matrices, M
and S
, and prints the results. Let's break down each operation and its output:
-
M + S
: Adds the scalar valueS
to each element of matrixM
.- Output:
{{17, 21, 23}, {27, 29, 33}, {39, 41, 47}}
- Output:
-
M - S
: Subtracts the scalar valueS
from each element of matrixM
.- Output:
{{-3, 1, 3}, {7, 9, 13}, {19, 21, 27}}
- Output:
-
M * S
: Multiplies each element of matrixM
by the scalar valueS
.- Output:
{{70, 110, 130}, {170, 190, 230}, {290, 310, 370}}
- Output:
-
M / S
: Divides each element of matrixM
by the scalar valueS
.- Output:
{{7/10, 11/10, 13/10}, {17/10, 19/10, 23/10}, {29/10, 31/10, 37/10}}
- Output:
-
M ^ S
: Raises each element of matrixM
to the power ofS
.- Output:
{{282475249, 25937424601, 137858491849}, {2015993900449, 6131066257801, 41426511213649}, {420707233300201, 819628286980801, 4808584372417849}}
- Output:
-
M + M
: Adds the matricesM
element-wise.- Output:
{{14, 22, 26}, {34, 38, 46}, {58, 62, 74}}
- Output:
-
M - M
: Subtracts matrixM
from itself element-wise.- Output:
{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}
- Output:
-
M * M
: Multiplies matricesM
element-wise.- Output:
{{49, 121, 169}, {289, 361, 529}, {841, 961, 1369}}
- Output:
-
M / M
: Divides matrixM
by itself element-wise.- Output:
{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}
- Output:
-
M ^ M
: Raises matrixM
to the power of itself element-wise.- Output:
{{823543, 285311670611, 302875106592253}, {827240261886336764177, 1978419655660313589123979, 20880467999847912034355032910567}, {2567686153161211134561828214731016126483469, 17069174130723235958610643029059314756044734431, 10555134955777783414078330085995832946127396083370199442517}}
- Output:
Source code in the wolfram programming language
S = 10 ; M = {{7, 11, 13}, {17 , 19, 23} , {29, 31, 37}};
M + S
M - S
M * S
M / S
M ^ S
M + M
M - M
M * M
M / M
M ^ M
Gives:
->{{17, 21, 23}, {27, 29, 33}, {39, 41, 47}}
->{{-3, 1, 3}, {7, 9, 13}, {19, 21, 27}}
->{{70, 110, 130}, {170, 190, 230}, {290, 310, 370}}
->{{7/10, 11/10, 13/10}, {17/10, 19/10, 23/10}, {29/10, 31/10, 37/10}}
->{{282475249, 25937424601, 137858491849}, {2015993900449,
6131066257801, 41426511213649}, {420707233300201, 819628286980801,
4808584372417849}}
->{{14, 22, 26}, {34, 38, 46}, {58, 62, 74}}
->{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}
->{{49, 121, 169}, {289, 361, 529}, {841, 961, 1369}}
->{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}
->{{823543, 285311670611, 302875106592253}, {827240261886336764177,
1978419655660313589123979,
20880467999847912034355032910567}, {2567686153161211134561828214731016126483469,
17069174130723235958610643029059314756044734431,
10555134955777783414078330085995832946127396083370199442517}}
You may also check:How to resolve the algorithm HTTPS step by step in the Ioke programming language
You may also check:How to resolve the algorithm Sorting Algorithms/Circle Sort step by step in the Swift programming language
You may also check:How to resolve the algorithm Reverse a string step by step in the NS-HUBASIC programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the Clipper programming language
You may also check:How to resolve the algorithm Create a file step by step in the PicoLisp programming language