Ask Your Question

tomcho's profile - activity

2024-05-28 13:33:40 +0200 received badge  Notable Question (source)
2022-04-27 13:53:21 +0200 received badge  Famous Question (source)
2022-04-27 13:53:21 +0200 received badge  Notable Question (source)
2022-01-25 19:13:47 +0200 received badge  Popular Question (source)
2021-07-22 20:24:02 +0200 received badge  Notable Question (source)
2021-07-03 10:28:39 +0200 received badge  Notable Question (source)
2021-04-29 20:49:43 +0200 received badge  Popular Question (source)
2021-01-05 20:28:30 +0200 received badge  Popular Question (source)
2020-07-06 19:22:40 +0200 asked a question How to define an integral to not be evaluated

I'm trying to write the following script:

var('alpha beta x')

num = x**(alpha-1) * (1-x)**(beta-1)
denom = integral(x**(alpha-1) * (1-x)**(beta-1), x)

gammadist = num / denom

diff(gammadist, x)

So it is mich easier if the integral on denom does not get evaluated. However, I cannot find a way to do that on Sage and Sage always tries to evaluate it (without success). Is there a way to tell Sage to keep it as an integral?

Thanks

2020-04-22 18:15:02 +0200 received badge  Scholar (source)
2020-04-22 03:50:21 +0200 asked a question Unicode art as the default printing

I installed Sagemath versio 9.0 using conda and and I'm trying to improve the display style. Right now the display style is something like:

sage: x^2
x^2

In a previous computer I used to get pretty printing by default in Sage. I can reproduce the behavior using unicode_art:

sage: unicode_art(z^2)
 2
z

But I'd like this to be the default behavior. I know this must be simple but I cannot find that on the docs (probably because I'm searching using the wrong terms or something).

2020-04-18 18:40:09 +0200 received badge  Popular Question (source)
2019-10-16 11:15:25 +0200 received badge  Popular Question (source)
2018-09-15 01:24:59 +0200 commented question Sagemath does not open anymore

@vdelecroix I don't think I can be much more specific. My OS is Arch Linux (which is already mentioned), I installed Sagemath via pacman and what I did to break it was to try to uninstall every package that was installed via pip2. (I did this last thing because when trying to install sagemath-jupyter, pacman failed with a bunch of conflicted packages that were installed via pip2.)

2018-09-14 18:54:56 +0200 asked a question Sagemath does not open anymore

I was trying to install sagemath-jupyter on my Arch Linux (which turned out to be a near impossible task) and deleted a bunch of packages from pip2. Now I can't even open sagemath, even after re-installing sagemath from Pacman:

Traceback (most recent call last):
  File "/usr/bin/sage-ipython", line 12, in <module>
    from sage.repl.interpreter import SageTerminalApp
  File "/usr/lib/python2.7/site-packages/sage/repl/interpreter.py", line 109, in <module>                                                                                   
    from sage.repl.prompts import SagePrompts, InterfacePrompts
  File "/usr/lib/python2.7/site-packages/sage/repl/prompts.py", line 16, in <module>
    from IPython.terminal.prompts import Prompts
  File "/usr/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
    from .core.application import Application
  File "/usr/lib/python2.7/site-packages/IPython/core/application.py", line 23, in <module>                                                                                 
    from traitlets.config.application import Application, catch_config_error
  File "/usr/lib/python2.7/site-packages/traitlets/__init__.py", line 1, in <module>
    from .traitlets import *
  File "/usr/lib/python2.7/site-packages/traitlets/traitlets.py", line 60, in <module>                                                                                      
    from .utils.importstring import import_item
  File "/usr/lib/python2.7/site-packages/traitlets/utils/importstring.py", line 8, in <module>                                                                              
    from ipython_genutils.py3compat import cast_bytes_py2
ImportError: No module named ipython_genutils.py3compat

Any ideas on how to overcome this? (And preferably also installing sagemath-jupyter?

I have installed ipython_genutils with pip2 already (version 0.1.0).

2018-09-14 18:25:50 +0200 received badge  Editor (source)
2018-09-14 17:53:52 +0200 asked a question Can't open sage notebook with Jupyter

Hello, I have Arch Linux and I'm trying to open a Sage notebook using sage -n jupyter. I am successful in opening the Jupyter interface but when I click to create a new notebook there's no sage option. Only Python 2, 3 and Julia.

I have installed sage-notebook and opened it from sage (by typing notebook() from within the prompt) but that's the old interface which is not what I want.

Is there something I'm missing? I found the docs surprising unhelpful (and apparently out of date, since it focus on the old sage-notebook, and not on Jupyter).

Cheers

EDIT

I have tried installing sagemath-jupyter but I get a conflict with some packages installed via pip (mostly IPython, which is installed only on Python3, which is weird). I don't want to uninstall everything I installed using pip3, although I am comfortable uninstalling everything I installed with pip2.

2018-03-14 02:55:01 +0200 asked a question Is it possible to get fortran code for an expression?

Hello, is it possible to get the fortran code for expressions in SageMath?

Here's what I mean:

sage: var('a b x y')
( a, b, x, y )
sage: eq = x^a + 3/2*y^b
sage: get_fortran(eq)
x**a + 3.0/2.0*y**b

Right now the best I can do as a workaround is:

sage: eq.__str__().replace('^', '**')
x**a + 3/2*y**b

but the numbers appear as integers, which makes the division be performed as integer division in Fortran, which forces me to manually change that. Is there a function I can use to get what I want?

Cheers

2017-09-13 07:45:51 +0200 received badge  Student (source)
2017-09-13 01:24:28 +0200 asked a question Python 3 print in Sage

This is a minor issue, but I've long migrated all my Python scripts to Py3, so I'm trying to write in Sage in the most Py3-compliant way possible, since we'll have Py3 support in a not-so-distant future according to the FAQs (frankly I'm a bit surprised that Py3 support haven't already happened, but, oh well).

Anyway, because of that I put from __future__ import print_function, division in the very first line of my init.sage.

If I type things interactively in the prompt, it works as it's supposed to:

sage: print('C_r' ,6)
C_r 6

However, if I run a script with load('my_script.sage') it prints things as if I was using Py2.

('C_r', 6)

Am I loading my scripts wrong? How can I get it to work for scripts too?

Cheers.

2017-09-12 14:20:23 +0200 asked a question Expanding summation with factorial

If I do this in sage

F=sum(k^2*factorial(n), v=k, a=1, b=n+1); F

it correctly expands to what I want:

⎛   3      2           ⎞   
⎝2⋅n  + 9⋅n  + 13⋅n + 6⎠⋅n!
───────────────────────────
             6

However, if the factorial is a function of the summed variable, it doesn't work anymore:

sage: F=sum(k^2*factorial(k), v=k, a=1, b=n+1); F
sum(k^2*factorial(k), k, 1, n + 1)
sage: F.expand_sum()
sum(k^2*factorial(k), k, 1, n + 1)

Is this the expected behavior? How can I get it to expand no matter what's inside the summation?

I'm using Sagemath 7.5, by the way.

Thank you.