Question: This also relates to Computer Science Problem 1: Vector Operations Now that you understand the basics, let's write your own program. We will start with

This also relates to Computer Science
 This also relates to Computer Science Problem 1: Vector Operations Now
that you understand the basics, let's write your own program. We will
start with a simple one that adds three vectors together, as you

Problem 1: Vector Operations Now that you understand the basics, let's write your own program. We will start with a simple one that adds three vectors together, as you might remember from the treasure hunt problem. To do this, we need to introduce arrays. An array is a variable type that is like a matrix of any dimension and size we wish. For our vector purposes, we will focus on 1x3 arrays, containing one row and three columns. Arrays can contain any variable type within them, so we could have an array of integers, floating points, strings, or even arrays Floating points will suffice for our needs. Arrays are not included in the base module of Python, so we need to include them by importing an additional module. Python is an open-source programming language, so anyone with the inclination can modify or write new Python code instructions and package them into modules. These modules can be called upon by a program, and as long as the computer has the necessary module installed, the program will access the additional functions correctly. The module that includes arrays and array operations is called NumPy. At the beginning of our program, we should include the following statement: import numpy Any time we want to define an array, we need to tell the program to look in numpy for the array code. So the statement to define a new array would look like this: MyArray numpy.array(1,2,3) The benefit of arrays is that we can add and subtract just as we would numbers, so given two arrays Array1 and Array2, the following operation is valid: Array3 Array1 + Array2 First, define nine floating point variables that will serve as the components for your arrays, naming these a1, b2, etc. Also define three 3x1 vector arrays using these variables (A [a1,a2,a3], for example). Then define a function VectorAdd similar to the Add function above that inputs three vectors and outputs the result as the return line

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!