Ask Your Question

dantetante's profile - activity

2021-09-03 09:26:12 +0100 asked a question Why are there two different options for Sage in Jupyter's "New" menu?

Who offers the dropdown menu of Jupyter two different Sage options? When I open a Jupyter Session and klick on >>N

2021-07-02 00:01:13 +0100 received badge  Nice Question (source)
2021-07-01 08:12:48 +0100 asked a question why can't I compute the zeros of an integer polynomial using solve()?

why can't I compute the zeros of an integer polynomial using solve()? This works fine, producing complex roots: x=var('

2021-06-24 11:47:55 +0100 received badge  Popular Question (source)
2021-05-18 01:56:04 +0100 received badge  Notable Question (source)
2021-05-18 01:56:04 +0100 received badge  Popular Question (source)
2021-02-09 16:30:52 +0100 commented answer limit of fourier series

Yes, but it does not answer my question ;-) I want to compute the limit function f(x), restricted to x from 0 to 2*\pi

2021-02-06 10:02:56 +0100 received badge  Organizer (source)
2021-02-06 10:00:40 +0100 asked a question limit of fourier series

I'd like to compute the limit of $$\sum_{k=1}^{n}\frac{1}{k^2+1}\sin(kx)$$ I did the following already:

def b(k):
        return(1/(k**2+1))
def a(k,x):
        return(b(k)*sin(k*x))
def s(n,x):
        s=0 
        for k in range(1,n+1):
                s=s+a(k,x)
        return(s)
var('x,n')
f=s(1000,x)
plot(f,0,2*pi)

I already tried computing it by hand, looked in Bronstein, searched the internet, but didn't find any solution. But I'm no specialist in Analysis, so perhaps somebody can help? Clearly the series converges for every x in [0,2*pi] ...

2020-09-08 17:57:25 +0100 received badge  Supporter (source)
2020-09-03 19:30:14 +0100 answered a question Can sagetex generate tex files?

Since you didn't provide an example I'm not 100% sure what you want to do. Anyway you should have a look at jinja:

https://pypi.org/project/Jinja2/

2020-09-03 07:26:14 +0100 received badge  Editor (source)
2020-09-03 07:23:29 +0100 asked a question How to handle very large numbers

I want to play around with factorials. I found that factorial(10**9) takes about 20 minutes (on my machine, which is a Mac mini with 8GB Memory). Then I tried factorial(10**10) and there I got this:

/Applications/...pathtoSageMath/sage/src/bin/sage-python: line 2:   975 Killed: 9              sage - python "$@"

Then I searched for a SageMath Stirling Formula, which I didn't find (only some related stuff), so I tried it myself:

sage: def s(n):
....:     x=sqrt(2*pi*n)*((n/e)**n)
....:     return x.numerical_approx()
....: 
sage: s(5)
118.019167957590
sage: s(6)
710.078184642185
sage: s(10**10)

This gave me an error after some minutes:

RuntimeError
...
 4047                            relational_operator(self._gobj))
   4048         else:
-> 4049             x = g_pow(self._gobj, nexp._gobj)
   4050         return new_Expression_from_GEx(self._parent, x)
   4051 

RuntimeError: size of exponent exceeds signed long size

Then I tried s(10**9), there I got another error:

python3(755,0x10fbecdc0) malloc: can't allocate region
:*** mach_vm_map(size=18446744073151754240, flags: 100) failed (error code=3)
python3(755,0x10fbecdc0) malloc: *** set a breakpoint in malloc_error_break to debug
sig_error() without sig_on()
------------------------------------------------------------------------
(no backtrace available)
------------------------------------------------------------------------
Unhandled SIGABRT: An abort() occurred.
This probably occurred because a *compiled* module has a bug
in it and is not properly wrapped with sig_on(), sig_off().
Python will now terminate.

So what can I do? Is there a special library for very large reals or int or some special commands for getting an approximation of how many decimals a factorial will have? Could I use the log somehow or would this have the same runtime problems?

The reason why I'm asking is that I am rewriting a text which is 20 years old and there's a statement that factorial(10**100) could not be computed (ok, I believe that because of factorial being between O(2**n) and O(2**(2**n))) and factorial(10**8) would take many hours, which was not the case on my machine (see above).

And last but not least I would like to know if there is an upper bound for numbers that sage can handle. I thought not, but now I know otherwise ;-) Also hints to good literature on these topics would be appreciated.

2020-08-20 18:22:48 +0100 commented answer sagetex linebreak

I really need long number output, because I work with cryptography and number theory stuff and people want to copy and paste.

2020-08-20 18:20:59 +0100 answered a question sagetex linebreak

I found a solution myself (and already posted it on tex.stackexchange). Here it is:

\documentclass[ DIV=16, a6paper, 11pt]{scrartcl} 
% arara: lualatex
% arara: sagetex
% arara: lualatex
% !TEX TS-program = sage
% !TEX encoding = UTF-8 Unicode
\usepackage{seqsplit}
\usepackage{sagetex}
\lstset{
literate=
{1}{1\allowbreak}1
{2}{2\allowbreak}1
{3}{3\allowbreak}1
{4}{4\allowbreak}1
{5}{5\allowbreak}1
{6}{6\allowbreak}1
{7}{7\allowbreak}1
{8}{8\allowbreak}1
{9}{9\allowbreak}1
{0}{0\allowbreak}1,
breaklines=true}
\begin{document}
\begin{sagecommandline}
sage: factorial(50)
\end{sagecommandline}
\seqsplit{%
30414093201713378043612608166064768844377641568960512000000000000}
\end{document}
2020-08-16 14:11:31 +0100 asked a question sagetex linebreak

When using the environment sagecommandline of sagetex with long number output, how can I get automatic line breaks? I already tried to change sagetex.sty (putting breaklines=true at several places), but nothing changed. Here is my minimal example: (p.s. I asked the same question also on tex.stackexchange)

\documentclass[
a6paper, 11pt, oneside,
english,ngerman]{scrartcl} 

% !TEX TS-program = sage
% !TEX encoding = UTF-8 Unicode

\usepackage[headsep=0cm,footskip=1.5em,includeheadfoot=true,
top=0cm,bottom=0cm,left=.5cm,right=.5cm,]{geometry}
\usepackage{sagetex}

\lstdefinestyle{SageOutput}{style=DefaultSageOutput,breaklines=true}

\begin{document}
\begin{sagecommandline}
sage: factorial(100)+1
sage: factorial(50)+1
sage: factorial(10)
\end{sagecommandline}
\end{document}
2020-04-05 14:52:37 +0100 received badge  Student (source)
2020-04-05 14:07:20 +0100 asked a question How to find out the difference between M.determinant(), M.det() and det(M)?

I am quite new to sagemath, but an experienced mathematician ... so I tried computing determinants for a given Matrix M and found different solutions. I found that M.det() is short for M.determinant() after searching the index and going further from there. But I did not find something for the syntax det(M). Inspire of being not a programmer, I am interested in

a) where could I search to find the difference? b) what is the difference, if any?

Many thank! Doris