# Tag Info

10

This appears to be a difference in parsing between the frontend and the kernel. Compare (in a notebook) HoldForm[\[LeftCeiling]x\[RightCeiling] + 1] (* Ceiling[x] + 1 *) with Get[StringToStream["HoldForm[\[LeftCeiling]x\[RightCeiling] + 1]"]] (* Ceiling[x] (+1) *) where the latter has multiplication instead of addition. One possible workaround is ...

10

You need to delay the evaluation of the right-hand side of ScalarCurvature: ScalarCurvature[fun_, xx_, yy_] := scalar /. Derivative[i_, j_][f][x, y] :> D[fun, {xx, i}, {yy, j}] Then it works, although there is a sign difference to your formula: ScalarCurvature[x^2 - y^2, x, y] -(8/(1 + 4 x^2 + 4 y^2)^2)

8

Using GaussianFilter on the raw RGB data will produce a convolution in all 3 dimensions of the list (rather than just the 2 spatial dimensions of the image). So filtering the raw data will also convolve RGB values at the same pixel. To see this effect, we can start with a uniform red image where all RGB values are {1,0,0}: test2 = Table[{1, 0, 0}, {m, 20}, ...

5

I've thought out 2 auxiliary functions. A possible improvement for the Derivative approach: d /: u_^d[a__][b__] := Derivative[a][u][b] Then $u^{(1,0)}(0,x)$ can be obtained by u^d[1, 0][0, x] But I'm not sure if typing Shift+6 is simpler than typing [+]… A possible improvement for the D approach: d2[u_, y__] := Module[{pos = Position[{y}, ...

4

This is very similar to the answer by Mr.Wizard, but avoids to introduce a named expression and therefore rewriting the function by using Condition: Replace[_, {_ /; IntegerQ[#] :> # (# - 1), _ :> #}] & /@ {1, 2, 3, x} {0, 2, 6, x} A more direct way is to use Switch: Switch[#, _Integer, # (# - 1), _, #] & /@ {1, 2, 3, x} ...

4

It is because Attributes have UpValues(*) associated with them so at the end you are not trying to Set to Attributes[Foo] but it will be translated. You can mimic that with e.g. UpSetDelayed (^:=): ClearAll[f] Set[f[x_], attr_] ^:= SetAttributes[x, attr]; SetAttributes[f, {Protected, HoldFirst}] f = 2 Set::wrsym: Symbol f is Protected. >> ...

4

This isn't an exact answer as for how to construct NCSort. However, it is the core of my approach for generating Wick contractions. I ripped out all the bells and whistles. It helps to have some background: I do lattice QCD, and so I mostly think about quark contractions. So, if you see "quark" you can parse that as "fermion". My code is designed to ...

4

If you do this often why not create a shortcut or template as you mentioned in the question? This has the advantage of formatting directly without having to use Evaluate in Place etc, or introducing a custom notation. Example: Derivative[Placeholder[], Placeholder[]][Placeholder[]] // PasteButton // CreatePalette Makes: If preferred a keyboard ...

3

Description The reason why your function doesn't execute as you'd expect is due to it expecting two arguments whilst you pass a single argument of type List containing two elements. Your function views it as hh[{3,4},y_]. Although, x parameter is passed successfully; y parameter is not available. Example: hh[3,4] Output: 7

3

If you want recursion, write recursively. dualF[Not[p_]] := Not[dualF[p]] dualF[And[p_, q_]] := Not[Or[Not[dualF[p]], Not[dualF[q]]]] dualF[Or[p_, q_]] := Not[And[Not[dualF[p]], Not[dualF[q]]]] dualF[p_Symbol] := p then dualF[p && (q || r)] ! (! p || (! q && ! r)) which has the truth table which is same as

3

It returns 0 because you are doing something like: D[ Sin[Globalx1], MyPPrivatex1] (*Global or current $Context really*) Why? You can read more in a related topic: Behavior of Remove inside a Package and in the general one I'm encouraging you to become familiar with: How symbol lookup actually works There are some tricks available to detect a ... 2 It seems to me that setenv is being used here to set the values of a series of helper variables that are then used by the other functions in the code. This (is awful but) works within a single notebook because all those variables are visible to all functions. I suspect, however, that once you put the code in a package, you run into context problems. Those ... 1 To see what it "does", use symbolic values as suggested by J.M. (tmatrix = Array[t, {2, 2}]) // MatrixForm (expr1 = Table[Sum[tmatrix[[i, j]], {i, 1, 2}], {j, 1, 2}]) // MatrixForm An alternate way to obtain this result expr1 === Plus @@@ Transpose[tmatrix] (* True *) 1 Too long for a comment. You can try this. res will contain a list of you 100 result. ClearAll[inexactSolve] ; SetAttributes[inexactSolve, HoldFirst] ; inexactSolve[expr_Solve] := ReleaseHold@ Replace[Hold[expr], a_?InexactNumberQ :> inert[ToString[a]], Infinity] /. inert[a_String] :> ToExpression[a]; res = Reap@Do[ With[{A = 0.625, h = 0.61}, ... 1 This works: hh @@ {3, 4} 7 This as well: myList = {3, 4} hh @@ myList 7 See: How to | Work with Lists Lists are at the core of the Wolfram Language. These "How tos" give step-by-step instructions for common tasks related to creating and manipulating lists. Applying Functions to Lists Many computations are conveniently specified in terms ... 1 This seems to meet your requirements, MyDensityPlot::argerr = "Number of undefined variables > 3"; Options[MyDensityPlot] := Options[DensityPlot]; MyDensityPlot[fn_, range_, options : OptionsPattern[]] := Module[{p1, externalSymbol, localx, localy, reg}, externalSymbol = With[{currentContextQ = Context@# ===$Context &}, ...

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