Ask Your Question

Pedro's profile - activity

2022-08-29 08:38:42 +0200 received badge  Famous Question (source)
2022-04-12 22:59:14 +0200 received badge  Notable Question (source)
2021-08-08 22:04:35 +0200 received badge  Popular Question (source)
2020-12-09 14:31:57 +0200 received badge  Notable Question (source)
2020-12-09 14:31:57 +0200 received badge  Famous Question (source)
2018-08-14 02:43:48 +0200 commented answer Is there a way to start a Sage session from a session of its Python interpreter ?

Meanwhile there is no solution:

>>> exec(preparse(r"""
... a = 2^3
... print a
... """))
8
>>> a
8
>>> exit
> py$a
8

or also:

>>> load("some.sage")
2018-07-02 13:15:57 +0200 received badge  Notable Question (source)
2018-03-13 11:12:15 +0200 received badge  Popular Question (source)
2017-08-26 06:26:52 +0200 received badge  Notable Question (source)
2017-03-01 17:33:15 +0200 received badge  Popular Question (source)
2016-08-13 10:24:44 +0200 received badge  Self-Learner (source)
2016-05-19 21:25:05 +0200 received badge  Famous Question (source)
2015-12-22 19:01:01 +0200 received badge  Notable Question (source)
2015-04-19 11:45:29 +0200 received badge  Popular Question (source)
2015-01-14 14:26:45 +0200 received badge  Famous Question (source)
2015-01-13 21:27:35 +0200 received badge  Popular Question (source)
2014-06-29 21:47:08 +0200 received badge  Notable Question (source)
2014-06-29 21:47:08 +0200 received badge  Popular Question (source)
2014-06-29 21:47:08 +0200 received badge  Famous Question (source)
2014-06-29 16:59:11 +0200 received badge  Popular Question (source)
2014-06-29 16:59:11 +0200 received badge  Notable Question (source)
2014-06-29 16:59:11 +0200 received badge  Famous Question (source)
2014-06-29 03:14:48 +0200 marked best answer How to find if computation is in a notebook or sage prompt ?
  • Example of what is needed in sage prompt:

    sage: is_sageprompt()

    True

  • Example of what is needed in a notebook:

In an input cell: is_sagenotebook()

The output cell: True

2014-06-29 03:14:45 +0200 marked best answer What is the function for "%latex" on a notebook cell ?

In a notebook cell one can write:

%latex

Hello

\ [

x=f(x)

\ ]

and an image appear with perfect math notation. (not jsmath)

What is the sage command that does the same receiving a string ? Something like latexrender(r"Hello \ [x=f(x)\ ]")

2013-11-01 11:19:36 +0200 received badge  Taxonomist
2013-10-25 13:00:47 +0200 asked a question A log(101,base=10) that doesn't reply log(101)/log(10)

How can we develop the function below ? Where should we start to read?

"""
HSLOG = "High School Log".

Treat forms like `\log_b(a^p)` in a special manner.

Standard sage log with integer arguments works like this:

::     
    sage: log(101^3,10)
    log(1030301)/log(10)
    sage: 3*log(101,10)
    3*log(101,10)
    sage: 10^log(101,base=10)  #101
    10^(log(101)/log(10))

and     

::    
    sage: log(101,10)
    log(101)/log(10)
    sage: latex( log(101,10) )
    \frac{\log\left(101\right)}{\log\left(10\right)}  %ie: log(101)/log(10)

What we want is:

    sage: HSLOG(101,10,3)   #log_{10}(101^3)
    3*log(101,10)
    sage: HSLOG(101,10) #log_{10}(101)
    log(101,10)
    sage: 10^HSLOG(101,10) #10^log_{10}(101^3) = 101
    101
    sage: latex( HSLOG(101,10) )
    \log_{10}(101)


"""
2013-10-05 05:43:16 +0200 received badge  Famous Question (source)
2013-09-08 07:41:03 +0200 received badge  Famous Question (source)
2013-08-17 14:59:58 +0200 received badge  Popular Question (source)
2013-07-31 18:26:07 +0200 received badge  Famous Question (source)
2013-07-11 05:44:26 +0200 asked a question maximum element of a matrix

How to determine the maximum element of a matrix? For "matrix_integer_dense" there is height() [1]. For numpy matrix there is max function. How to do it in Sage matrices with one single "max" like instruction ?

[1] http://www.sagemath.org/doc/reference...

[2] Alternetive: m.numpy().max()

2013-07-04 06:25:01 +0200 commented answer JSON and basic sage types

The habit of the search for standards made ask the question. Thank you.

2013-07-02 20:17:27 +0200 asked a question JSON and basic sage types

Is there any package that produces a JSON string from sage dictionary containing "basic" sage types ?

Something like [1]:

class jsonmegua(json.JSONEncoder):

def default(self, o):
    try:
        if type(o)==sage.rings.integer.Integer:
            json_obj = int(o)
        elif type(o)==sage.rings.real_mpfr.RealLiteral:
            json_obj = float(o)
        elif type(o)==sage.rings.real_mpfr.RealNumber:
            json_obj = float(o)
        elif type(o)==sage.symbolic.expression.Expression:
            json_obj = latex(o)
        else:
            json_obj = o
    except TypeError:
        pass
    else:
        return json_obj

    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)

[1] http://docs.python.org/2/library/json...

2013-04-29 12:51:43 +0200 asked a question setting plot options

After a plot has been made, how can one change options but not using show() or save()?

Does command "change_options" in this code exists ?

   p = plot(some plot)
   p.change_options(ticks=[None, 1.5/4])

later on

 
p.show()
2013-04-16 12:10:34 +0200 received badge  Commentator
2013-04-16 12:10:34 +0200 commented answer random seed

By "later" I mean few days later and not just the next computation. Maybe this is not an effective mathematical question because random is random at all times (stopping or not). Starting from a seed there's a cycle in generated random number. But maybe that's no important to follow the same cycle if I interrupt the computation. Thanks.

2013-04-16 12:07:35 +0200 commented answer random seed

I've read but probably I'm missing the answer.

2013-04-16 11:08:28 +0200 asked a question random seed

How to start using random() and stop the process and then recover the random generation from the point where it stopped?

Example

  set_random_seed(0)
  some cycle calling random()

later

  set_random_seed( ...where??... )
  more steps of some cycle calling random()
2012-11-07 11:43:20 +0200 received badge  Notable Question (source)
2012-10-08 00:30:32 +0200 received badge  Notable Question (source)
2012-09-11 11:07:54 +0200 marked best answer How to find if computation is in a notebook or sage prompt ?

There is an env variable of sorts called EMBEDDED_MODE, I think, which is used internally to tell whether one is in the notebook.

----------------------------------------------------------------------
| Sage Version 4.6.2.alpha1, Release Date: 2011-01-20                |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
**********************************************************************
*                                                                    *
* Warning: this is a prerelease version, and it may be unstable.     *
*                                                                    *
**********************************************************************
Loading Sage library. Current Mercurial branch is: plotpatches
sage: sage.plot.plot.EMBEDDED_MODE
False

But in the notebook this will give True.

2012-08-29 04:07:47 +0200 commented question Articles about Sage Notebook

Sage Notebook is now a different product from Sage Mathematics. I would like to reference only to SageNB. I will use nb.sagemath.org as a reference. Thanks.

2012-08-21 11:54:33 +0200 asked a question Articles about Sage Notebook

Is there any list of published texts about SageNB? Thanks.

2012-06-26 23:53:04 +0200 received badge  Notable Question (source)
2012-06-22 05:25:30 +0200 commented answer What compression use a sws worksheet file?

Thanks. 'file' is new to me and a nice tool. A long term idea is to pre-build worksheets, a different one for each user to upload each.

2012-06-21 11:48:00 +0200 asked a question What compression use a sws worksheet file?

(I remember reading about it but could find again.)

2012-05-17 11:18:15 +0200 received badge  Notable Question (source)
2012-04-26 14:42:24 +0200 received badge  Popular Question (source)