Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
48

The easiest way to get the Jacobian is D[a,{b}] To get the format of a matrix, you would do MatrixForm[D[f, {x}], or D[f, {x}]//MatrixForm, as the comment by azdahak says. There is no special matrix type in MMA - it's internally always stored as a list of lists. Edit Since this question is partly about the format of the matrix and its elements, I ...


41

Mathematica wouldn't be much helpful if one applied only formulae calculated by hand. Here we demonstrate how to calculate the desired geometric objects with the system having a definition of the curve r[t] : r[t_] := {t, t^2, t^3} now we call uT the unit tangent vector to r[t]. Since we'd like it only for real parameters we add an assumption to Simplify ...


20

See: Jacobian matrix The Jacobian matrix and determinant can be computed using the Mathematica commands: JacobianMatrix[f_List?VectorQ, x_List] := Outer[D, f, x] /; Equal@@(Dimensions/@{f,x}) JacobianDeterminant[f_List?VectorQ, x_List] := Det[JacobianMatrix[f, x]] /; Equal @@ (Dimensions /@ {f, x}) Some additional info. a = {x1^3 + 2 ...


19

The easiest thing to do is differentiate the field and use VectorPlot3D and ContourPlot3D to show orthogonality of these. This is from Documentation Center. I will change this a bit from original to polish graphics for your lecture. These are not unit vectors though - do u really need unit ones? It can be done too if you need. Use a contour plot to ...


19

The answer depends a lot on what you mean by "doing" vector calculus. You want results to be displayed without using component notation, and that's in general a difficult thing to achieve. A prerequisite about doing completely symbolic vector calculus is to define the simplification rules. But even in "non-vector" algebra it's often hard to get Simplify to ...


19

Assuming that we have three-dimensional real vectors : $Assumptions = (u | v | w) ∈ Vectors[3, Reals]; we can use e.g. various tensor functions (new in ver. 9) e.g. TensorReduce to reduce (simplify) a tensor expression, e.g. TensorReduce[ v.v + w.w - (v + w).(v + w) ] TensorReduce[u \[Cross] (v \[Cross] w) ] -2 v.w -w u.v + v u.w We can perform more ...


18

The definition used (motivated by exterior calculus) is as follows: Given a rectangular array $a$ of depth $n$, with dimensions $\{d, ..., d\}$ (so there are $n$ $d$'s) and a list $x = \{x_1, ..., x_d\}$ of variables, then Curl[a, x] == (-1)^n (n+1) HodgeDual[Grad[a, x], d] If $a$ has depth $n$, then Grad[a, x] has depth $n+1$, and therefore HodgeDual[...


16

Here is the Mathematica proof. I'll leave out the prefactor $\hbar/i$ for simplicity. Also, in case this is a homework problem, I decided not to add too many comments to the code. Instead I'll let you figure it out. The basic idea is to do cross products and gradients in spherical coordinates. The calculation shown here actually gives you a way to calculate ...


14

Thank you for your interest. I would strongly recommend against trying to modify SymbolicTensors`CoordinateChartDataDump`mappingInfo. It is a very low level function and any changes you make are unlikely to work. There are two sets of operations commonly needed with alternate coordinate systems. One is calculus in the coordinate system - Grad, Div, Curl ...


13

Any time you try to execute a command of the form a*b=c, you'll generate this error: Of course, that's exactly what you've done in your last line: ρ Dt[v, t] = -Gradient[p] + μ Laplacian[v] + f We can see the issue more clearly if we examine the left side of the equation in FullForm FullForm[a*b] (* Out: Times[a,b] *) Furthermore, Times is protected. ...


12

You can make use of option VectorScale - see the "More Information" section, and some singular examples at the end. Setting None will cause all the vectors to have the same length. Or you can improvise with a custom function to make the best view of the arrows (#5 the fifth argument is vector's norm): VectorPlot[{-(x/(x^2 + y^2)^(3/2)), -(y/(x^2 + y^2)^(3/2)...


12

Why don't you pick a random vector on the sphere to be your first vector, instead of $\mathbf{n}$, and then pick a random uniform number between $0$ and $2 \pi$ to orient the second vector aronud the first? Something like this, assuming you have your function randomVectorOnUnitSphere[] already (haven't tested it) generateRandomPositioning[v1_, v2_] := ...


12

Let's start with a parametrized surface. Any one will do, but I guess being orientable helps in this case. Then calculate the unit normal, and then create a Manipulate object that lets you see how the normal behaves: σ[u_, v_] := {(2 + Cos[v]) Cos[u], (2 + Cos[v]) Sin[u], Sin[v]} n[u_, v_] := Evaluate[Normalize[ Cross[D[σ[u, v], u], D[σ[u, v], v]] ]] ...


12

Observe that even when the tangent vector $r'(t)$ is not normalized, it is still a linear combination of $T(t)$ and $N(t)$. Thus--operating under the usual assumptions that $r'$ and $r''$ exist and are linearly independent--all we have to do is make an orthonormal frame out of $r'(t)$ and $r''(t)$ (which is very much in the spirit of the entire proceeding). ...


11

Mathematica 10 provides new functionality dealing with curves, (see e.g. the Vector Analysis tutorial) like ArcLength, ArcCurvature and especially FrenetSerretSystem: FrenetSerretSystem[{ x1, ..., xn}, t] gives the generalized curvatures and Frenet-Serret basis for the parametric curve x[t] i.e. it returns {{ k1, ..., k(n-1)}, { e1, ..., en}}, where ki ...


11

The main issue is simply that your constraint should not be imposed after the integration of the field lines, but beforehand. This means that we should choose the starting points from which the differential equations of the field lines are integrated to lie on the desired cylinder right from the beginning. Then, all you have to do is to impose the ...


10

It isn't too hard to roll your own routine, of course: UnitNormalVector[f_, {u_, u0_}, {v_, v0_}] := Block[{f0, g0}, f0 = f /. {u -> u0, v -> v0}; g0 = Transpose[D[f, {{u, v}}] /. {u -> u0, v -> v0}]; Arrow[{f0, f0 + Normalize[Cross @@ g0]}]] (* Möbius strip *) mobius[u_, v_] := {(3 + (1/...


10

Enjoy it! Graphics3D[{ {Lighter[Brown], Cone[{{0, 0, 0}, {0, 0, -1}}, .25]}, {Yellow, Sphere[{0, 0, .1}, .25]}, {Pink, Sphere[{.15, 0, .2}, .26]}, {Orange, Sphere[{-.1, 0, .25}, .25]} }, Boxed -> False]


10

Update since version 9 Grad is built in. Let us first define the vector field A = {10 x, 20 y^3, 30 z}; and load the vector analysis package: Now let's define $A\cdot \nabla A$ field = (A.Grad[#, {x, y, z}]) & /@ A (* ==> {100 x, 1200 y^5, 900 z} *) and plot both fields: pl1 = VectorPlot3D[A, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}, ...


10

Our package VEST (Vector Einstein Summation Tools) is designed to do exactly this. It's described here and can be downloaded from github along with a tutorial. I realize this question is now very old, but thought this answer might be helpful for others looking for similar capability.


10

I've previously found that Mathematica's arrangement of Grad's output doesn't always agree with fluid mechanics conventions: try transposing it. In general for three dimensions: u={ux[x,y,z],uy[x,y,z],uz[x,y,z]}; gradu=Transpose[Grad[u,{x,y,z}]]; (* note the Transpose *) uu=TensorProduct[u,u]; divu=Div[u,{x,y,z}]; FullSimplify[u.gradu - Div[uu,{x,y,z}], ...


10

Any approach to this will depend on efficiently deciding if two capsules overlap. You could do this using the built-in RegionDisjoint capsulesOverlapRegion[cap1 : CapsuleShape[{p1a_List, p1b_List}, d1_], cap2 : CapsuleShape[{p2a_List, p2b_List}, d2_]] := ! RegionDisjoint[ BoundaryDiscretizeRegion[cap1], BoundaryDiscretizeRegion[cap2] ] but ...


9

Disclaimer In the meantime, user929304 found out that my collision test is incorrect. I posted a new answer with a rather new approach. Strategy I use a Bag to store the lines between the two sphere centers of each existing capsule. When generating a new capsule I use RegionMember to check wether a new capsule fits into the box and RegionDistance of a ...


9

You could just do: Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], {ν, d}, {μ, d}, Assumptions->d>1] d Although it might make sense to use symbolic tensors instead, e.g., something like: Tr[IdentityMatrix[d] . IdentityMatrix[d]] although in this case you would need some extra code for simplification (as you can find in my TensorSimplify package). ...


9

The "Details" section of that page refers to CoordinateChartData. Now this is a bit dense, but it contains everything you need. First of all, you can try to find out what kind of things you can find out about spherical coordinates: In[9]:= CoordinateChartData["Spherical", "Properties"] Out[9]= {"AlternateCoordinateNames", "CoordinateRangeAssumptions", ...


9

Really this should have a concrete example in Mathematica copy-pastable format. Anyway, I'll show a few ways using a made-up example. We'll eventually get it down to straight linear algebra. To keep it simple I'll assume the matrix has distinct eigenvalues. This restriction can be lifted of course. Also as has been noted in comments, without loss of ...


8

Grad[a,b] also produces the Jacobian. a = {x1^3 + 2 x2^2, 3 x1^4 + 7 x2}; b = {x1, x2}; Grad[a, b] // MatrixForm This has the added advantage of letting you compute the Jacobian in different coordinate systems.


8

Here is how I'd do it. First, let's write a function that generates the plane stress PDE: << NDSolve`FEM` ClearAll[PlaneStress]; PlaneStress[{Y_, nu_}, {u_, v_}, X : {x_, y_}] := Module[{pStress}, pStress = -Y/(1 - nu^2)*{{{{1, 0}, {0, (1 - nu)/2}}, {{0, nu}, {(1 - nu)/2, 0}}}, {{{0, (1 - nu)/2}, {nu, 0}}, {{(1 - nu)/2, 0}, {0, 1}...


8

You can plot the surface and the vector fields separately and then combine them together. Here is an example. Consider the spherical radius r can be written as function $r(\theta,\phi)$: mysurface[θ_, ϕ_] = FullSimplify[Re[SphericalHarmonicY[3, 2, θ, ϕ]], Assumptions -> {θ ∈ Reals, ϕ ∈ Reals}] (* 1/4 Sqrt[105/(2 π)] Cos[θ] Cos[2 ϕ] Sin[θ]^2 *) ...


7

This is mainly an answer to your last question, but I think it will help with your other ones. I assume you know that the $T$ function is vector valued, and that is what you want. To substitute in a specific value of $t$, you probably want replacement rules, specifically the ReplaceAll (/.) construct. For example, if you had defined your expression $T(t)$ ...


Only top voted, non community-wiki answers of a minimum length are eligible