Problem · Math

Solve Matrix Equations (Also for AI/ML Interns :)

Learn this problem
EasySnowflake logoSnowflakeINTERNOA
See Snowflake hiring insights

Problem statement

Write a Python Program using SciPy that solves the equation X = A*B*C, given X, B, and C, as input. In the equation, X is a scalar, A is the unknown 1x2 vector, B is a 2x2 matrix, and C is a 2x1 vector. The two elements of A have the relationship A[1] = 1 - A[0]. Find the value of vector A.

Function

findA(X: float, B: float[][], C: float[][]) → float[]

Complete the function findA in the editor below.

findA has the following parameter(s):

  1. float X: the value of X.
  2. float B[2][2]: the matrix B.
  3. float C[2][1]: the vector C.

Returns

float[2]: an array containing the two values A[0] and A[1].

Examples

Example 1

X = 0.35B = [[3, -1], [-2, 3]]C = [[0.2], [0.8]]return = [0.75, 0.25]
After solving the equation X = A*B*C under the constraints A[1] = 1 - A[0], the value of the vector A = [[0.75, 0.25]]. The values of A should be rounded to two decimal places.

Constraints

  • B has exactly 2 rows and 2 columns.
  • C has exactly 2 rows and 1 column.
  • The two entries of B * C are different, so the equation has a unique solution under A[1] = 1 - A[0].
  • Round both returned values to two decimal places.

More Snowflake problems

drafts saved locally
public float[] findA(float X, float[][] B, float[][] C) {
 // Write your code here 
}
    
X0.35
B[[3, -1], [-2, 3]]
C[[0.2], [0.8]]
expected[0.75, 0.25]
checking account