Ask Your Question's profile - activity

2020-11-16 07:11:39 +0200 received badge  Famous Question (source)
2019-04-26 16:31:53 +0200 answered a question How to break up function definitions across several lines?


you can use line breaks line breaks

phi(epsilon, Q, r) = 1/(4*pi* \
                    epsilon \


Worked for me in the sage command line v8.2

2019-03-15 10:55:09 +0200 commented answer How to construct the following matrix

Why are there elements in the top right and bottem left corner of the matrix?

2019-03-06 16:18:46 +0200 received badge  Nice Answer (source)
2019-03-06 07:28:32 +0200 answered a question What an efficient way to construct a n by n matrix with all entries -1?

Or you could try numpy which is roughly 50 times faster

import time
import numpy as np

for i in range(100):
    test = a*np.ones([1000,1000])


But keep in mind that the example

from itertools import repeat

generates a different type than a numpy array does

<type 'sage.matrix.matrix_rational_dense.Matrix_rational_dense'>

<type 'numpy.ndarray'>
2019-02-07 13:28:01 +0200 received badge  Popular Question (source)
2017-10-18 22:31:11 +0200 received badge  Notable Question (source)
2017-10-06 16:46:03 +0200 received badge  Popular Question (source)
2016-10-19 20:10:51 +0200 received badge  Famous Question (source)
2016-06-10 18:31:42 +0200 received badge  Famous Question (source)
2015-10-22 18:20:49 +0200 received badge  Popular Question (source)
2015-10-14 02:53:21 +0200 received badge  Notable Question (source)
2015-09-25 15:02:26 +0200 received badge  Notable Question (source)
2015-09-08 19:29:53 +0200 received badge  Popular Question (source)
2015-04-12 20:09:43 +0200 answered a question Can I enter identity solution in trig and give me answer?


it is possible, just try


which will result in

-2*cos(x)*sin(x) + 1

since sin(x)^2+cos(x)^2=1 (I think you mean this formula with the trigonometric identity).

2015-03-27 04:07:27 +0200 marked best answer solve solution change after cell evaluation

Hello everyone,

I wanted to fit some data and I found a strange behaviour of solve(). After evaluating cell 1,2 and 3 and further evaluations of cell 2,3,2,3,2,3,... the solution for kf changes and gets smaller and smaller. I use Sage 5.9 in a VM in Win7Prof


# data=[another list]


# modell for fitting

print 'best_fit_par'
print best_fit_par



The values for kf started at 0.49 and are wandering towards 0.35

Thanks in advance

2015-01-23 21:45:49 +0200 received badge  Taxonomist
2014-11-16 07:03:19 +0200 commented answer Solving an equation in multiple variables

Thanks, but in this case using different assume scenarios resulting in different results is strange (escpecially in the both is negative case)

2014-11-15 14:30:25 +0200 answered a question Solving an equation in multiple variables

You can try the following with substituting b-a with c

eq1 = (sqrt((c)^2 + (B-A)^2) == A+B)

which results in

[c == -2*sqrt(A*B), c == 2*sqrt(A*B)]

But can anybody explain me the results of the computation without the assume statements? For A,B both beeing negative the solver does not do anything and for A being bigger and B being smaller then zero, sage throws an error that maxima needs further inputs (the same as when you're not using assume)

2014-10-10 06:12:04 +0200 answered a question Problem with solution_dict=True

Hi, could you please tell us which version of sage you are using? Going to

var('x y')
sol=solve(x + y, [x, y], solution_dict=True)


[{x: -y}]

which still surprises me since the system of equation is more than incomplete.

2014-10-05 15:06:32 +0200 received badge  Nice Answer (source)
2014-10-01 07:17:39 +0200 commented answer How to plot correctly these two simple exponential functions?

Try imag, imag_part or imaginary, they should do the trick. And remember to use help or ? often to find out what a function does.

2014-09-30 10:17:36 +0200 answered a question How to plot correctly these two simple exponential functions?


sage is correct saying that a negative number cannot be raised to a fractional power IF you want to plot it. For example


The first one is imaginary, the other one real, so you cannot plot both in the same 2D plot. You could use the abs() function to avoid this problem. Another thing is

sage: f(x).limit(x=0,dir='+')
sage: f(x).limit(x=0,dir='-')

so that your plot for either f or g will have a huge peak which will suppress the rest of the plot. Try the following:

sage: f1(x)=x^(1/x)
sage: f2(x)=(-x)^(1/x)
sage: p1=plot(f1(x),0,5)
sage: p2=plot(f2(x),-5,-0.5)
sage: show(p1+p2)
2014-09-30 07:09:51 +0200 answered a question How do you plot solutions of an O.D.E?

I'm sorry, this forum is not here for solving your homework. If you have any non-working code which you could provide, anybody here is happy to help you.

And since this is a special use-sage-task, propably your instructor is lurking around here, too :)

2014-09-26 18:28:35 +0200 marked best answer Reliability of Sage vs commercial software

Hello everybody,

for future calculations I need a CAS. Up to now, I worked with a free mathematica student licence. But now I need a officially bought version (which I can't afford). I'm now trying to work with Sage but my head of department is no fan of open source projects and thinks, among other things, that it is probably buggy and not as powerful as said mathematica. Could you please tell me how "stable" and "correct" the sage calculations are and give me further information on this topic (I already searched the forum for some information) so that I can present him/them why we should use Sage and nothing like mathematica/mathlab/...

Please tell me if you need more information or clarification.

Thank you all in advance for your effort.


2014-09-08 17:52:53 +0200 answered a question derivatives of variable order

Don't know if this helps but

def P(f,m,n):
    return derivative(f,x,m+n)

works fine with

2014-08-25 11:07:44 +0200 asked a question Sage and Maxima expression not compatible


I got another problem relating to this question and many other of that kind (sorry for opening another question). If I use


in the shell, I get

TypeError: unable to make sense of Maxima expression 'imagpart(f[4,3]([1/2,1/2,1/2,1],[3/2,3/2,3/2],e^-(2*I*pi*r1)))' in Sage

I read in that the problem concerns the temporary variables. But is there a possibility to reformulate the problem to get to the solution? Btw, I'm using Sage v6.2 on a LinuxMint machine.

2014-08-03 13:32:21 +0200 commented answer Solve equations with sin(x)

On using var('x,y'); solve([y==sin(x),y+4*sin(x)==5],x,y) I get [y == sin(x), y + 4*sin(x) == 5] as a solution

2014-08-03 13:30:25 +0200 answered a question Solve equations with sin(x)

On using



2014-08-02 03:30:18 +0200 received badge  Good Question (source)
2014-07-30 16:38:21 +0200 received badge  Nice Question (source)
2014-07-30 12:10:09 +0200 commented answer Load notebook .sws file into shell

Sehr schoen. I will try this. If there is no easy way to turn .sws files into .sage files, the old copy&paste will have to do it for now.

2014-07-30 07:59:02 +0200 asked a question Load notebook .sws file into shell

Hello everyone.

I used for a very long time and now I wanted to migrate all my files to my PC. Is there any possibilty to load the .sws files into the sage shell? Searching the web did not bring any answers.

Another question: what is the best substitution to a sws in the shell? Should I write my sage code in another editor and then run it in the sage shell (eg. write all def in a py file, load it anew in every session,...)?

Thanks in advance

2014-07-14 06:55:07 +0200 commented answer Fast (uniform) random integer generation

Hi, I got a question unrelated to this one but to your code. If I stupidly copy and paste it in a notebook, it throws different errors like 'invalid syntax'. The version that works for me is timeit('[randint(0,10) for i in xrange(1000)]') timeit('[randrange(0,11) for i in xrange(1000)]') import numpy timeit('[numpy.random.random_integers(0,10) for i in xrange(1000)]') timeit('numpy.random.random_integers(0,10,1000)') Can someone explain this to me or give me a hint for which keywords I have to search? Thanks in advance.

2014-06-29 17:54:19 +0200 received badge  Notable Question (source)
2014-06-29 17:54:19 +0200 received badge  Popular Question (source)
2014-06-29 17:54:19 +0200 received badge  Famous Question (source)
2014-06-29 03:15:11 +0200 marked best answer multiple region_plots in one plot

Hi, I want to plot two region_plots into one plot. The idea is if you use different colors for the inequalities you can see how the regions change. A minimal example:


I do not know how to manage this, since zorder or opacity are not working for region_plot. Does anybody know how to make this work (by the way I use Thanks in advance

2014-06-29 03:15:10 +0200 marked best answer How can one use maxima kummer confluent functions in sage

Hi, here is my piece of code

assume(m, 'integer')
y = function('y', x)
desolve(diff(y,x,2) + 2*x*diff(y,x) - 4*m*y, y,contrib_ode=true,ivar=x)

which yields

[y(x) == k1*kummer_m(-m, 1/2, -x^2) + k2*kummer_u(-m, 1/2, -x^2)]

Internet(Wikipedia) sais that the solutions to this differential equation are the Kummer functions or Confluent_hypergeometric_functions. I now want to know how I can use these functions in sage since they must be defined in maxima.

Thanks in advance