How to improve this custom notation?

I implemented this custom notation...

In[57]:= Notation[ParsedBoxWrapper[
RowBox[{"x_", "↓", "y_"}]] ⟺
ParsedBoxWrapper[
RowBox[{" ",
RowBox[{"FunctionExpand", "[",
RowBox[{"FactorialPower", "[",
RowBox[{"x_", ",", "y_"}], "]"}], "]"}]}]]]


and works as expected:

In[71]:= x↓2

Out[71]= (-1 + x) x


What I really want is that when I enter x ^ ( 2 ) that this is interpreted as FactorialPower[x,2] meaning that the outer ( and ) make it a FactorialPower instead of a normal power.

Which changes should I implement to achieve this?

• Not sure if it is what you are asking, but ctrl-6 on my mac gives a shortcut to raise something to a power. I have to use the arrow keys to move from that to the "normal" line of the equation. The "6" is the up carrot so if you are using a PC, there is probably an equivalent using the key with the up carrot. – Mark R Feb 7 '20 at 23:02
• I have windows, I can do that too with ctr-6. If I create 5^(2) I get 25 instead of 20. – nilo de roock Feb 8 '20 at 8:08
• @niloderoock I don’t understand what you’re looking for. It isn’t clear what you’re trying to shortcut to what. Can you provide a little more context, maybe what the definition of this shortcut should be? – CA Trevillian Feb 9 '20 at 4:21
• Falling should give 5*4*3=60 rising should give 5*6*7=210 – CA Trevillian Feb 9 '20 at 4:30
• Mma has the function FactorialPower which handles this. I am mainly concerned about the formatting / notation. - I am now investigating the Notation Package but that is not an easy package. – nilo de roock Feb 9 '20 at 8:19

2 Answers

Another non-Notation option is to use InputAliases:

CurrentValue[EvaluationNotebook[], {InputAliases, "fp"}] = TemplateBox[
{"\[SelectionPlaceholder]", "\[Placeholder]"},
"FactorialPower",
SyntaxForm->SuperscriptBox
]


Then, typing Esc f p Esc will generate the desired input.

• So Notation is not necessary after all. – nilo de roock Feb 11 '20 at 13:25
• At the end of the day I want to be able to switch between normal exponents, falling exponents and rising exponents. To start with, I would like ( in "a falling exponents mode" ), x^2-x to display as x^(2). - Could this be the reason why initially Notation was suggested? I hoped the Notation[ _ <=> _] would be able to do this. – nilo de roock Feb 11 '20 at 13:42

This code interprets the superscript (achieved with ctrl+6) as FactorialPower:

MakeExpression[SuperscriptBox[x_, RowBox[{"(", y_, ")"}]], StandardForm] :=
MakeExpression[RowBox[{FactorialPower, "[", x, ",", y, "]"}], StandardForm]


Then an input of

$$a^{(b+c)}$$

leads to

FactorialPower[a,b+c]

• How can I add FunctionExpand after FactorialPower ? I want (x+5)^(3) to evaluate to (x+5)(x+4)(x+3) ; FactorialPower as a name should never appear. – nilo de roock Feb 11 '20 at 13:25
• You can add a layer of RowBox[{FunctionExpand,"["...,"]"}] around the FactorialPower inside MakeExpression. – QuantumDot Feb 11 '20 at 16:24
• I found it very hard to choose which answer to accept, sorry. – nilo de roock Feb 24 '20 at 8:08