# Tag Info

## New answers tagged vector

0

You guessed right that one problem in your code is the missing definition of V. In the snippet you posted above, you defined a function V[X_, Y_, Z_, Len_, Br_, Dep_]. Later, you try to call it by writing D[V, x]. This does not work, because Mathematica distinguishes between V and V[X_, Y_, Z_, Len_, Br_, Dep_]. You can see this by looking into the down ...

1

Assuming $G=\rho=1$, move the gradient operator into the integral:  \begin{align} - \mathbf{g} = \nabla V(X,Y,Z) &= \nabla \int_{-D}^{D} \int_{-B}^{B} \int_{-L}^{L} \frac{{dx}'{dy}'{dz}'}{\sqrt{(X-{x}')^2+(Y-{y}')^2+(Z-{z}')^2)}} \\ &= \int_{-D}^{D} \int_{-B}^{B} \int_{-L}^{L} \nabla ...

1

Just another way to index (not as concise as kguler) but may be useful to note is MapIndexed: Sqrt[Total @ MapIndexed[(#2[[1]] - 1 - μ)^2 #1 &, y]] yielding 0.793748 #2 is the index starting at {1}, hence need for #2[[1]] lists/arrays start at 1, so reindexing -> #2[[1]]-1 as per kguler

1

If what you wish to calculate is $\sqrt{\sum _{i=0}^3 (i-\mu )^2 y_i}$, this can be done: Sqrt@Total[(Range[0, 3] - μ)^2 y] which gives 0.793748. The function Range[0,3] gives the numbers {0,1,2,3}, each of which is subtracted from mu and squared. These are then multiplied by the corresponding element of y and the collection is summed using Total.

2

First, you can get the desired result using much simpler form Sqrt[Sum[(i - 1 - μ)^2 y[[i]], {i, 1, 4}]] (* 0.793748 *) Notes on your code: In Mathematica indices start at 1, not 0. Furthermore, you need to use y[[i]] to refer to ith Part of a list y, not y[i]. With these changes Sqrt[\!$$\*SubsuperscriptBox[\(∑$$, $$i = 1$$, $$4$$]\( ...

1

As others have pointed out, using MatrixForm when assigning values will result in something that's no longer treated as a matrix for many functions. You can see the difference directly with the following example. a = IdentityMatrix[2]; b = MatrixForm[a]; FullForm[a] (* List[List[1, 0], List[0, 1]] *) FullForm[b] (* MatrixForm[List[List[1, 0], List[0, 1]]] ...

1

Here is working code: s = DirectedGraph[RandomGraph[{10, 15}], "Acyclic"]; M = AdjacencyMatrix[s]; id = VertexInDegree[s]; od = VertexOutDegree[s]; wd = Log[1 - od/(25 + id)]; x = M.wd; Total@x What makes this work: Do not use MatrixForm in calculations, only for final display, since it wraps the expression and leads to a different internal ...

2

It's not exactly what was asked for but it's another way to display the sought-after deformation. I thought I would share it because it's probably not well known how it can be done, and it seems appropriate to the problem at hand. First the OP's code computed this displacement: displacement (* (0.0001 (-125 x + 10 x^3 - x^4))/(5 + x)^3 *) Here is an ...

4

Eb = 2 10^7; b = 1/4; t0 = 1/2; L = 5; t[x_] := (t0 (L + x))/L; s = DSolve[{Eb (b t[x]^3)/12 y''''[x] == -1, y''[0] == 0, y''[L] == 0, y[0] == 0, y[L] == 0}, y, x][[1]]; displacement = y[x] /. s[[1]]; u = {-x2 D[displacement, x], displacement}; VectorPlot[u, {x, 0, L}, {x2, -4, 4}]

1

You need to define c and to use the correct syntax in the definition of T2: T2[s_, y_] := r[s] + 2*(c[s]*Sin[y] - j[s]*Cos[y]) c[s_] := s; (* for example *) ParametricPlot3D[Evaluate@T2[s, y], {s, 0, 2*Pi}, {y, 0, 2*Pi}] Update: For the updated version of the question: ClearAll[r, s, j, v, T2, y] r[s_] := {-(5 + 2*Cos[2*s])*Sin[3*s], (5 + ...

1

All the functions in Mathematica begins with a capital letter, you should modify cos to Cos, sin to Sin; and the function for cross product is Cross.When you multiply two variables, either put a * or a space between them, or they will be considered as another variable. [] are only used for functions,e.g.Sin[x], please change your []s to ()s when indicating ...

1

If you know that x will always have 6 items then you can restrict f by f[a_List /; a \[Element] Vectors[6, Reals]] := a.x This will not evaluate the function when a has the wrong dimensions. Hope this helps.

0

f[a__] := {a}.x x = Range[6]; f[a1, a2, a3, a4, a5, a6] (* a1 + 2 a2 + 3 a3 + 4 a4 + 5 a5 + 6 a6 *) Or g = {##}.x &; g[a1, a2, a3, a4, a5, a6] (* a1 + 2 a2 + 3 a3 + 4 a4 + 5 a5 + 6 a6 *)

2

f[a_List] := a.{3, 4, 5, 6, 7, 12}; f[{1, 2, 3, 4, 5, 6}] (* 157 *) Incidentally, do not use upper-case variables, as it is likely to conflict with internal functions (such as N). I presume you know the number of components of a (i.e., you're not asking about inputting a vector of arbitrary length), since you apparently have a fixed x (of known length). ...

2

Isn't this is a problem of mathematics more than programming? Under the stated conditions, by permutation symmetry of the indexes of $v$ all entries of $v$ should be the same (up to absolute value, because in the problem statement all elements are squared). Thus one answer is $v$ is an array of $c$ entries each of which is $n/c$. This solution is ...

1

You're like 99% of the way there. You just need to tell Mathematica that z is a vector by feeding it the components: With[{z = Array[v, 3]}, Minimize[{Total[z^4]/Total[z^2]^2, Total[z] == n}, z]] For dimensions 1 and 2 the answers are as expected. For 3 (the code above) Minimize outputs a bunch of ugly Roots. So although there is a symbolic solution, ...

Top 50 recent answers are included