What is wrong with this matrix multiplication in python

In the below code (Jupiter notebook), output is given wrong, how to correct the code? import numpy as np A = [1,22,231,1540] B = [[-1,1,0],[1,-1,1],[0,6,0],[0,6,0]] C = [[113401201],[10649],[1]] result = np.dot(np.dot(A, B),C) print(result) output [-1800609408] The actual answer is I want to find the error and correct it >Solution : You’re probably running this code… Read More What is wrong with this matrix multiplication in python

Why am I getting an incorrect result from multiplying an inverted matrix by a vector?

I’m trying to learn Python for basic work in linear algebra. I’m running into the following problem with a simple system of linear equations: import scipy.linalg as la import numpy as np A = np.array([[186/450, 54/21, 30/60], [12/450, 6/21 , 3/60], [9/450, 6/21 , 15/60]]) l = np.array([18/450, 12/21, 30/36]) b = np.array([2, 0, 1/6])… Read More Why am I getting an incorrect result from multiplying an inverted matrix by a vector?

Matrix generation based on list's objects in R

I have a list of objects in R like follows: set.seed(1234) data <- matrix(rnorm(3*4,mean=0,sd=1), 3, 4) results <- lapply(1:ncol(data), function(i) outer(data[, i], data[, i])) which will result in the following matrices [[1]] [,1] [,2] [,3] [1,] 1.4570077 -0.33487534 -1.3089918 [2,] -0.3348753 0.07696698 0.3008557 [3,] -1.3089918 0.30085569 1.1760127 [[2]] [,1] [,2] [,3] [1,] 5.502298 -1.0065968 -1.1870541… Read More Matrix generation based on list's objects in R

Matrix calculation between list objects in R

I have created list of objects in R as follows: set.seed(1234) data <- matrix(rnorm(3*4,mean=0,sd=1), 3, 4) results <- lapply(1:ncol(data), function(i) outer(data[, i], data[, i])) all 4 list objects have dim=3×3. I also have the following matrix matr <- matrix(c(2,4,6,8),ncol=4), where each value corresponds to the above list objects. Then, I use this equation matr[,1]*matr[,2]*results[[1]]*results[[2]] between… Read More Matrix calculation between list objects in R

Python: Create a function that takes dimensions & scaling factor. Returns a two-dimensional array multiplication table scaled by the scaling factor

I am trying to create a function that does what the title is asking for. Without the use of any functions besides: range, len or append. The function would take the dimensional input of the 2D array, as well as the scaling factor, and then return a two-dimensional array multiplication table scaled by the scaling… Read More Python: Create a function that takes dimensions & scaling factor. Returns a two-dimensional array multiplication table scaled by the scaling factor