Ask Your Question

How to write integrals symbolically in Sagemath similar to Mathematica

asked 2022-09-15 01:17:25 +0100

vtomole gravatar image

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 flag offensive close merge delete



This can be somehow related with

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

2 Answers

Sort by » oldest newest most voted

answered 2022-09-17 08:43:29 +0100

Emmanuel Charpentier gravatar image

updated 2022-09-19 13:45:48 +0100

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]
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...


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...

edit flag offensive delete link more

answered 2022-09-15 17:09:45 +0100

eric_g gravatar image

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)
edit flag offensive delete link 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)
vtomole gravatar imagevtomole ( 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)))

ortollj gravatar imageortollj ( 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/", line 1
∫ sin(x), (x, Integer(0), pi)
SyntaxError: invalid character '∫' (U+222B)
vtomole gravatar imagevtomole ( 2022-09-16 16:58:06 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2022-09-15 01:16:59 +0100

Seen: 192 times

Last updated: Sep 19 '22