# What are some good ideas on how to Map a Replace function over a list of equations?

I've been working on a rather simple implimination of parameterizing a 3D line in space, and now am trying to find a way to map different values of t over those equations. The only approaches I've tried so far have a lot of negative side effects and complications. Advice is appreciated because I need to find the points on a lot of lines by segmentation. :) Thanks.

 {u,i} = {{2099,1313,4599},{-21208,-1146,4697}}

f[x] = (i[[1]]-u[[1]]) t + u[[1]];
f[y] = (i[[2]]-u[[2]]) t + u[[2]];
f[z] = (i[[3]]-u[[3]]) t + u[[3]];

{f[x],f[y],f[z]} /. t->.5
{-9554.5,83.5,4648.}

• The expressions f[x]=, f[y]=, and f[z]= are syntactically correct but are not customary. In any case, can you give some examples of the negative side effects you want to avoid? Commented Jul 28, 2018 at 20:37
• Well briefly... one side effect is that I don't know exactly how to do that? (As you could probably already tell from my non-customary expression.) Perhaps someone will enlighten me as to the standard way to express these terms in their answer? Commented Jul 28, 2018 at 21:35
• As you do not use x as a argument of the function, but f[x] is just a name you could jist write fx=, fy=, fz=.
– Johu
Commented Jul 28, 2018 at 21:45

I set values of t to be from 1,2,...10 using Range

{u, i} = {{2099, 1313, 4599}, {-21208, -1146, 4697}};

f[x] = (i[[1]] - u[[1]]) t + u[[1]];
f[y] = (i[[2]] - u[[2]]) t + u[[2]];
f[z] = (i[[3]] - u[[3]]) t + u[[3]];

{fNumericX, fNumericY, fNumericZ} = {f[x], f[y], f[z]} /. t -> Range[1, 10]


Your expression works if t should be a vector. The values of each coordinate are saved as vectors in fNumericX, fNumericY, and fNumericZ

In more complex cases it might not work and and you might want to look up how Map and Table could be used for the same purpose.

Somewhat more elegant code for solving the same task using Map

{fNumericX, fNumericY, fNumericZ} =
Transpose@Map[(t \[Function] (i - u) t + u), Range[1, 10]]