How to make a mathematica code with vectors and magnitude

In summary, the conversation discusses creating a Mathematica code to add an arbitrary number of 3-dimensional vectors. The code should accept the length and three angles of each input vector and output the magnitude and angles of the resultant vector, as well as plot the resultant vector. The conversation also mentions using a variable and adding a number to the vector, but it is unclear how to incorporate the angles. The question also asks for the relationship between the vector's components and its magnitude and angles with the x, y, and z axes.
  • #1
Sneakatone
318
0

Homework Statement


Create a mathematica code to add arbitrary number of 3 dimensional vectors.
1. n: the number of vectors which must be added
2. For each input vector, the code should accept the following:
a. Length of the vector
b. Three angles which the vector makes with x, y, and z axes
Output: The result should be the magnitude and the angles which the resultant vector makes with the x, y, and z axes. Plot the resultant vector.


Homework Equations





The Attempt at a Solution


what you can do is set a variable into a vector like v={1,2,3} and v+(a number)
but I don't know what to do with the angles
 
Physics news on Phys.org
  • #2
How are the x, y, and z components of a vector related to the magnitude of the vector and the three angles which the vector makes with x, y, and z axes?
 

1. How do I define a vector in Mathematica?

To define a vector in Mathematica, you can use the "Vector" function. For example, if you want to define a vector v with components (2, 3, 5), you can write v = Vector[2, 3, 5]. This will create a vector with the name "v" that can be used in your code.

2. How do I calculate the magnitude of a vector in Mathematica?

To calculate the magnitude of a vector in Mathematica, you can use the "Norm" function. For example, if you have a vector v with components (2, 3, 5), you can write Norm[v] to calculate its magnitude. This will return the value of the magnitude, which in this case would be Sqrt[38].

3. How can I add or subtract vectors in Mathematica?

To add or subtract vectors in Mathematica, you can use the "+" and "-" operators. For example, if you have two vectors v and w with components (2, 3, 5) and (1, -2, 4) respectively, you can write v + w to add them or v - w to subtract them. This will return a new vector with the resulting components.

4. Can I multiply a vector by a scalar in Mathematica?

Yes, you can multiply a vector by a scalar in Mathematica using the "*" operator. For example, if you have a vector v with components (2, 3, 5) and want to multiply it by 3, you can write 3 * v to get a new vector with components (6, 9, 15).

5. Is there a function in Mathematica to calculate the dot product of two vectors?

Yes, the function "Dot" can be used to calculate the dot product of two vectors in Mathematica. For example, if you have two vectors v and w with components (2, 3, 5) and (1, -2, 4) respectively, you can write Dot[v, w] to calculate their dot product. This will return the value of the dot product, which in this case would be 17.

Similar threads

  • Introductory Physics Homework Help
Replies
25
Views
1K
  • Introductory Physics Homework Help
Replies
8
Views
1K
  • Introductory Physics Homework Help
Replies
2
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
6K
  • Introductory Physics Homework Help
Replies
1
Views
910
  • Introductory Physics Homework Help
Replies
6
Views
1K
  • Introductory Physics Homework Help
Replies
4
Views
1K
  • Introductory Physics Homework Help
Replies
5
Views
2K
  • Introductory Physics Homework Help
Replies
25
Views
3K
  • Introductory Physics Homework Help
2
Replies
38
Views
3K
Back
Top