Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is for my python programming course eerorth be in force. 1. Assume vectors x and y are stored as lists of floats. In the

image text in transcribedimage text in transcribed

image text in transcribed

this is for my python programming course

eerorth be in force. 1. Assume vectors x and y are stored as lists of floats. In the module file, define functions that compute def sum (x,y): the sum of two vectors def diff(x, y): the difference of two vectors (i.e. x -y) def scale (c, x): scalar multiplication def 1incomb (x1, x2, x3,..., cl, c2, c3,...): t turning he linear combination of vectors re- Here the function accepts variable length parameters. def dot (x, y): the dot product def proj(x,y): the projection of x onto y. def perp (x, y) : the perpendicular part of x to y (i.e. ,#x-Prolyx.) def refl (x, y): the reflection of x across the line/plane perpendicular to y. def angle(x,y, s): the angle between x and y. The optional parameter s allows the user to output the angle in radians 'r' or degrees 'd', or not specify which and get the default. Here you will need math.acos to compute arccos. You receive extra credit for implementing your own version of arccos. Make sure to include a docstring with each of the above, explaining the function's purpose and imple- mentation details. For example def sum (x,y): """Returns the sum of two vectors. x and y are lists of floats representing vectors of the same length. Uses list comprehension (as should you!)." return t xi + yi for (xi,yi) in zip(x, y) We see the docstring by calling >>help (sum). tto narh funetion Instructions: Solve using the Python programming language. Submit two files-a module and a script-with the names LastNameFirstName.Lab 3mod.py LastNameFirstName Lab3scr.py The module contains the function definitions of this lab, as described below. The script imports the module, and illustrates the functions with examples. Remember, you can always use import LastNameFirstName.Lab3mod as vec to shorten names, for example We see the docstring by calling >>>nelp (sum) . 2. In your script file, import the module containing the above function definitions. Illustrate each function, preferably in the above order, by meaningful examples. (Examples that use only two-dimensional vectors would be least meaningful.) You receive extra credit for illustrating your functions proj, perp, refl with two-dimensional (or three-dimensional!) plots

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions