Tag Info

Hot answers tagged

13

As djp explains parentheses are unnecessary in the FullForm of an expression; it is logical for superfluous information to be removed. However if you want parentheses to persist you could use something like this: $PreRead = # /. RowBox[{"(", body___, ")"}] :> RowBox[{"paren", "[", body, "]"}] &; MakeBoxes[paren[body___], form_] := ...


11

So recently I've learned from John Fultz that RawBoxes are kind of verbatim indicator for MakeBoxes which is not well stressed out in documentation. This or I've missed the point but it doesn't matter, here we have handy way to do this: x = 5; ToExpression @ MakeBoxes[RawBoxes["x"] = 123]; x 123


8

You can make them an expression if you want. Let par[x.....] represent (x....). For example: (x+y)*z The FullForm would be: Times[par[Plus[x,y]], z] But in every such expression, the par[..] would only ever have on argument (in the example, Plus[x,y]). It would never modify the meaning of the argument. So in FullForm, there would be no point having ...


5

This answer is in the same spirit as Kuba's answer, but it avoids conversion between boxes and expressions. Here is our workhorse mark::usage = "Use in combination with markedExpression"; markedExpressify::usage = "Use mark to mark strings for conversion to expressions"; markedExpressify[expr_] := Module[{pos, hCExpr, ext, thr, rLH, expresser}, ...


4

Version 9.0.1.0 (Windows 8 64-bit) In version 9.0.1.0 (Windows 8 64-bit), both PropertyValue and SetProperty work as expected: x = Graph[{1, 2, 3, 4}, {1 <-> 2, 3 <-> 2, 3 <-> 4, 1 <-> 4}, EdgeWeight -> {1, 10, 30, 60}, VertexLabels -> "Name", EdgeLabels -> "EdgeWeight", ImagePadding -> 20] PropertyValue ...


4

Preamble There are some important differences (or, more precisely, features of Function which can't be reproduced with symbols and rules), that have not been reflected in answers here, but that I think deserve a separate answer. These are related to some more advanced uses, involving evaluation control, closures, and garbage collection. Emulating Hold ...


3

E.g.: SparseArray[Band[{1, 1}] -> Infinity, {3, 3}, 2] // Normal Creates a 3×3 with 2 everywhere but the diagonal of infinity. Drop the // Normal if you want to keep it sparse...


2

Is it not just this? g[r_,θ_,ϕ_] := Sum[Sum[f[l, m] r^l SphericalHarmonicY[l, m, θ, ϕ], {m, -l, l}], {l, 0, ∞}]


2

Perhaps you want PolynomialGCD instead of GCD: PolynomialGCD @@ Denominator@*Together /@ Flatten[mL] (* 32 h *)


2

lp = 10; uu = Table[Subscript[u, i], {i, 1, lp + 1}] You can use MapAt to add 4 to Part 2 of all elements in uu MapAt[4 + # &, uu, {{All, 2}}] Or use ReplaceAll to replace the second part of Subscript[a, i] to Subscript[a, i + 4]: uu /. Subscript[a_, i_] :> Subscript[a, i + 4] Alternatively, you can assign new values to ...


2

Mathematica does not like your h[i]s. If you introduce shrt[head_, indices_] := ToExpression[StringJoin[ ToString /@ Flatten[ {head, indices}]]] so that e.g. shrt[h,1] becomes h1 or shrt[h,{i,j}] hij Then this works: S = 10^-9.2; cl = 3*10^8 ; f = 5.9*10^9; w = cl/f ; A = (4*π/w)^(2/1); β = 2.5 ; m ...


2

ClearAll[Cto, kd1, ke2, kf3, FA, FB, FC, FD, FE, FF, Fto, V] Cto = 3.5; kd1 = 0.25; ke2 = 0.1; kf3 = 5.0; Note: = (not ==) in the line above. s = NDSolve[{FA'[V] == -kd1*Cto^3*(FA[V]/Fto[V])*(FB[V]/Fto[V])^2 - 3 ke2*Cto^2*(FA[V]/Fto[V])*(FD[V]/Fto[V]), FB'[V] == -2 kd1*Cto^3*(FA[V]/Fto[V])*(FB[V]/Fto[V])^2 - ...


1

First we define your system of equations: eqns = {D[u1[x,t],x] == u2[x,t], D[u2[x,t],x] == D[u1[x,t],t]}; Then we solve your substitution for u1 and u2: sub = Solve[{w11[x, t] == u1[x, t], w12[x, t] == u1[x, t]/u2[x, t]}, {u1[x, t], u2[x, t]}] (* {{u1[x, t] -> w11[x, t], u2[x, t] -> w11[x, t]/w12[x, t]}} *) Then we transform the ...



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