Sage is based on Interactive Python. Therefore, every feature in IPython works in SageMath. For example, one feature is automatic-parentheses-and-quotes.
So, if you are too lazy to write parenthesis and commas, then you can turn on the autocall magic and use it by starting the line by /
:
sage: %autocall 1
Automatic calling is: Smart
sage: f(x,y,z) = x + y^2 + z^3
sage: /f x+1 y+2 z+3 # no parenthesis, no comma!
(z + 3)^3 + (y + 2)^2 + x + 1
There is also the auto-quoting which can be used if you are too lazy to quote strings. It may be activated by starting the line with a comma:
sage: ,print aujourd'hui # no parenthesis, no comma, no quotes "" !
aujourd'hui
For more information and options, see the documentation of IPython on the link above or as follows:
$ sage -ipython
Python 3.11.1 (main, Sep 2 2023, 13:40:58) [GCC 9.4.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: ?
Please provide a complete code example, including the definition of
f
.Hi
But I'm probably missing something here, maybe you could give the function f in order to check with your function as Max Alekseyev asked you ?.
@ortollj@Max Alekseyev Writing
x^2+x^3-31//Sin
is equivalent toSin[x^2 + x^3 - 31]
in Mathematica. OP asks whether there is equivalent of this syntax//
in Sagemath.Let's wait clarification from OP. I read the question differently, and I do not understand why
f(x^2 + x^3 - 31)
is not considered quick enough. This may depend on howf
is defined, hence I asked for clarification.Sorry for the delay -- @Max Alekseyev@ortollj, I was indeed thinking along the lines of @azerbajdzan , e.g. with
f
as something likesin
or evenN
, so that I could quickly evaluate e.g.cos(23)
viacos(23) // N
. (But I guess in the latter case, the answer is to just usecos(23).n()
.)I've now forgotten what the context was (I didn't get any notifications for the comments added here), but I think it's based on using SageMath via an interactive shell. Sometimes I will have an expression defined as the input to one line, and then after executing it, I can access it via the up-arrow key. Rather than scroll across the line to wrap the expression in parentheses and
f
, it would be quicker to just type// f
, especially as the cursor is already at the end of the expression.