DEV Community

Cover image for Subtracting Vectors
AI_Dosage
AI_Dosage

Posted on

Subtracting Vectors

Key Concept:

  • Vector subtraction involves subtracting corresponding components of two vectors.

  • If x=[x1,x2] and y=[y1,y2], then:

x−y=[x1−y1, x2−y2]
Enter fullscreen mode Exit fullscreen mode
  • The result is a new vector representing the displacement from y to x

Example: Subtract Vectors x=[2,3] and y=[−4,−2]

1. Given vectors:

  • x=[2,3]
  • y=[−4,−2]

2. Subtraction formula:

x−y = [x1−y1, x2−y2]
Enter fullscreen mode Exit fullscreen mode

3. Component-wise subtraction:

x−y=[2−(−4),3−(−2)]
Enter fullscreen mode Exit fullscreen mode

4. Simplify:

x−y=[2+4,3+2]=[6,5]
Enter fullscreen mode Exit fullscreen mode

5. Result:

 x−y=[6,5]
Enter fullscreen mode Exit fullscreen mode

Observations:

Subtracting x effectively adds the opposite of y to x.
The result [6,5] represents the displacement vector between
x and y.

subtraction-example

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more