Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I only need help with the linear combination equation :) Question 1 def lincomb lastructions: Solve using the Python programming language. Submit two files-a module

I only need help with the linear combination equation :)
Question 1
def lincomb
image text in transcribed
lastructions: Solve using the Python programming language. Submit two files-a module and a script-with the names Last NameFirstName.Lab3mod.py Last NameFirstName.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. Send to rryham@fordham.edu by Sunday, February 24, 11:59 p.m. Please submit on time as the syllabus's no late work policy will henceforth 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 lincomb (xl, x2, x3,.... cl, c2, c3,...): the linear combination of vectors re- turning 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 x -Projyx.) 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) 2. In your seript 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. call s> inport vel.i

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

Students also viewed these Databases questions