Ask Your Question

Pedro's profile - activity

2018-08-13 19:43:48 -0500 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
... """))
>>> a
>>> exit
> py$a

or also:

>>> load("some.sage")
2018-07-02 06:15:57 -0500 received badge  Notable Question (source)
2018-03-13 05:12:15 -0500 received badge  Popular Question (source)
2017-08-25 23:26:52 -0500 received badge  Notable Question (source)
2017-03-01 10:33:15 -0500 received badge  Popular Question (source)
2016-08-13 03:24:44 -0500 received badge  Self-Learner (source)
2016-05-19 14:25:05 -0500 received badge  Famous Question (source)
2015-12-22 12:01:01 -0500 received badge  Notable Question (source)
2015-04-19 04:45:29 -0500 received badge  Popular Question (source)
2015-01-14 07:26:45 -0500 received badge  Famous Question (source)
2015-01-13 14:27:35 -0500 received badge  Popular Question (source)
2014-06-29 14:47:08 -0500 received badge  Notable Question (source)
2014-06-29 14:47:08 -0500 received badge  Famous Question (source)
2014-06-29 14:47:08 -0500 received badge  Popular Question (source)
2014-06-29 09:59:11 -0500 received badge  Notable Question (source)
2014-06-29 09:59:11 -0500 received badge  Famous Question (source)
2014-06-29 09:59:11 -0500 received badge  Popular Question (source)
2014-06-28 20:14:48 -0500 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()


  • Example of what is needed in a notebook:

In an input cell: is_sagenotebook()

The output cell: True

2014-06-28 20:14:45 -0500 marked best answer What is the function for "%latex" on a notebook cell ?

In a notebook cell one can write:



\ [


\ ]

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 05:19:36 -0500 received badge  Taxonomist
2013-10-25 06:00:47 -0500 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)
    sage: 3*log(101,10)
    sage: 10^log(101,base=10)  #101


    sage: log(101,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)
    sage: HSLOG(101,10) #log_{10}(101)
    sage: 10^HSLOG(101,10) #10^log_{10}(101^3) = 101
    sage: latex( HSLOG(101,10) )

2013-10-04 22:43:16 -0500 received badge  Famous Question (source)
2013-09-08 00:41:03 -0500 received badge  Famous Question (source)
2013-08-17 07:59:58 -0500 received badge  Popular Question (source)
2013-07-31 11:26:07 -0500 received badge  Famous Question (source)
2013-07-10 22:44:26 -0500 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 ?


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

2013-07-03 23:25:01 -0500 commented answer JSON and basic sage types

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

2013-07-02 13:17:27 -0500 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):
        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)
            json_obj = o
    except TypeError:
        return json_obj

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


2013-04-29 05:51:43 -0500 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
2013-04-16 05:10:34 -0500 received badge  Commentator
2013-04-16 05:10:34 -0500 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 05:07:35 -0500 commented answer random seed

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

2013-04-16 04:08:28 -0500 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?


  some cycle calling random()


  set_random_seed( ...where??... )
  more steps of some cycle calling random()
2012-11-07 04:43:20 -0500 received badge  Notable Question (source)
2012-10-07 17:30:32 -0500 received badge  Notable Question (source)
2012-08-28 21:07:47 -0500 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 as a reference. Thanks.

2012-08-21 04:54:33 -0500 asked a question Articles about Sage Notebook

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

2012-06-26 16:53:04 -0500 received badge  Notable Question (source)
2012-06-21 22:25:30 -0500 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 04:48:00 -0500 asked a question What compression use a sws worksheet file?

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

2012-05-17 04:18:15 -0500 received badge  Notable Question (source)
2012-04-26 07:42:24 -0500 received badge  Popular Question (source)
2012-03-25 04:00:48 -0500 received badge  Popular Question (source)
2012-01-29 23:08:07 -0500 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

But in the notebook this will give True.

2012-01-17 02:10:37 -0500 marked best answer What is the function for "%latex" on a notebook cell ?

In the notebook, I believe that executing a %latex cell is equivalent to the command

Latex().eval("string", globals=globals)

For example,



Goodbye""", globals=globals)
2012-01-05 02:44:37 -0500 commented answer Personalizing the notebook

Where, in a recent sage release, is SAGENB_TEMPLATE_PATH set ? How is it set to sagenb/data/sage ?

2011-12-07 08:10:13 -0500 received badge  Popular Question (source)