A wealth of knowledge is on display in MaplePrimes as our contributors share their expertise and step up to answer others’ queries. This post picks out one such response and further elucidates the answers to the posted question. I hope these explanations appeal to those of our readers who might not be familiar with the techniques embedded in the original responses.

**The Question: How to sketch a line in space?**

vahid65 wanted to know how to sketch the line with equation (x-2)/3 = (y-1)/4 = (z-3)/3 in a three-dimensional space.

This question was answered using two different approaches that we will discuss.

The first approach, given by Preben Alsholm, suggested using these commands: solve, subs, and plots:-spacecurve.

Preben provided the following lines of code:

- {(x-2)/3 , (y-1)/4 , (z-3)/3} =~t;
- solve(%,{x,y,z});
- L:=subs(%,[x,y,z]);
- plots:-spacecurve(L,t=-5..5,thickness=3,color=red);

The first line sets the three expressions equal to *t* using the element wise operator =~. This distributes the operation of equality over the elements of the set of expressions, forming a set of equations.

Result-1: {(x-2)/3=t, (y-1)/4=t, (z-3)/3=t}

The second line invokes the **solve** command. The solve command, **solve(***equations, variables***)**, solves one or more equations or inequalities for their unknowns. So in this line, this command was used to solve each expression for its corresponding unknown.

Result-2: {(x= 2+3t, y=1+4t, z= 3+3t}

You may have noticed that the % symbol is used within the command. This symbol is referring to the equation label that was created *chronologically* last.

The third line uses the **subs** command. The subs command, **subs(***x=a,expr***)**, substitutes “a” for “x” in the expression *expr*. In this case, “a” is the reference to the equation label referenced by (%) and *expr* is the sequence of variables x,y,z. The square brackets around *expr* forms a list, and the replacement imposed by the subs command replaces each of the three names x, y, and z with their equivalents in the set of equations returned by the solve command.

Result-3: [2+3t,1+4t, 3+3t ]

Finally the last line uses the **plots:-spacecurve** function. This function, **spacecurve(***sc,r,opts***)**, graphs a parametrically defined curve in three-dimensional Cartesian space.

In this example the first parameter, *sc*, is replaced by L since L has the properties of a list. The parameter *r* is an equation containing the parameter name and the parameter range; here it is the equation t=-5..5. Last but not least, the *opts* parameter (which is optional) gives the user the opportunity to specify the optional properties of the graph, properties such as thickness and color of the space curve.

Result 4:

Another contributer, Carl Love, suggested that these commands could be combined using the **zip** function, **zip(** *f, u, v***)**, which is an unusual application of it. The zip command applies elementwise to corresponding members of the two lists *u* and *v*, the binary function *f*, creating a new list *r*, whose members are f(u_{k},v_{k}).

Carl provided the following code:

plots:-spacecurve( zip(solve, [(x-2)/3 , (y-1)/4 , (z-3)/3] =~ t, [x,y,z]), t= -5..5, thickness= 3, color= red, axes= normal);

In this case zip is applying solve to *u*, a list of equations, and *v*, a list of variables. The equations in *u* are those in Result-1. The zip function returns the solution of each equation for the indicated variable, that is, the new list r is the list in Result-3. This list is the first argument of plots:-spacecurve. Finally, the parameter range and opts are up to the user’s preferences.

A second approach was suggested by Kitonum. The difference between this approach and the first one is that here we are not using the solve command. Instead, we are treating the line as an intersection of two planes.

Kitonum's code is as follows:

- L := [(x-2)*(1/3), (y-1)*(1/4), (z-3)*(1/3)]:
- plots[intersectplot](L[1]-L[2], L[2]-L[3], x = -4 .. 4, y = -4 .. 4, z = -4 .. 4, linestyle = 1, thickness = 3, axes = normal, orientation = [60, 75], view = [-1 .. 3, -4 .. 2, -1 .. 4]);

The first statement initializes a list L that contains all the desired expressions in the given symmetric form of the line.

In the second statement Kionum used the **plots[intersectplot]** command. This command graphs, in three-dimensional Cartesian space, the intersection of a pair of surfaces. This example uses the calling sequence: **intersectplot(***expr1, expr2, x=a..b, y=c..d, z= e..f, options***)**.

What are expr1 and expr2 used in Kitonum’s solution? The pairwise differences of L[1] and L[2], and L[2] and L[3] are planes, the intersection of which is the desired line in space.

expr1 = L[1] – L[2] = (x-2)*(1/3)- (y-1)*(1/4)

expr2= L[2] - L[3] = (y-1)*(1/4)-(z-3)*(1/3)

The variables x,y, and z are the coordinate names and define the axes, whereas a, b, c, d, e, f define the ranges. In this case they were taken as -4 or 4.

In the options parameter Kitonum used linestyle, thickness, axes, orientation, and view. The help page “plot3d,option” details these and other options that apply.

*This blog was written by our intern Pia under the supervision of Dr. Robert Lopez. We both hope that you find this useful. If there is a particular question on MaplePrimes that you would like further explained, please let us know. *