math4610

Homework, Material, and Software Manual for Math 4610


Project maintained by tannerwheeler Hosted on GitHub Pages — Theme by mattgraham

Frobenius Matrix Norm

GO BACK TO SOFTWARE MANUAL

Routine Name: frobeniusMnorm

Author: Tanner Wheeler

Language: Python. This code can be run on a python 3 compiler. The file can be imported and then the method will run.

Description/Purpose: This method will compute the Frobenius Matrix Norm given a specific matrix. You will need to import math as shown in the implementation section.

Input: This method has only one input. This input x is a matrix of dimensions mxn.

Output: This method will return a double value representing the norm.

Usage/Example: First create a matrix a with dimensions mxn and specify values for it.

n = 3
m = 3

a = [[float(0)] * n for i in range(0,m)]

a[0][0] = float(1)
a[0][1] = float(8)
a[0][2] = float(2)
a[1][0] = float(4)
a[1][1] = float(4)
a[1][2] = float(1)
a[2][0] = float(5)
a[2][1] = float(6)
a[2][2] = float(2)

Now we have

a = [[1.0, 8.0, 2.0],
     [4.0, 4.0, 1.0],
     [5.0, 6.0, 2.0]]

Now let’s print the output of our function given the matrix a.

print(frobeniusMnorm(a))

This will print


9.9498743710662

to the console.

Implementation/Code: The following is the code for frobeniusMnorm(x)

import math

def frobeniusMnorm(x):
    numSum = 0.0
    
    for i in range(0, len(x)):
        for j in x[1]:
            numSum = numSum + (j**2)
            
    return math.sqrt(numSum)

Last Modified: December 2018