Ask Your Question

Green diod's profile - activity

2018-03-16 17:50:21 -0600 received badge  Popular Question (source)
2017-06-21 02:17:01 -0600 received badge  Good Question (source)
2017-06-21 02:16:58 -0600 received badge  Famous Question (source)
2017-06-13 14:47:24 -0600 received badge  Notable Question (source)
2017-03-27 20:59:06 -0600 received badge  Notable Question (source)
2016-08-11 19:30:18 -0600 received badge  Popular Question (source)
2016-07-22 13:48:46 -0600 received badge  Famous Question (source)
2016-03-11 09:15:34 -0600 received badge  Notable Question (source)
2016-01-15 18:18:50 -0600 received badge  Notable Question (source)
2015-12-08 02:06:51 -0600 received badge  Famous Question (source)
2015-05-03 00:39:32 -0600 received badge  Popular Question (source)
2014-11-10 02:35:00 -0600 received badge  Notable Question (source)
2014-06-28 20:15:10 -0600 marked best answer Symbolic solve

Following the change of variable thread, I wanted to streamline the whole process.

Namely, using the same example in the above thread, I'd like to say

integral_def_change(x*cos(x^2+1), (x, 0, 2*pi), u==x^2+1, u)

The difference is, I wanted also Sage to automatically solve for x instead of providing x= sqrt(u-1), say. But when I tried

solve(u==x^2+1, x)[0].rhs()

the output was r1 ???

1- What exactly is r1 ??

A way out (see this thread) seems to make of the solution a function of u

f(u)=solve(u==x^2+1, x)[0].rhs()

Now f is

u |--> -sqrt(u - 1)

2- What can I do to get +sqrt(u - 1) instead? Is this related to the positive function question there?

2014-06-28 20:15:09 -0600 marked best answer Getting help inside Sage

Sorry if it's a dumb question, folks.

What are all the ways of getting help inside Sage? I would like some table like this:

item?? | see code
help(item) | see help about item

I ask this question because I only know the ?? and help() ways. But they don't always work: I tried simplify_full?? and help(simplify_full) but ... got errors!

2014-06-28 20:15:08 -0600 marked best answer Change of variable in an integration

How to indicate a change of variable to Sage in an integration when Sage seems clueless?

2014-06-28 20:15:08 -0600 marked best answer Sympy integration algorithm towards -infinity

Following achrzesz hint about integral's algorithm option, I tried (Sage 4.7.2):

integral(1/x^2, x, -infinity, -1, algorithm='sympy')

Unfortunately, I got:

Traceback (click to the left of this block for traceback)
...
AttributeError: 'MinusInfinity' object has no attribute '_sympy_'

What's going wrong?

2014-06-28 20:15:08 -0600 marked best answer Keyboard layout in Sage appliance

Hi all,

I'm currently testing Sagemath on a Windows 7 box via sage appliance (4.7.2). I wanted to try the interactive shell out but it is not usable as my host keyboard layout is fr and the guest fedora box for sage uses en.

A quick search pointed me to the system-config-keyboard command but too bad, it is not shipped with sage appliance 4.7.2. Any other hint ?

Final solution (see below): change layout via sudo nano /etc/sysconfig/keyboard

KEYTABLE="fr-latin1"
MODEL="pc105+inet"
LAYOUT="fr"
2014-06-28 20:15:07 -0600 marked best answer Interactive question in notebooks

When trying to find some solution to the double integral problem and poking around with Sage (4.7.2), I stumbled upon this behavior:

x,y,u,v,p,k=var('x,y,u,v,p,k')
integrate(x+y^k, y)

output (resembles maxima interaction):

Traceback (click to the left of this block for traceback)
...
Is  k+1  zero or nonzero?

How can I answer to this (with nonzero)?

Update: I accept @god.one solution below as there seems no way as for now to interactively answer those maxima questions.

2014-05-21 22:04:48 -0600 received badge  Popular Question (source)
2014-02-20 02:54:00 -0600 received badge  Notable Question (source)
2014-02-11 02:46:35 -0600 received badge  Popular Question (source)
2014-02-04 01:32:16 -0600 received badge  Notable Question (source)
2014-01-28 01:44:12 -0600 received badge  Popular Question (source)
2014-01-03 08:31:57 -0600 received badge  Famous Question (source)
2013-08-28 02:13:38 -0600 marked best answer Symbolic solve
sage: var('u')
u
sage: solve(u==x^2+1, x)
[x == -sqrt(u - 1), x == sqrt(u - 1)]

So you could use [1] instead of [0] to get the "positive" one.

I don't know how you got the r1 from this example, but the documentation for solve says, among other things:

   If there is a parameter in the answer, that will show up as a new
   variable.  In the following example, "r1" is a real free variable
   (because of the "r"):

      sage: solve([x+y == 3, 2*x+2*y == 6],x,y)
      [[x == -r1 + 3, y == r1]]

Hope this helps!

2013-07-14 12:43:59 -0600 received badge  Famous Question (source)
2013-07-08 17:49:46 -0600 received badge  Famous Question (source)
2013-03-27 23:27:35 -0600 received badge  Popular Question (source)
2013-03-16 01:53:16 -0600 received badge  Taxonomist
2013-01-07 07:33:40 -0600 received badge  Notable Question (source)
2012-12-14 05:53:57 -0600 received badge  Notable Question (source)
2012-12-09 23:49:55 -0600 received badge  Popular Question (source)
2012-10-29 12:44:41 -0600 received badge  Notable Question (source)
2012-10-09 03:04:16 -0600 received badge  Popular Question (source)
2012-07-28 10:19:27 -0600 received badge  Popular Question (source)
2012-07-25 19:39:41 -0600 received badge  Popular Question (source)
2012-04-06 09:38:46 -0600 marked best answer Interactive question in notebooks

Hi, you can use the assume command

x,y,u,v,p,k=var('x,y,u,v,p,k')
assume(k+1!=0)
integrate(x+y^k, y)

which calculates to

x*y + y^(k + 1)/(k + 1)
2012-02-13 09:58:13 -0600 commented answer Loading a predefined function

But the .py file is on my local drive, not on the VM drive ...

2012-02-13 09:54:19 -0600 edited question Piecewise assumptions (for integration)

All right, still with these integration problems, and I don't know all the subtleties of passing extra-arguments to Maxima (ok, I reckon that @kcrisman doesn't stop pointing out Maxima flags now and then when some expert uses them but some list would be very handy).

What I want is to integrate a function with the domain of integration broken into pieces. The problem is that the maxima engine requires different assumptions for each piece but an assumption seems to tie a variable globally.

Example: In fact, this example is still related to the double integral thread over there. After a little but tedious pen and paper work, I could get rid of the absolute value by breaking the domain of integration into pieces but then I'm stuck again. Independently of my own shortcomings and maybe the hard nature of what I tried to compute, in my sense, the remaining problem causes are mainly twofold, we need to talk to Maxima (pass assumptions) and the assumption mechanisms in Sage are somehow weak.

This is what I tried to get around these shortcomings and to answer the above question:

# This could take extra-arguments for the integral function (algorithm, ...) but I don't know all of them, so let's leave this as is for now.
def integral_assumptions(f, var, lbound,  ubound, extra_assumptions):
   old_assumptions= assumptions() # Keep current assumptions for later restore
   assume(extra_assumptions)
   result = integral(f, var, lbound, ubound)
   forget()
   assume(old_assumptions) # Unfortunately, extra assumptions don't stay local
   return result

Different problems arise:

1- If the integral call breaks (and this often occurs), the old_assumptions are not restored .. ok, this one should be easy and dealt with some exception handling but I don't know the Sage coding guideline here.

x,y,u,v,p,k,b=var('x,y,u,v,p,k,b') # It seems enough to just say var('x,y,u,v,p,k,b') but I'm not sure
n(x)=1/sqrt(2*pi) * exp(-1/2*x^2) # I would have loved to be able to get this directly from Maxima but okay, it was just a few keystrokes away.
# I need to split at -sqrt(k-1)*v
alpha_neg(v,k,p)=integral_assumptions((u)^p*(u+sqrt(k-1)*v)^p*n(v)*n(u), u, 0, -sqrt(k-1)*v, [k-1 > 0, v < 0])
integral(alpha_neg(v, k, p), v, -oo, 0) # Error
alpha_neg(v,k,2) # Still an error but just to find the culprit

2- One big problem is the way Sage handles assumptions: they are global and (but maybe that feature is because of the fact that ...) they can't be made more stringent. Namely assume(x>=0); assume(x>0) doesn't yield x>0. It would have also been handy to be able to say forget(x>0) and it would give back x>=0 and have a forget_about(x) function which forgets everything about x ..

To be clear, I'm not against global assumptions but I just ... (more)

2012-02-13 09:51:49 -0600 commented question Piecewise assumptions (for integration)

See the updated question. Yeah, it's along the same lines as your example and the problem is that Maxima may need different sets of assumptions for each part of the domain.