Ask Your Question

ensaba's profile - activity

2022-06-21 14:26:36 +0200 received badge  Notable Question (source)
2022-05-15 14:29:50 +0200 received badge  Famous Question (source)
2022-01-30 19:49:29 +0200 received badge  Popular Question (source)
2021-09-19 02:34:03 +0200 received badge  Famous Question (source)
2020-12-09 13:12:25 +0200 received badge  Notable Question (source)
2020-11-11 04:41:11 +0200 received badge  Popular Question (source)
2020-10-17 21:09:04 +0200 received badge  Popular Question (source)
2020-10-07 10:01:29 +0200 received badge  Famous Question (source)
2020-07-17 21:06:24 +0200 received badge  Famous Question (source)
2020-06-08 20:53:12 +0200 received badge  Popular Question (source)
2019-12-14 14:14:37 +0200 received badge  Notable Question (source)
2019-10-22 08:44:44 +0200 received badge  Popular Question (source)
2019-09-09 10:25:19 +0200 received badge  Popular Question (source)
2019-09-09 10:25:19 +0200 received badge  Notable Question (source)
2019-08-26 10:19:10 +0200 received badge  Famous Question (source)
2019-07-14 16:33:27 +0200 received badge  Famous Question (source)
2018-07-04 16:24:59 +0200 received badge  Popular Question (source)
2018-04-21 15:22:46 +0200 received badge  Notable Question (source)
2017-09-12 23:37:53 +0200 received badge  Famous Question (source)
2017-08-22 23:05:52 +0200 received badge  Critic (source)
2017-08-17 00:18:50 +0200 asked a question Why does $\frac{2}{3} t - \frac{2}{3} y$ factors only when the variables are polynomial ring over the rational numbers?

The expression $\frac{2}{3} t - \frac{2}{3} y$ can be factored as $\left(\frac{2}{3}\right) \cdot (y - t)$.

If I try to use sage in this way to do the factorization:

var('y t')
E = -2/3*y + 2/3 * t
E.factor()

The result is still E.

On the other hand, if do it like this:

R.<y,t> = PolynomialRing(QQ)
E = -2/3*t +2/3*y
E.factor()

The result is as expected.

Why does the call to factor() works as expected when the variable $y$ and $t$ are defined to be a polynomial ring in QQ and not work then they are symbolic expressions.

2017-08-17 00:09:24 +0200 commented answer How to get sage to keep the same form as an expression from sympy?

If I type (y1-t1).mul(2/3, hold=true) it means that I already know the factorized form of the expression I want to factor. What if I don't know what the factorized form of the expression that I want to factor will look like?

2017-08-09 01:31:19 +0200 asked a question How to get sage to keep the same form as an expression from sympy?

I have this expression:

$$-\frac{2}{3} t_{1} + \frac{2}{3} y_{1}$$

and would like to rewrite it as follows:

$$\frac{2}{3} (-t_1 + y_1)$$

Using sympy, I can get something close:

import sympy as sp

var('y1 t1')
expr1 = -2/3*t1 + 2/3*y1
sp.factor(sp.sympify(expr1))

This gives:

𝟸*(⎯𝚝𝟷+𝚒𝟷)/𝟹

But when I convert it back to Sage:

sp.factor(sp.sympify(expr1))._sage_()

The result reverts to expr1.

How can I get the call to _sage_() not do any rewrites on the sympy expression?

2017-08-06 02:14:37 +0200 commented question How to assume the sum of some variables is equal to a constant?

Thanks for the suggestion. Do you have any idea why assume() didn't work?

2017-08-06 02:13:58 +0200 commented answer How to assume the sum of some variables is equal to a constant?

Any idea why assume() didn't work?

2017-08-05 08:08:05 +0200 asked a question How to assume the sum of some variables is equal to a constant?

Suppose I have this expression:

$$\frac{a {\left(t_{1} + t_{2} + t_{3} - 1\right)}}{b} $$

This can be simplified to 0 if we assume $t_1 + t_2 + t_3 = 1$.

How can I accomplish this in Sage? I've tried:

var('t1', 't2', 't3', 'a', 'b')
expr1 = ((t1 + t2 + t3 - 1)*a)/b
expr1.full_simplify()

assume(t1 + t2 + t3 == 1)
expr1.full_simplify()

I expected the second call tofull_simplify() to return 0 but it returned the same result as the first call, which is $$\frac{a t_{1} + a t_{2} + a t_{3} - a}{b}$$

2017-08-04 01:09:07 +0200 asked a question How to reorder terms in an expression to follow a specific order?

Suppose I have the following code:

ti = var('ti', latex_name = 't_i')
yi = var('yi', latex_name = 'y_i')
expr1 = yi -ti

expr1 will display as $$-{t_i} + {y_i}$$

Is there a way I can rewrite expr1 so that it will display as:

$$ {y_i} -{t_i}$$

?

I've tried using hold=True like so:

expr1 = yi.add(-ti, hold = True)

but that did not work.

2017-08-01 18:15:57 +0200 received badge  Good Question (source)
2017-07-31 15:40:18 +0200 received badge  Nice Question (source)
2017-07-31 03:30:11 +0200 received badge  Organizer (source)
2017-07-31 03:29:25 +0200 asked a question How to get Sage 8.0 to plot matplotlib plots inline and typeset expressions on a Jupyter notebook?

If I start Sage 8.0 notebook using the jupyter notebook (sage -n jupyter), and the following code:

from numpy import arange, sin, pi

import matplotlib.pyplot as plt

X = arange(0.0, 2*pi, 0.01)

plt.plot(X, sin(X))

plt.show()

x + 1

The plot displays inline but the expression $x+1$ is not typeset.

If I run the following code:

%display typeset


from numpy import arange, sin, pi

import matplotlib.pyplot as plt

X = arange(0.0, 2*pi, 0.01)

plt.plot(X, sin(X))

plt.show()

x + 1

Then, the plot does not display inline. It shows:

π™΅πš’πšπšžπš›πšŽ(𝟺𝟹𝟸𝚑𝟸𝟾𝟾)

However, the expression $x+1$ is in typeset.

How can I have both the matplotlib plots display inline and expressions typeset?

2017-06-24 11:27:53 +0200 asked a question Can sage do symbolic optimization?

I know sage has many functions to do numerical optimization.

Now, I am wondering if sage can do symbolic optimization as well.

For example, if I wanted to maximize a function using numerical methods, I could do this:

f(x,y) = -(x * log(x) + y * log(y))
minimize(-f,[0.1, 0.1])

Which gives the answer:

(0.367880005621,0.367880005621)

Is there a function that can give the solution as $(\frac{1}{e}, \frac{1}{e})$ or do I have to compute the stationary points and perform the necessary substitutions myself?

2017-06-08 03:08:39 +0200 commented answer Can I display a table of contents (TOC) in sage worksheet?

Is there an equivalent add-on for Chrome?

2017-04-24 16:07:49 +0200 received badge  Notable Question (source)
2016-10-24 14:20:55 +0200 marked best answer Can sage find the equilibrium solution to a first order differential equation?

I was reading this to get up to speed on how to use sage to solve differential equations.

I notice it made no mention of finding equilibrium solution.

Does this mean that sage has no function that can be used to find the equilibrium solution for a given ordinary differential equation?

2016-09-10 00:45:08 +0200 received badge  Popular Question (source)
2016-08-13 20:45:33 +0200 received badge  Popular Question (source)