Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docsa.stemfard.com/llms.txt

Use this file to discover all available pages before exploring further.

The matrix arithmetic endpoints let you perform basic arithmetic operations on matrices. There are seven endpoints in this group: a combined endpoint that accepts an operation parameter, and six individual endpoints — one per operation. All endpoints accept two input matrices a and b (or a and a scalar for element-wise operations) and the full set of common request parameters.

Combined endpoint

Use this endpoint to run any arithmetic operation in a single request by setting the operation field. POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic

Parameters

a
number[][]
required
The first input matrix, expressed as an array of row arrays. Default: [[5, 1, 6], [3, 4, 5], [6, 4, 8]].
b
number[][] | number
required
The second input matrix or scalar. For element-wise operations, b must have the same dimensions as a. For matmul, the number of columns in a must equal the number of rows in b. Default: [[-4, -2, 6], [4, 7, -3], [7, -3, 5]].
operation
string
required
The arithmetic operation to perform. Accepted values:
  • "all" — run all operations and return all results
  • "add" — element-wise addition
  • "subtract" — element-wise subtraction
  • "multiply-ew" — element-wise (Hadamard) multiplication
  • "divide-ew" — element-wise division
  • "raise-ew" — element-wise power (each element of a raised to the corresponding element of b)
  • "matmul" — standard matrix multiplication
result_name
string
default:"ans"
Name assigned to the computed result in the response.
api_level
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
steps_bg
boolean
default:"true"
Include background theory alongside solution steps.
steps_output_formats
string[]
default:"[\"\"]"
Format for step content: "html", "latex", or "speech".
decimals
integer | null
default:"null"
Decimal precision for rounding the result. Pass null for full precision.
apply_decimals_in_steps
boolean
default:"false"
Apply decimals rounding to intermediate step values.
request_params
boolean
default:"true"
Include normalized request parameters in the response.
learning_pathways
boolean
default:"true"
Include curated learning resource links in the response.
Include links to related Stemfard endpoints in the response.
properties
boolean
default:"true"
Include a description of the result object’s properties.

Example — matrix multiplication via the combined endpoint

curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic \
  --header 'Authorization: Bearer <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[2, 7, 3], [4, -1, 6], [5, 8, 3]],
    "b": [[1, 0], [0, 1], [2, 3]],
    "operation": "matmul",
    "result_name": "product",
    "api_level": "standard"
  }'
200
{
  "product": [[8, 16], [16, 17], [11, 17]],
  "operation": "matmul"
}

Individual operation endpoints

Each operation has its own focused endpoint. These endpoints do not accept an operation field — the operation is determined by the path. All accept a, b, and the common parameters.
Adds two matrices element by element. a and b must have identical dimensions.POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/add
a
number[][]
required
First input matrix.
b
number[][]
required
Second input matrix. Must have the same dimensions as a.
result_name
string
default:"ans"
Name for the result in the response.
api_level
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
decimals
integer | null
default:"null"
Decimal precision for the result.
Example
curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/add \
  --header 'Authorization: Bearer <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[1, 2, 3], [4, 5, 6]],
    "b": [[7, 8, 9], [10, 11, 12]],
    "result_name": "sum",
    "api_level": "standard"
  }'
200
{
  "sum": [[8, 10, 12], [14, 16, 18]]
}
Subtracts b from a element by element. Both matrices must have identical dimensions.POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/subtract
a
number[][]
required
First input matrix (minuend).
b
number[][]
required
Second input matrix (subtrahend). Must have the same dimensions as a.
result_name
string
default:"ans"
Name for the result in the response.
api_level
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
decimals
integer | null
default:"null"
Decimal precision for the result.
Example
curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/subtract \
  --header 'Authorization: Bearer <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[10, 20], [30, 40]],
    "b": [[1, 5], [10, 15]],
    "result_name": "difference",
    "api_level": "lite"
  }'
200
{
  "difference": [[9, 15], [20, 25]]
}
Computes the Hadamard (element-wise) product of a and b. Each element at position (i, j) in the result equals a[i][j] × b[i][j]. Both matrices must have identical dimensions.POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/multiply-ew
a
number[][]
required
First input matrix.
b
number[][]
required
Second input matrix. Must have the same dimensions as a.
result_name
string
default:"ans"
Name for the result in the response.
api_level
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
decimals
integer | null
default:"null"
Decimal precision for the result.
Example
curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/multiply-ew \
  --header 'Authorization: Bearer <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[1, 2], [3, 4]],
    "b": [[5, 6], [7, 8]],
    "result_name": "hadamard",
    "api_level": "lite"
  }'
200
{
  "hadamard": [[5, 12], [21, 32]]
}
Divides each element of a by the corresponding element of b. Both matrices must have identical dimensions. Division by zero in b will produce an error.POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/divide-ew
a
number[][]
required
Numerator matrix.
b
number[][]
required
Denominator matrix. Must have the same dimensions as a. No element may be zero.
result_name
string
default:"ans"
Name for the result in the response.
api_level
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
decimals
integer | null
default:"null"
Decimal precision for the result.
Example
curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/divide-ew \
  --header 'Authorization: Bearer <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[10, 20], [30, 40]],
    "b": [[2, 4], [5, 8]],
    "result_name": "quotient",
    "api_level": "lite",
    "decimals": 2
  }'
200
{
  "quotient": [[5.0, 5.0], [6.0, 5.0]]
}
Raises each element of a to the power of the corresponding element of b. The result at position (i, j) equals a[i][j] ^ b[i][j]. Both matrices must have identical dimensions.POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/raise-ew
a
number[][]
required
Base matrix.
b
number[][]
required
Exponent matrix. Must have the same dimensions as a.
result_name
string
default:"ans"
Name for the result in the response.
api_level
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
decimals
integer | null
default:"null"
Decimal precision for the result.
Example
curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/raise-ew \
  --header 'Authorization: Bearer <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[2, 3], [4, 5]],
    "b": [[3, 2], [2, 3]],
    "result_name": "power",
    "api_level": "lite"
  }'
200
{
  "power": [[8, 9], [16, 125]]
}
Performs standard matrix multiplication (dot product). The number of columns in a must equal the number of rows in b. If a is m × k and b is k × n, the result is m × n.POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/matmul
a
number[][]
required
Left-hand matrix. An m × k matrix.
b
number[][]
required
Right-hand matrix. A k × n matrix. The number of rows must equal the number of columns in a.
result_name
string
default:"ans"
Name for the result in the response.
api_level
string
default:"detailed"
Response verbosity: "lite", "standard", or "detailed".
decimals
integer | null
default:"null"
Decimal precision for the result.
Example
curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/matmul \
  --header 'Authorization: Bearer <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[2, 7, 3], [4, -1, 6], [5, 8, 3]],
    "b": [[1, 0], [0, 1], [2, 3]],
    "result_name": "product",
    "api_level": "standard"
  }'
200
{
  "product": [[8, 16], [16, 17], [11, 17]]
}
Matrix multiplication is not commutative — a × b is not equal to b × a in general. Make sure you pass the matrices in the correct order for your use case.