# Tag Info

24

As explained by Michael Pilat you cannot create your own compound operators with custom precedence. (You could conceivably write your own parser as Leonid has worked on, or attempt to coerce the Box form with CellEvaluationFunction.) You can however use an existing operator with the desired precedence. Looking at the table Colon appears to be a good ...

21

UpArrow[a_, n_Integer] := Nest[a^# &, 1, n] then UpArrow[4, 3] or 4 \[UpArrow] 3 To complete this method you may wish to add an input alias: AppendTo[CurrentValue[$FrontEndSession, InputAliases], "up" -> "\[UpArrow]"]; Now EscupEsc will enter \[UpArrow]. Change$FrontEndSession to $FrontEnd and run it only once to make the change ... 19 Maybe I miss the point here, but FullForm[x ↗ y] gives UpperRightArrow[x,y]. This is described in the documentation to UpperRightArrow and since this symbol is not protected and has not built-in meaning, you can just define it the way you like: UpperRightArrow[x_, y_] := FooBar[x, y] and this instantly gives you Update: As answer to Jacobs ... 17 The short answer is don't do it. Really, it's just not a good idea. You can use other symbols, such as \[CapitalIota] which looks almost exactly like I and is entered with EscIEsc. If you're really determined you could substitute symbols using$PreRead and MakeBoxes but again I don't recommend it. For example: MakeBoxes[I, _] := "\[ImaginaryJ]" ...

16

Some people make good use of the Notation package but I have never been very successful with it. A good reason to learn a little about MakeBoxes and TemplateBox. The following MakeBoxes definition will format your expression. MyHead /: MakeBoxes[MyHead[a_, b_], form : (StandardForm | TraditionalForm) : StandardForm] := InterpretationBox[#1, #2] & ...

15

Yes you can, with limitations. You have at least three different ways to make an assignment to a subscripted symbol a0 : make a rule for Subscript make a rule for a "symbolize" a0 using the Notation package/palette In each case below, when I write e.g. Subscript[a, 1] this can also be entered as a1 by typing a then Ctrl+_ then 1. When you write: ...

14

You can use Symbolize, from the Notation package following the tutorial as you did. Then, just take the precaution of writing the pattern with its head explicit, such as: Pattern[xr, _] The problem is that Mathematica can't interpret the short notation for patterns (xr_ for example) if it has a box structure before the "_"

14

I can't answer how the association is made for the built-in operators, but I can show how to add your own. If your symbol is already an operator you can do this simply as halirutan showed. This question may be a duplicate of How can one define an infix operator with an arbitrary unicode character? but since it admits a simpler interpretation I shall not ...

13

You can get the syntax highlighting that you desire by modifying your UnicodeCharacters.tr file, though I don't know how advisable this practice is. For example, adding: 0x20B0 \[PennyOp] ($penny$) Infix 155 None 5 5 I can use EscpennyEsc to enter: I am not aware of documentation of the format of this file but as ...

13

Currying I don't know if it is possible to make all functions work in the Currying form (h[x1][x2][..]) but it is at least possible to extend Hold behavior to all arguments which natively that pattern will not have. I will copy my favorite method which was posted here by Grisha Kirilin: SetAttributes[f, HoldAllComplete] f[a_, b_, c_] := Hold[a, b, c] ...

13

A general idea as to how this can be done in a consistent way is explained in the help documents under NonCommutativeMultiply. The thing is that you want to use your operators in an algebraic notation, and that's what that page discusses. If, on the other hand, you're happy with a more formal Mathematica notation, then you would have the easier task of ...

10

Something like this f = D[#, x] + D[#, y] + z # & seems to work. Use as follows: f[x ψ[x, y, z]] to give $x \psi ^{(0,1,0)}(x,y,z)+x \psi ^{(1,0,0)}(x,y,z)+x z \psi (x,y,z)+\psi (x,y,z)$

10

The Notation package is the most convenient way to define new notation(s). <<Notation Define an infix notation. You can use the palette that the 'Notation package pops up to do this. InfixNotation[ParsedBoxWrapper["\[UpperRightArrow]"], FooBar] Check that the infix notation maps to the correct FullForm expression. x \[UpperRightArrow] y // ...

8

I'm not going into the well-coded part of your question (as this is rather subjective), but a package that I've (cursorily) examined and which looks nice is this quantum notation package, which has lots of custom notation and corresponding palettes.

8

You may wish to use the Notation package. It lets you do these things fairly easily. I'd copy and paste some examples but they don't really copy and paste well. Read through the tutorials and you'll see some examples of how to do this. You may also be interested in the Vector Analysis package.

7

Perhaps: uu := u[x, y, z, t] uu[x_, y_, z_, t_] := u[x, y, z, t] So that D[uu, t] // InputForm (* - >Derivative[0, 0, 0, 1][u][x, y, z, t] *) and Dt[uu, t] // InputForm (* -> Derivative[0, 0, 0, 1][u][x, y, z, t] + Dt[z, t]*Derivative[0, 0, 1, 0][u][x, y, z, t] + Dt[y, t]*Derivative[0, 1, 0, 0][u][x, y, z, t] + Dt[x, ...

7

What I usually suggest for such cases is to use custom environments, inside which you can change the rules of the game. Here is a lexical one for your case: ClearAll[withNCTimes]; SetAttributes[withNCTimes, HoldAll]; withNCTimes[code_] := Unevaluated[code] /. Times -> NonCommutativeMultiply so that withNCTimes[a*b*c] (* a**b**c *) and here is ...

7

Unfortunately, this is not possible directly, at least as far as I know. The error message you are getting is just a manifestation of it. You are using UpValues, which have a fundamental limitation that they can only be attached to symbols on a level no deeper than 1. I discussed this more in my answer to this question. Redefining built-in functions, OTOH, ...

7

Instead of using the Notation package, you can achieve the translation by doing the following: MakeExpression[RowBox[{x_, "⟗", y_}], StandardForm] := MakeExpression[ RowBox[{"FlatJoin", "[", x, ",", y, "]"}], StandardForm ] This takes care of the input translation. Now it's possible to enter expressions like 1 ⟗ (3 + 4 ⟗ 2) and have ...

7

That's how I finally defined haskell operators: rapply[x_] := x rapply[x_, y__] := x[rapply[y]] InfixNotation[ParsedBoxWrapper["|"], rapply] lapply[x_] := x lapply[x__, y_] := lapply[x][y] InfixNotation[ParsedBoxWrapper["\[SmallCircle]"], lapply] InfixNotation[ParsedBoxWrapper["\[CenterDot]"], Composition] Now $\circ$, $\dot{}{}$ and | act exactly like ...

7

Why does this not show up in a ?Global* query? Because you set a definition to CirclePlus which is in the System context How can I set the Attributes for this operation to be Flat so it is associative? SetAttributes[CirclePlus, Flat] But now redefine your function so it can take any number of arguments CirclePlus[stuff___] := Print@{stuff} Do I need ...

7

You can use something like this dx /: MakeBoxes[dx[a_], fmt_] := RowBox[{FractionBox["\[PartialD]", "\[PartialD]x"], MakeBoxes[a, fmt], "=", MakeBoxes[#, fmt] &@D[a, x]}]; dx[Sin[x]] dx[Sin[x]] // TraditionalForm I prefer MakeBoxes but it also can be implemented with Format ClearAll[dx] Format[dx[a_]] := ...

7

Here's a more general variant a(↑...↑)b with any given number of up-arrows, as defined on MathWorld: (* Short-hand for single arrow. *) UpArrow[a_, b_] := UpArrow[1][a, b]; (* Trivial case of a(↑...↑)1. *) UpArrow[_][a_, 1] := a; (* Single arrow: exponentation. *) UpArrow[1][a_, b_] := a^b; (* Generic case: do a recursion. *) UpArrow[n_Integer][a_, ...

6

What you are really looking for is InputAutoReplacements. If I understand your question correctly you are looking for a simple/quick way to input mildly complex strings of characters. In your example you want to find an easy way to input $\beta$. But there is no point in creating another symbol beta, since the 2 symbols are meant to always be "equivalent" ...

6

Updated First, let's stop Dot from creating these box structures. MakeBoxes[Dot[x__], form_] := RowBox[{"Dot", "[", RowBox@Riffle[MakeBoxes /@ {x}, ","], "]"}] Next, let's specify that these structures should instead be interpreted as myDot: MakeExpression[RowBox@(row : {PatternSequence[_, "."] .., _}), form_] := MakeExpression[ RowBox@{"myDot", ...

5

So (I guess that) the problem occurs because Notation[LHS \[DoubleLongLeftRightArrow] RHS] converts the LHS into boxes, where OverBar[x] is OverscriptBox[x,"_"]. It then interprets the underscore as a Blank (_), which it tries to match up with a pattern on the RHS. I'm sure that I've used the Notation package with OverBars before and have not had troubles ...

5

You appear to be looking for the functionality of $PreRead:$PreRead = # /. "beta" -> "\[Beta]" &;

5

Besides the quantum package already mentioned by @Sjoerd, the package with the most customized notation that I know of is the THEOREMA package. You can freely use the package and admire the complex logicographics notation created, but the code is not available for inspection. Finally, the OP leaves me No-Escape (pun intended) but to mention my WildCats ...

5

After some further thought and exploration, it seems like this is a perfect use of the newish (version 6 and up) Defer wrapper. Adding the following rules to Pair seems to do exactly what I'm looking for: Pair /: Format[list : Pair[_, _]] := With[{args = Normal@list}, Defer[LinkedList[##]] & @@ args]; Pair /: Format[Pair[]] := Defer[Nil]; Then: ...

5

I see in your question that you would rather not use MakeBoxes but I think this might be worth a try. Pair /: MakeBoxes[linkedList : Pair[i_, p_Pair], fmt_] := TagBox[ToBoxes[LinkedList @@ Flatten[linkedList]], InterpretTemplate[Pair[i, p] &], Editable -> False, Selectable -> True, SelectWithContents -> True] The InterpretTemplate ...

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