Tag Info

New answers tagged

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, ...


3

The idea (as in my comment) is to replace a vector-valued dependent variable by coordinate functions K[i] for i = 1, 2, ...; then call DSolve; and finally reassemble the solution coordinates into a vector-valued solutions. ClearAll[reassembleSols, vectorize]; reassembleSols[sols_, fns_, var_, dim_] := Function[sol0, MapThread[ Function[{f, s}, ...


2

dVF = Table[{{x, y}, Normalize@{Cos@x, Tan@y}}, {x, 1, 3, 1}, {y, 1, 3, 1}]; f = Interpolation@Flatten[dVF, 1]; VectorPlot[f[x, y], {x, 1, 3}, {y, 1, 3}]


0

You can do this by projecting onto the two orthogonal vectors in the product space that have the second factor equal to the unchanged vector: res = KroneckerProduct[{{a}, {b}}, {{c}, {d}}] /. {a -> e, b -> f} (* ==> {{c e}, {d e}, {c f}, {d f}} *) p1 = KroneckerProduct[{{1}, {0}}, {{c}, {d}}/(c^2 + d^2)]; p2 = KroneckerProduct[{{0}, {1}}, {{c}, ...


1

Taking the code practically straight out of the author's demo:- m = {{1, -3.5}, {2, -2}}; pt1 = {-5.1, 4.8}; pt2 = {4.9, 5.1}; pt3 = {-4.9, -5}; pt4 = {4.9, -5.2}; Show[VectorPlot[m.{x, y}, {x, -10, 10}, {y, -10, 10}, StreamPoints -> {{pt1, pt2, pt3, pt4}}, StreamStyle -> {Red, Thick}, ImageSize -> {460, 310}], Graphics[ {Thick, Orange, ...


5

r[i_, dt_] := r[i, dt] = r[i - 1, dt] + v[i, dt]*dt; r[0, dt_] = {0, 0}; v[i_, dt_] := {1/100*(Min[#, 100 - #] &@Last@r[i - 1, dt]), 0.4}; ListPlot[Table[r[n, 2.5], {n, 1, 100}]] An even better implementation (similar to the answer of kguler to your previous question): f[Δt_] := NestWhileList[# + {1/100*(Min[Last@#, 100 - Last@#]), 0.4}*Δt ...


4

You can also use NestList: tbl[v_, delta_, n_, init_: {0, 0}] := NestList[# + v delta &, init, n] tbl[v, 1, 10] (* {{0, 0}, {0.01, 0.4}, {0.02, 0.8}, {0.03, 1.2}, {0.04, 1.6}, {0.05, 2.}, {0.06, 2.4}, {0.07, 2.8}, {0.08, 3.2}, {0.09, 3.6}, {0.1, 4.}} *)


3

With v = {0.01, 0.4}; you can define r[n_, dt_] := r[n, dt] = r[n - 1, dt] + v dt r[0, dt_] = {0, 0} Now Table[r[n, 1], {n, 1, 10}] {{0.01, 0.4}, {0.02, 0.8}, {0.03, 1.2}, {0.04, 1.6}, {0.05, 2.}, {0.06, 2.4}, {0.07, 2.8}, {0.08, 3.2}, {0.09, 3.6}, {0.1, 4.}} and Manipulate[ ListPlot[Table[r[n, deltat], {n, 1, 10}], PlotRange -> 20], ...


1

Another way is with Tuples. A = {1, 2, 3}; B = {a, b, c}; MinkowskiSum[lis__] := Total /@ Tuples[{lis}] MinkowskiSum[A, B] {a+1, b+1, c+1, a+2, b+2, c+2, a+3, b+3, c+3} A1 = {1, 2}; A2 = {a, b}; A3 = {x, y}; MinkowskiSum[A1, A2, A3] {a+x+1, a+y+1, b+x+1, b+y+1, a+x+2, a+y+2, b+x+2, b+y+2}


1

For example x = {{1, 0}, {0, 1}, {0, -1}}; y = {{0, 0}, {1, 1}, {1, -1}}; Union @@ Outer[Plus, x, y, 1] {{0, -1}, {0, 1}, {1, -2}, {1, 0}, {1, 2}, {2, -1}, {2, 1}} You can use CirclePlus (⊕) (entered as \[CirclePlus] or Escc+Esc) to define your Minkowski sum: CirclePlus[x__] := Flatten[Union @@ Outer[Plus, x, 1], Length@{x} - 2] x⊕y {{0, -1}, ...


0

I haven't found out why the method presented in the question doesn't produce the right formula. But if you want the formula to present an arbitrary vector that's in 3d cartesian coordinate system as a linear combination of vectors forming a basis, or in other words, want to transform the vector from 3d cartesian basis to an arbitrary one, you can do this: ...



Top 50 recent answers are included