New answers tagged

4

Not a one-liner, but straightforward. z1 = Table[Table[3*k*k, {k, i, i+3}], {i, 1, 256, 8}]; z2 = Table[{1,1,1,1}, {i, 1, 256, 8}]; result = Riffle[z1,z2] // Flatten


3

BlockMap[{#,ConstantArray[1,4]}&,f,4,8]//Flatten or BlockMap[{#[[;;4]], Unitize@#[[5;;]]}&,f,8]//Flatten {3, 12, 27, 48, 1, 1, 1, 1, 243, 300, 363, 432, 1, 1, 1, 1, 867, 972, 1083, 1200, 1, 1, 1, 1, 1875, 2028, 2187, 2352, 1, 1, 1, 1, 3267, 3468, 3675, 3888, 1, 1, 1, 1, 5043, 5292, 5547, 5808, 1, 1, 1, 1, 7203, 7500, 7803, 8112, 1, 1, 1, 1, 9747, ...


5

g[k_Integer] := 3 k^2 /; MemberQ[{1, 2, 3, 4}, Mod[k, 8, 1]]; g[k_Integer] := 1 /; MemberQ[{5, 6, 7, 8}, Mod[k, 8, 1]]; g /@ Range[256]


7

To answer your question directly, a loop could be written like this: f = Table[3*k*k, {k, 1, 16}]; Do[ f[[4 i + j]] = 1; , {i, {1, 3}}, {j, 1, 4} ]; f {3, 12, 27, 48, 1, 1, 1, 1, 243, 300, 363, 432, 1, 1, 1, 1} A non-loop alternative is this: f = Table[3*k*k, {k, 1, 16}]; pos = Flatten@Table[Range[4] + 4 n, {n, {1, 3}}]; f[[pos]] = 1; f {3, 12, ...


5

Join @@ MapAt[ConstantArray[1, 4] &, Partition[f, 4], {2 ;; ;; 2}] {3, 12, 27, 48, 1, 1, 1, 1, 243, 300, 363, 432, 1, 1, 1, 1}


1

You can also use the option NormalsFunction: ParametricPlot3D[{u, v, Exp[u] Cos[u - v]}, {u, 1, 3}, {v, 1, 5}, Boxed -> False, ViewPoint -> {0, 0, ∞}, Axes -> False, Mesh -> None, ColorFunction -> "TemperatureMap", NormalsFunction -> ({1, 1, 0} &)] Use ColorFunction -> (Blend[{White, Orange}, #3] &) (as in ...


2

You could use white ambient light and a custom ColorFunction based on a Blend of White and Darker@Orange. ParametricPlot3D[{u, v, Exp[u]*Cos[u - v]}, {u, 1, 3}, {v, 1, 5} , Boxed -> False , ViewPoint -> {0, 0, Infinity} , Axes -> False , ColorFunction -> Function[{x, y, z, u, v}, Blend[{White, Darker@Orange}, z]] , Mesh -> None , ...


2

You could follow this example from the documentation and use Glow: ParametricPlot3D[{u, v, Exp[u]*Cos[u - v]}, {u, 1, 3}, {v, 1, 5}, Boxed -> False, ViewPoint -> {0, 0, Infinity}, Axes -> False, ColorFunction -> Function[{x, y, z}, Glow[ColorData["TemperatureMap", z]]], Mesh -> None, Lighting -> None] Here is an example ...


1

To plot the volume try ParametricRegion as follows: First do linear interpolation of your expression f0 = {(1 - \[CurlyEpsilon])*x1 + \[CurlyEpsilon]*x2, (1 - \[CurlyEpsilon])*y1 + \[CurlyEpsilon]*y2, (1 - \[CurlyEpsilon])*x1*y1 + \[CurlyEpsilon]*x2*y2} /. \[CurlyEpsilon] -> 0 f1 = {(1 - \[CurlyEpsilon])*x1 + \[CurlyEpsilon]*x2, (1 - \[CurlyEpsilon])*y1 + ...


1

We can use NDSolve[] to solve this problem as follows: system[j_] := {A1'[x] == I*\[Kappa]1*Conjugate[A2[x]]*A3[x]*A4[x]* E^(-I*\[CapitalDelta]kl*x) + I*A1[x]*(\[Alpha]11*Abs[A1[x]]^2 + \[Alpha]12* Abs[A2[x]]^2 + \[Alpha]13*Abs[A3[x]]^2 + \[Alpha]14* Abs[A4[x]]^2), A2'[x] == I*\[Kappa]2*Conjugate[A1[x]]*A3[x]*A4[x]*...


1

After modifying ParametricNDSolve to ParametricNDSolveValue (without argument brackets ...[x]) DEsols = ParametricNDSolveValue[system, {A1 , A2 , A3 , A4 }, {x, 0, 2000}, {j}] you can access A4 Plot[sols[0][[4]][x], {x, 0, 2000}] Unfortunately your system seems to be solvable only for j==0


Top 50 recent answers are included