Ask Your Question

bekalph's profile - activity

2021-04-08 09:31:01 +0200 received badge  Notable Question (source)
2021-04-08 09:31:01 +0200 received badge  Popular Question (source)
2021-01-29 10:01:29 +0200 received badge  Notable Question (source)
2021-01-29 09:55:12 +0200 received badge  Popular Question (source)
2020-12-04 18:04:55 +0200 received badge  Notable Question (source)
2020-08-03 16:30:53 +0200 received badge  Notable Question (source)
2020-06-30 03:44:00 +0200 received badge  Popular Question (source)
2020-02-16 09:54:43 +0200 received badge  Popular Question (source)
2020-01-23 15:08:55 +0200 received badge  Notable Question (source)
2020-01-23 15:08:55 +0200 received badge  Popular Question (source)
2019-11-27 16:30:46 +0200 asked a question How to avoid scientific notation of numbers in the Mathematica interface

I use the mathematica interface to compute numerical values of an extended hyper-geometric function MeijerG for real arguments. This function is provided only by Mathematica:

mathematica('MeijerG[{{1, 3/2}, {}}, {{1, 1}, {1/2}}, mx]')

For real arguments x >= 0.00001 I get useful numeric results, e.g.


for x =0.00001. However, for 0< x < 0.00001 this method fails. With a small argument x and

mathematica('MeijerG[{{1, 3/2}, {}}, {{1, 1}, {1/2}}, mx]'),

With this small argument, I obtain:

resp=MeijerG[{{1, 3/2}, {}}, {{1, 1}, {1/2}}, -9. + 1.*e]

Obviously, this behavious is caused by the python interpreter: It converts pure decimal presentation of numbers (see previous example) into their scientific presentation. And, as I have learned from contributions in the Mathematica's stack exchange, Mathematica doesn't accept formatted numbers like ScientficForm, etc, for numerical evaluation of functions. Thus, Mathematica lets requested numeric evaluation undone. I haven't found any hints how to prevent python from expressing the argument in scientific format. Is it possible by any means to circumvent this problem?

2019-11-27 15:07:33 +0200 received badge  Scholar (source)
2019-11-17 20:02:42 +0200 commented answer SageMath cannot access Mathematica

It works! Many many thanks for your help. I suggerst to include this important advice in the official sageMath documentation.

2019-11-17 13:41:42 +0200 asked a question SageMath cannot access Mathematica

I have installed Mathematica Version 11.3 at a Linux system (openSUSE Leap 15.1) on a partition "math", i.e. separated from the Linux home and system partition. I have tried to send Mathematica expressions from SageMath to Mathematica in the manner described in the SageMath reference by using a SageMath Notebook or its command line interface. They are rejected with:

TypeError: unable to start mathematica: End Of File (EOF). Exception style platform. Mathematica finished running /usr/bin/sh -c stty -echo; math -rawterm command: /usr/bin/sh args: ['/usr/bin/sh', '-c', 'stty -echo; math -rawterm'] buffer (last 100 chars): '' before (last 100 chars): 'es/Linux/WolframKernel\r\nnot found. Your Mathematica installation may be i incomplete\r\nor corrupted.\r\n' after: <class 'pexpect.exceptions.eof'="">

In the course of the installation of Mathematica I added the path to the math command line interface of Mathematica to the common PATH-sequence. Therefore I am able to access the Mathematica command line interface by simply entering math or the command:

/usr/bin/sh -c stty -echo; math -rawterm

using a bash-terminal outside SageMath. I have checked that I can do it without the need for specifying the complete path to math. However, entering the same command within a Sage-session by using the Python's OS- interface is only successful if the full path to math is specified:

/usr/bin/sh -c stty -echo; /run/media/bernhardi/math/math -rawterm

The error appearing otherwise is the same as that one returned by the above described trials to send mathematica objects. The protocol shows that the mathematica objects are sent to Mathematica without detailed path info. Thus, obviously the SageMath-Mathematica interface does not recognize the complete path info that is availabe in the basic Linux system. Maybe the missing info is caused by the fact that Mathematica is located on a remote partition. Therefore my question: Is it possible to provide sageMath with the needed full path to math?

Unfortunately it is not possible to attach the complete output of SageMath.

2019-10-14 21:16:47 +0200 received badge  Taxonomist
2019-01-12 18:00:58 +0200 asked a question How to configure jupyter for Sage-specific use?

I am an absolute beginner in using jupyter-notebooks. Since SageMath version 8.5 the user is asked to be prepared for using jupyter as the standard notebook in the future. So, in Linux I activate jupyter with ./ sage -n jupyter and do some experiments. In this way, obviously, SageMath activates an internal jupyter package via an internal notebook-interface (and not via an external jupyter installation e.g. in anaconda). I tried also to edit python code within a jupyter cell. I got some unexpected errors, so editing code in jupyter cells seems to be problematic. Also, I want to figure out, why editing python code within a jupyter cell changes the color marks of some 'if' statements to red? Sometimes, after re-opening a closed jupyter session appears as plain text only, i.e., without cells.

My simple question is therefore: Is there any documentation available for the sage-specific use of jupyter (e.g., meaning of color code for the elements of the python language, extra necessary import of additional sage objects for jupyter, configuration of jupyter, etc)?.

2018-06-05 08:10:51 +0200 received badge  Self-Learner (source)
2018-06-05 08:10:51 +0200 received badge  Teacher (source)
2018-06-05 08:10:45 +0200 received badge  Nice Question (source)
2018-06-04 21:57:09 +0200 answered a question convert charpoly()-generated characteristic polynom to symbolic expression

I just found that characteristic polynomals of matrices can also be converted to SR by substituting one of their symbols with subs.

2018-06-04 20:51:16 +0200 commented answer convert charpoly()-generated characteristic polynom to symbolic expression

Thank you very much for the hint. I need the conversion to SR in order to simplify the expression with canonicalize_radical() or with factor(). This seems not be possible if I apply them on the unconverted expression (unimplemented error or attribute error). I just found that characteristic polynomals of matrices can also be converted to SR by substituting one of their symbols with subs.

2018-06-04 20:21:46 +0200 answered a question convert charpoly()-generated characteristic polynom to symbolic expression

Thank you very much for the quick response, However, I want to calculate the characteristic polynom of a matrix containing symbols, e.g.:


m=matrix(SR,[[ a , 1 , b],[ 0 , c , 1],[ d , 1 ,-1]])

2018-06-03 19:33:33 +0200 asked a question convert charpoly()-generated characteristic polynom to symbolic expression

A characteristic polynom that is generated by the procedure charpoly() has the type:


How can I convert it to one of type 'symbolic expression' without doing 'copy and paste'?

2018-04-04 11:18:52 +0200 received badge  Popular Question (source)
2018-03-22 21:37:27 +0200 commented answer Mathematica misinterprets some underscored symbolic variables

I agree, The best method to circumvent this problem is substituting the "_"- symbol by unique identifiers in sage and subsequently replacing them in Mathematica by its appropriate underscoring. key combination. This workaround should be applied to all kinds of underscored symbols (not only for underscored numbers).

2018-03-21 14:06:46 +0200 received badge  Popular Question (source)
2018-03-21 08:25:24 +0200 asked a question Mathematica misinterprets some underscored symbolic variables

Following examples show that the interface between sage and Mathematica misinterprets symbolic variables if they are underscored with numbers:

sage: h_20,h_10,h_2,h_3,h20,h10,h_ij,h_kl=var("h_20,h_10,h_2,h_3,h20,h10,h_ij,h_kl");
sage: mexpr=mathematica((h_20+h_10)^3);
sage: print(mexpr);
     27000 (h_)
sage: mexpr1=mathematica((h20+h10)^3);
sage: print(mexpr1);
     (h10 + h20)
sage: mexpr2=mathematica((h_2+h_3)^3);
sage: print(mexpr2);
     125 (h_)
sage: mexpr3=mathematica((h_ij+h_kl)^3);
sage: print(mexpr3);
     ((h_ij) + (h_kl))

I use sage-8.1 and Mathematica 11.2.0 at Linux OpenSUSE Leap v42.3. In this forum I haven't found any other comment regarding this funny behaviour.

2017-05-09 16:48:50 +0200 asked a question Interactive solving differential equations with MAXIMA's desolve

I am using Maxima's "desolve" to handle a system of linear differential equations. During processing, Maxima arrives at an intermediate expression (in my case this is a complicated argument of a sqareroot) that may be positive, negative or zero. Maxima asks me interactively if this expression is negative, positive or zero. If I use "desolve" directly within the Maxima's notebook, I can give my answer interactively (e.g., "pos") to Maxima. Consequently, Maxima can continue processing immediately. Thus, in Maxima's notebook there is no need to use an 'assume' statement that includes the whole complicate expression in question. On the contrary, processing this system via Maxima's 'desolve ' at a sage's notebook is very inconvenient, since, according to sage's documentation, one can answer such questions only via assumes given prior to 'desolve'. Moreover, in the treated case Maxima ignores such 'assume'-statements. Thus, solving my equation system at Maxima via sage turns out to be impossible.
Thus my question: Is it really impossible to answer Maxima's interactive questions via sage? If not, one should implement this feature in future save-versions. This would enable sage to solve linear differential equations that cannot be treated by sage up to now.

Here is a simlpe executable example for interactive working with Maxima. (Members of Maxima's discussion forum gave this example to me for demonstration) I tried to answer this question interactively at a sage- notebook. Unfortunately, This leads to a deadlock in the sage-platform (version 7.4).

(%i1) integrate(x^a,x);
 Is a equal to -1?   

 (%o1) x^(a+1)/(a+1)
2016-09-06 00:17:12 +0200 commented answer ATAN2 AssertionError while plotting complex squareroot function

I have checked this in the cloud and also in my private 7.3 version. I made additional checks: An integer delta=1 is ok, but unfortunately a real delta=1.0 results in the same error. Also delta=real(1) is ok, but not delta=real(1.0). Thus, the problem persists, which obviously is caused by a wrong type conversation.

2016-09-05 21:59:22 +0200 asked a question ATAN2 AssertionError while plotting complex squareroot function

I want to plot the real part of a a squareroot function with complex argument by using the SAGE plot method.
This plot method combines function evaluation and plotting within one single python statement.
It fails with the error message :ATAN2 Assertion error.
However, doing the job in two separate consecutive steps , i.e., evaluating the needed function values first and plotting them afterwards with SAGE's line method is successful without error.
The following example code demonstrates this behaviour.
Meaning of variables:
f_exampl: test function calling the real part of a square-root function;
exx=1 uses the method "plot" ;
exx=2 uses the method "line" to plot a pre-calculated list of values.
delta =0: the argument of the square-root is real
delta /= 0 : I*delta is the imaginary part of the squareroot argument.

The result:
testcase exx=2 is successful for delta=0 and delta != 0.
testcase exx=1 is successful for delta=0.
testcase exx=1 aborts with ATAN2 Assertion error if the squareroot must evaluate complex numbers.

Apparently there is a conflict between the evaluation of complex sqareroots during SAGE's plot method.
Evaluating the complex sqareroots without plotting them can be done without problems.
However, In my case it is more convenient to use SAGE's plot instead of SAGE's line method.
Is it possible to avoid the assertion error in the preferred plot method?

I used SAGE Version 7.1 within a Linux opensuse 42.1 OS.

x,delta,exx=var('x', 'delta', 'exx')
def f_exampl(xx):
    return sqrt(xx-I*delta)
if exx==2:
    # exampl_2: no assertion error, if delta != 0: 
    list_exampl=[[xmin+(xmax-xmin)*i/plotpts,real_part(f_exampl(xmin+(xmax-xmin)*i/plotpts))]for i in range(plotpts_1)]
    exampl_2=line(list_exampl,thickness= 2,color='red',marker='+')
    # exampl_1: assertion error, if delta != 0: 
    exampl_1=plot (real_part(f_exampl(x)),(x,xmin,xmax),ymin=1.0,ymax=+ym,plot_points=plotpts,color='blue',marker='+')
2016-04-25 00:09:59 +0200 asked a question store python code from a notebook cell to a file

During a notebook session I enter a series of SAGE-statements (python code) in a notebook cell. How can I let SAGE store/save this code automatically (not via copy&paste) in a file? The purpose is to reload the stored code in a cell of another session for later processing . I tried to perform this via the "save-session" -command. However, this results in a data volume of several MB, which is much larger than the total length of the code of the session. This I want to avoid.

2015-11-09 17:01:13 +0200 received badge  Student (source)
2015-11-09 14:48:26 +0200 asked a question Substituting derivatives in Taylor expansions

Within Taylor expansions, as well as in results of 'Derivative'- operations, derivatives are marked by symbol "D[ ]" . I want to substitute them by other symbolic expressions/functions in order to get the usual presentation of derivative symbols via Latex. The following testprogram demonstrates that derivatives triggered by the "derivative"-operation can indeed be substituted by user-defined symbols, but not derivatives in Taylor expansions.

print 'a3(x):',a3(x)
print 'da3:', da3
print '### After a "derivative"-operation, substituting dt1 by dTedx works:'
print 'da4:',da4
print 'Taylor series ata:',ata
print '### After Taylor expansion, substituting dt2 by dTedx does not work:'
print 'Taylor series atb:',atb

I run this program within In a SAGE6.8 notebook-session. The output is:

dt1: D[0](T_e)(x)
dt2: D[0](T_e)(x_0)
a3(x): a_5*T_e(x) + a_4

After a "derivative"-operation, substituting dt1 by dTedx works:

da3: a_5*D[0](T_e)(x)
da4: a_5*dTedx

After Taylor expansion, substituting dt2 by dTedx does not work:

Taylor series ata: a_5*(x - x_0)*D[0](T_e)(x_0) + a_5*T_e(x_0) + a_4
Taylor series atb: a_5*(x - x_0)*D[0](T_e)(x_0) + a_5*T_e(x_0) + a_4

What is the reason for this difference? Maybe, I merely must access the derivative expression within a Taylor expansion in a different way. Thus: which is the correct way to do this?

2014-11-29 23:34:34 +0200 commented answer How to define more complicated differential expressions in Sage?

I want to add a remark concerning the real problem with D0(y).

You can substitute the default output of an derivative-operation, e.g. D[0] (fxx)(z)

by any symbolic function you want by using the 'derivative_func'- option of 'function'.

Following Example using symbolic function definition

  • fx with this option,

  • fxx without this option.:



def dfx(self,args,*kwds):return dfxdz(z)



For the input

fx(z).derivative(z) #with derivative_func

you get the output :


For the input

fxx(z).derivative(z) #without derivative_func

you get the output: D[0] (fxx)(z)

2014-11-25 19:08:57 +0200 answered a question How to define more complicated differential expressions in Sage?

Perhaps the answer I have given for the question "latex typesetting for derivatives" at 31.Oct. can help you. One can utilize the option "derivative_func" of Function to let perform a list containing the requested results of the partial differentiations during processing a product rule or a chain of differentiations.

2014-10-31 19:39:46 +0200 received badge  Editor (source)
2014-10-31 19:28:36 +0200 answered a question latex typesetting for derivatives like g'

Obviously it is possible to assign any latex text to derivatives by using the ' derivative_func' -option of the 'function'- procedure. Below I have addad an example that I have executed in the SAGE V63 environment.


def dfx(self,args,*kwds):return dfxdz(z)

def dfy(self,args,*kwds):return dfydz(z)










def pderivg(self, args, *kwds): print "args:",args; print "kwds:",kwds,pdev[kwds['diff_param']]; return pdev[int(kwds['diff_param'])]

gf = function('gf', latex_name='g',nargs=2, derivative_func=pderivg)