# How to write integrals symbolically in Sagemath similar to Mathematica

In Mathematica you can input an integral symbolically by entering esc int esc (Their documentation says (∫ can be entered as esc int esc).

Does Sagemath have this functionality?

edit retag close merge delete

1

This can be somehow related with https://ask.sagemath.org/question/541...

( 2022-09-17 13:46:36 +0100 )edit

Sort by » oldest newest most voted

∫ is Unicode's U+222B. Depending on your platform, this can be input in various ways. For example :

• On most Linux's terminals, Ctrl-Shift-U + 222B, then <space> will input ∫.

• Emac's input method "TeX" allows you to type "\int" to get ∫.

But this character isn't accepted by Python as an identifier ; you can't use it as a synonym to integrate :

sage: ∫=integrate
Input In [4]
∫=integrate
^
SyntaxError: invalid character '∫' (U+222B)


Furthermore, this example illustrates that displaying ∫(sin(x), (x, 0,π)) isn't really an acceptable substutite to $\displaystyle{\int_0^\pi\sin(x) \operatorname{d}\!x}$ : the substitute is hard to read and ugly as hell...

What you seem to aim at is an input mechanism accepting your keystrokes/mousestrokes , using them to build a structure representing some mathematical expression and displaying a "nice" visual representation of it. That's what Matehmatica interface does.

Such an input interpreter is probably somewhat lateral to Sage's goals... I have found that Sage's ability to latex any Sage object is enough (and easy enough to use) to check and understand anything I have had to use...

HTH,

EDIT : as noted by @tolga, this answer to a previous question is relevant : it suggests to use Sage through TeXmacs, thus benefitting of TeXmacs interface. Which I don't know...

more

Does using the keyword hold=True in integrate cover your need?

sage: integrate(sin(x), (x, 0, pi), hold=True)
integrate(sin(x), x, 0, pi)

more

That keyword doesn't create the ∫ symbol as input. I'm thinking of something more along the lines of:

 sage: ∫ sin(x), (x, 0, pi)
2

( 2022-09-15 17:35:38 +0100 )edit

like that ?:on sageCell you can get latex:print(latex(integrate(sin(x), (x, 0, pi), hold=True)))

( 2022-09-16 15:36:51 +0100 )edit

No, like this: ∫ sin(x), (x, 0, pi)

This is what i get when I input the above into Sage Cell:

  File "/tmp/ipykernel_1220566/835758590.py", line 1
∫ sin(x), (x, Integer(0), pi)
^
SyntaxError: invalid character '∫' (U+222B)

( 2022-09-16 16:58:06 +0100 )edit