I need to define an equation stating that the sum of n operations involving n 2D vectors and n scalars yields zero, where n is an arbitrary integer greater than 1.

For example, think of it as Sum[(v_i + t)*(Norm[v_i+t]-L_i), {i, 1, n}] == 0 where v_i are the n 2D vectors, t is the unknown (which is also a 2D vector), and L_i are the n scalars.

How should I define the v_i vectors and the L_i scalars so that I can best index them from the sum operator? Note that the Norm[] operator is used, so Mathematica needs to know vectors are 2D, and that scalars are scalars (i.e. I just cannot define the equation like if all variables were scalars and understand them as vectors in an abstract way).


1 Answer 1


Your unknowns

t = {tx, ty}

Assuming you have already defined your v and L on your own, here I provide some random values for them

Option 1

ClearAll[v, L]
Do[v[i] = RandomReal[1, 2], {i, 7}]
Do[L[i] = RandomReal[1], {i, 7}]

your equation

Sum[(v[i] + t)*(Norm[v[i] + t] - L[i]), {i, 1, 7}] == 0

Mathematica graphics

Option 2

ClearAll[v, L]
v = RandomReal[1, {7, 2}]
L = v = RandomReal[1, {7, 2}]
Sum[(v[[i]] + t)*(Norm[v[[i]] + t] - L[[i]]), {i, 1, 7}] == 0

Notice the difference in the definitions for v and L use of down values or own values in the two options. See here.

Is that what you need?

  • $\begingroup$ Yes, that's it! Thanks a lot! $\endgroup$
    – cesss
    Nov 11, 2015 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.