Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: LS 30B-2 S19
Views: 127

Vector

What is a vector?

  1. A geometric object that has magnitude (or length) and direction

  2. Collection of variables!!


Vector only cares about the "difference" between the starting point and the end point

Why we need it here?

=> We can use vector to describe current variables!!!

How to create vector in Sage

'how we define vectors' v1= vector([1,2]) v2 = vector([3,-3]) v1 v2 'math operation on vectors' v1+v2 3*v1 v2/3 'retrieve each variable' v1[0] v2[1]
'how we define vectors' (1, 2) (3, -3) 'math operation on vectors' (4, -1) (3, 6) (1, -1) 'retrieve each variable' 1 -3

How to plot them?

fig1 = plot(v1) fig2 = plot(v2) fig3 = plot(v1+v2,color='red') #please ignore the following lines fig4 = arrow(v1,v1+v2,color='green') # just for showing parallel v2 fig1+fig2+fig3+fig4

We can also plot in 3D

v3d = vector([1,3,4]) plot(v3d)
3D rendering not yet implemented

Linear Function





Answer: (a)

Hint for today's lab

In today's lab, it requires you to write a function for determining whether a function is linear

Hint: Compare two symbolic equations

def testFun(x): return vector([x[0]*0.25+x[1]*1.3,x[0]*1.2+x[1]*0.3]) x1 = vector([1,3]) y1 = testFun(x1) x2 = vector([3,2.5]) y2 = testFun(x2) x3 = vector([4,5.5]) y3 = testFun(x3)
plot(x1,color='red')+plot(y1,color='red',linestyle='--')+plot(x2,color='blue')+plot(y2,color='blue',linestyle='--')+plot(x3,color='green')+plot(y3,color='green',linestyle='--')
pp