Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
1

How to write integrals symbolically in Sagemath similar to Mathematica

asked 2 years ago

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?

Preview: (hide)

Comments

1

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

tolga gravatar imagetolga ( 2 years ago )

2 Answers

Sort by » oldest newest most voted
2

answered 2 years ago

Emmanuel Charpentier gravatar image

updated 2 years ago

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 π0sin(x)dx : 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...

Preview: (hide)
link
1

answered 2 years ago

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)
Preview: (hide)
link

Comments

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
vtomole gravatar imagevtomole ( 2 years ago )

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

ortollj gravatar imageortollj ( 2 years ago )

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)
vtomole gravatar imagevtomole ( 2 years ago )

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

Stats

Asked: 2 years ago

Seen: 370 times

Last updated: Sep 19 '22