ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 27 Nov 2019 09:30:46 -0600How to avoid scientific notation of numbers in the Mathematica interfacehttps://ask.sagemath.org/question/48908/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:
var('x,mx')
x=0.00001
resp=mathematica.set(mx,x)
mathematica('MeijerG[{{1, 3/2}, {}}, {{1, 1}, {1/2}}, mx]')
For real arguments x >= 0.00001 I get useful numeric results, e.g.
resp=0.00025871503616237216
for x =0.00001.
However, for 0< x < 0.00001 this method fails. With a small argument x and
var('x,y,mx')
x=0.000000001
resp=mathematica.set(mx,x)
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?
bekalphWed, 27 Nov 2019 09:30:46 -0600https://ask.sagemath.org/question/48908/SageMath cannot access Mathematicahttps://ask.sagemath.org/question/48785/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.bekalphSun, 17 Nov 2019 06:41:42 -0600https://ask.sagemath.org/question/48785/How do I save a rational matrix for Mathematica and Matlab to read?https://ask.sagemath.org/question/45141/how-do-i-save-a-rational-matrix-for-mathematica-and-matlab-to-read/Hi,
I create a rational matrix (rather large, say 1000x1000), and I want to save it in a file that can be read by Mathematica or MATLAB (with symbolic toolbox). Is there a simple way to do that?
Right now, I use
o = open('file.txt','w')
o.write(str(A))
o.close()
where A is the matrix. However, it has these "[" and "]" at the beginning of line that makes it difficult for Mathetmatica and MATLAB to read. Any suggestions would be appreciated.raykanTue, 22 Jan 2019 22:01:12 -0600https://ask.sagemath.org/question/45141/Make SageMath allow for Error of Mathematicahttps://ask.sagemath.org/question/42223/make-sagemath-allow-for-error-of-mathematica/Hello everyone!
I am currently trying on the interface of SageMath to Mathematica for the solution of polynomial equations and inequalities. Whilst doing that I came across an instance that is typical for Mathematica when solving systems of polynomial equation and inequalities. I tried to solve the system and Mathematica returned the error
> "Mathematica ERROR: Solve::ratnz:
> Solve was unable to solve the system
> with inexact coefficients.
> The answer was obtained by solving a corresponding exact system and
> numericizing the result. "
and as a result Sage raised the error and returned no solution.
I am trying to get solutions to the system:
sys={0.500000000000000*lamda2*theta3 - 3*x1^2 + 2*lamda1 - lamda3 + 5==0,lamda1 + lamda2 - lamda4 + 3*theta1 - 6*x2==0,lamda1*(theta2 + 2*x1 + x2 - 7.50000000000000)==0,(0.500000000000000*theta3*x1 + x2 - 1.50000000000000)*lamda2==0,-lamda3*x1==0,-lamda4*x2==0}
for the variables
var={x1,x2,lamda1,lamda2,lamda3,lamda4}
and a sample of the code for the solve is:
from sage.interfaces.mathematica import mathematica
sys = mathematica(sys)
var=mathematica(var)
sys.Solve(var)
Is it possible to make an exception for specific Mathematica errors so as to get the solution?
Many thanks,
Jason :)JasonKMon, 30 Apr 2018 06:45:47 -0500https://ask.sagemath.org/question/42223/Mathematica-like transformations ruleshttps://ask.sagemath.org/question/41746/mathematica-like-transformations-rules/Hey everyone!
I am currently exploring Sage's features and was wondering if there is something similar to Mathematica's replacement/transformation rules, which are (in my opinion) the strongest feature of Mathematica itself.
Thanks in advance for any answers!
PS: I would have liked to link on Wolfram's documentation page on Transformation rules but my Karma is insufficient for posting links, so in case you wonder what I mean by transformation rules, just give Google a hit.Peter WildemannSat, 24 Mar 2018 08:39:14 -0500https://ask.sagemath.org/question/41746/Mathematica misinterprets some underscored symbolic variableshttps://ask.sagemath.org/question/41666/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);
3
27000 (h_)
sage: mexpr1=mathematica((h20+h10)^3);
sage: print(mexpr1);
3
(h10 + h20)
sage: mexpr2=mathematica((h_2+h_3)^3);
sage: print(mexpr2);
3
125 (h_)
sage: mexpr3=mathematica((h_ij+h_kl)^3);
sage: print(mexpr3);
3
((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.bekalphWed, 21 Mar 2018 02:25:24 -0500https://ask.sagemath.org/question/41666/Import class using mathematicahttps://ask.sagemath.org/question/37229/import-class-using-mathematica/I have a class a in a file a.sage using the interface to mathematica. I want to use this class in another class b.
One way I found was to run first "mv a.sage a.py", which generates a python file. But then I get the error: "NameError: global name 'mathematica' is not defined" because you cannot use mathematica in python as you can use it with sage.
Is there a way importing a self-written class (a.sage) using mathematica in another self-written class (b.sage)?sageUserFri, 07 Apr 2017 12:34:45 -0500https://ask.sagemath.org/question/37229/Any way to solve this differential equation?https://ask.sagemath.org/question/36122/any-way-to-solve-this-differential-equation/ sage: x(t)=function('x')(t)
sage: x
t |--> x(t)
sage: g(v,c)=1/sqrt(1-v^2/c^2)
sage: g
(v, c) |--> 1/sqrt(-v^2/c^2 + 1)
sage: var('a')
a
sage: ode = g(diff(x,t))*diff(x,t) == a*t
sage: ode
t |--> diff(x(t), t)/sqrt(-diff(x(t), t)^2/c^2 + 1) == a*t
sage: desolve(ode,x)
Traceback (most recent call last):
...
ValueError: Unable to determine independent variable, please specify.
sage: desolve(ode,[x,t])
Traceback (most recent call last):
...
NotImplementedError: Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.
sage: desolve(ode,[x,t],contrib_ode=True)
Traceback (most recent call last):
...
NotImplementedError: Maxima was unable to solve this ODE.
I can solve it by hand.
Mathematica can solve it. But I would very much prefer to learn to use Sage because it's open source.
It looks like it is Maxima that cannot solve it. But is it possible to make Sage invoke any other open source program than Maxima? Or use some trick in defining the problem that would allow Maxima to solve it?
Thank you.omoplataThu, 29 Dec 2016 13:15:36 -0600https://ask.sagemath.org/question/36122/Does Sage have a plain math expression editor, without any calculation performed?https://ask.sagemath.org/question/35331/does-sage-have-a-plain-math-expression-editor-without-any-calculation-performed/Is there a way to edit an expression in a pretty, classical, math style without declaring variables and without evaluating?
In Mathematica we can write whatever we want using some keystroke shortcuts and it looks just as if it were hand-written. We can keep these notes in a file and re-use them (visualize, modify...) later on. The powerful feature is that we can copy and paste any part of such notes into a notebook and get it evaluated in the most straightforward way.
Can we do this in Sage?
Michel PoquerusseTue, 01 Nov 2016 15:56:19 -0500https://ask.sagemath.org/question/35331/derivative of order var('m') returns 0https://ask.sagemath.org/question/30330/derivative-of-order-varm-returns-0/ Hello,
In mathematica I can differentiate a function m times with respect to x, where m doesn't have an explicit value yet and get an expression that can be evaluated as below:
<pre>
#MATHMATICA CODE
in[0] g = x^2 + 3/2*(x^2 - 1)*x
f = D[g, {x, m}]
out[0]= ∂(x,m)(3/2x(-1+x^2))+Power(m,0)[x,2]
in[1] f /. {m -> 2}
out[1]= 2+9x
</pre>
What I believe to be the equivalent code in sage will only give me 0 instead of an expression which I could then evaluate by setting m=2:
<pre>
#Sage example 1
sage: g = x^2 + 3/2*(x^2 - 1)*x
sage: var('m')
sage: diff(g,x,m)
0
</pre>
I know it is possible to differentiate a variable number of times due to the following:
<pre>
#Sage example 2
sage: diff((x^2-1)^n,x,n)
2*(x^2 - 1)^(n - 1)*n*x*log(x^2 - 1) + 2*(x^2 - 1)^(n - 1)*x
</pre>
I think that example 2 works because I have x raised to the power n.
Is it possible to accomplish the equivalent of what I did in mathematica in sage (i.e. have example 1 not return 0)?
Alternatively if this is not possible what advice do you have for how I could work on making this functionality exist?
Thanks in advance.
ianhiWed, 28 Oct 2015 22:34:28 -0500https://ask.sagemath.org/question/30330/Calling Mathematica gives 'Read-only file system'https://ask.sagemath.org/question/29372/calling-mathematica-gives-read-only-file-system/ When I try to call Mathematica for anything (`mathematica('1')`), it comes back with
OSError: [Errno 30] Read-only file system: '/export/pkgs/linux-rh6/sagemath-6.3/local/share/sage/ext/mathematica'
Is there anything I can do to remedy this?
Calling `math` from the command line will open Mathematica.jaebondSun, 30 Aug 2015 11:15:15 -0500https://ask.sagemath.org/question/29372/full simplify, sage vs mathematicahttps://ask.sagemath.org/question/8403/full-simplify-sage-vs-mathematica/I have this somewhat lengthy, but in principal trivial expression
sage: B = 1/4*(e^(sqrt(-2*cos(l) + 2)) + 1)*(I*sin(l) -
cos(l))*e^(-1/2*sqrt(-2*cos(l) + 2)) - 1/4*sqrt(-2*cos(l) +
2)*(e^(sqrt(-2*cos(l) + 2))*sin(l)^2/sqrt(-2*cos(l) + 2) +
I*e^(sqrt(-2*cos(l) + 2))*sin(l)*cos(l)/sqrt(-2*cos(l) + 2)
- (I*e^(sqrt(-2*cos(l) + 2)) - I)*sin(l) +
(e^(sqrt(-2*cos(l) + 2)) - 1)*cos(l) - I*e^(sqrt(-2*cos(l) +
2))*sin(l)/sqrt(-2*cos(l) + 2))/(e^(1/2*sqrt(-2*cos(l) +
2))*cos(l) - e^(1/2*sqrt(-2*cos(l) + 2))) +
1/8*sqrt(-2*cos(l) + 2)*((I*e^(sqrt(-2*cos(l) + 2)) -
I)*cos(l) + (e^(sqrt(-2*cos(l) + 2)) - 1)*sin(l) -
I*e^(sqrt(-2*cos(l) + 2)) + I)*(e^(1/2*sqrt(-2*cos(l) +
2))*sin(l)*cos(l)/sqrt(-2*cos(l) + 2) -
2*e^(1/2*sqrt(-2*cos(l) + 2))*sin(l) - e^(1/2*sqrt(-2*cos(l)
+ 2))*sin(l)/sqrt(-2*cos(l) + 2))/(e^(1/2*sqrt(-2*cos(l) +
2))*cos(l) - e^(1/2*sqrt(-2*cos(l) + 2)))^2 -
1/4*((I*e^(sqrt(-2*cos(l) + 2)) - I)*cos(l) +
(e^(sqrt(-2*cos(l) + 2)) - 1)*sin(l) - I*e^(sqrt(-2*cos(l) +
2)) + I)*sin(l)/(sqrt(-2*cos(l) + 2)*(e^(1/2*sqrt(-2*cos(l)
+ 2))*cos(l) - e^(1/2*sqrt(-2*cos(l) + 2))))
My humble understanding of full_simply() is, that it will 'kind of' make the 'simplest looking' expression from that.
sage: B.full_simply()
1/8*((e^(I*sqrt(cos(l) - 1)*sqrt(2)) + 1)*cos(l)^3 -
3*(e^(I*sqrt(cos(l) - 1)*sqrt(2)) + 1)*cos(l)^2 +
3*(e^(I*sqrt(cos(l) - 1)*sqrt(2)) + 1)*cos(l) +
((-I*e^(I*sqrt(cos(l) - 1)*sqrt(2)) - I)*cos(l)^2 +
(2*I*e^(I*sqrt(cos(l) - 1)*sqrt(2)) + 2*I)*cos(l) -
I*e^(I*sqrt(cos(l) - 1)*sqrt(2)) - I)*sin(l) + sqrt(cos(l) -
1)*((I*sqrt(2)*e^(I*sqrt(cos(l) - 1)*sqrt(2)) -
I*sqrt(2))*cos(l)^2 + (-2*I*sqrt(2)*e^(I*sqrt(cos(l) -
1)*sqrt(2)) + 2*I*sqrt(2))*cos(l) +
((sqrt(2)*e^(I*sqrt(cos(l) - 1)*sqrt(2)) - sqrt(2))*cos(l) -
sqrt(2)*e^(I*sqrt(cos(l) - 1)*sqrt(2)) + sqrt(2))*sin(l) +
I*sqrt(2)*e^(I*sqrt(cos(l) - 1)*sqrt(2)) - I*sqrt(2)) -
e^(I*sqrt(cos(l) - 1)*sqrt(2)) - 1)/(e^(1/2*I*sqrt(cos(l) -
1)*sqrt(2))*sin(l)^2 + 2*e^(1/2*I*sqrt(cos(l) -
1)*sqrt(2))*cos(l) - 2*e^(1/2*I*sqrt(cos(l) - 1)*sqrt(2)))
That doesn't look too much simpler. So I compared to *Mathematica*
sage: B._mathematica_().FullSimplify()
(I*Sin[l/2]^3*(Sqrt[1 - Cos[l]]*Cosh[Sin[l/2]] -
Sqrt[2]*Sinh[Sqrt[Sin[l/2]^2]]))/(E^((I/2)*l)*(1 - Cos[l])^(3/2))
Does this imply I really have to use *Mathematica* for such things?XaverThu, 27 Oct 2011 10:38:16 -0500https://ask.sagemath.org/question/8403/Open Mathematica nb with Sagehttps://ask.sagemath.org/question/26618/open-mathematica-nb-with-sage/ Hello, I'm having troubles with opening some lectures ( created in *Mathematica* extension-.nb ) in Sage.
I used *Upload worksheet to the Sage Notebook* but there is no option for ".nb". <br/> What should I do? <br/>Thanks in advanceVladimirTue, 21 Apr 2015 17:15:40 -0500https://ask.sagemath.org/question/26618/Similar command to Mathematica's Reduce[]?https://ask.sagemath.org/question/26600/similar-command-to-mathematicas-reduce/Can one do in Sage things similar to what the Mathematica commands such as Reduce[] does? In particular, using Reduce[] in Mathematica, one can check whether a given real polynomial in several variables is positive on a semi-algebraic set. Can this be done in Sage? Iosif PinelisSun, 19 Apr 2015 14:04:15 -0500https://ask.sagemath.org/question/26600/Is it possible to convert Mathematica notebook to Sage?https://ask.sagemath.org/question/9396/is-it-possible-to-convert-mathematica-notebook-to-sage/I have been using Mathematica, now would like to switch to Sage. Is there a way that I can convert my existing Mathematica notebooks to Sage? npaSat, 06 Oct 2012 14:50:16 -0500https://ask.sagemath.org/question/9396/tab completion for mathematica failshttps://ask.sagemath.org/question/25184/tab-completion-for-mathematica-fails/Hello,
In sage 5.6 if I type mathematica and then TAB, the program hangs. I think it's probably waiting for some input from Mathematica. I can see that a Mathematica process is started. For Maple, the TAB completion works well. Can you confirm this?
I'm using 'Sage Version 6.5.beta2, Release Date: 2014-12-04'
SLTue, 09 Dec 2014 16:05:06 -0600https://ask.sagemath.org/question/25184/Cannot call Mathematica functions form Sagehttps://ask.sagemath.org/question/24941/cannot-call-mathematica-functions-form-sage/I have *Sage* 6.4 and *Mathematica* 10 installed on my computer. I was trying to call *Mathematica* functions from *Sage* in terminal. *Sage* starts properly in terminal, but it hanged every time when `mathematica()` was called. By the way, I can start *Mathematica* kernel by calling `math` in command line. I have no idea why it doesn't work. Please help me out.HanSat, 22 Nov 2014 07:13:29 -0600https://ask.sagemath.org/question/24941/Calling Sage functions from Mathematicahttps://ask.sagemath.org/question/24388/calling-sage-functions-from-mathematica/ Is it possible to call *Sage* functions from *Mathematica*?
I'm new to *Sage*. I find that some functions in *Sage* are extremely useful for me. But I'm not so used to the language in *Sage*. Instead, *Mma* is currently my main tool. So I wonder whether I can call *Sage* functions from Mathematica.HanSat, 04 Oct 2014 03:21:08 -0500https://ask.sagemath.org/question/24388/interact buttons that do stuff, not just selectorshttps://ask.sagemath.org/question/10810/interact-buttons-that-do-stuff-not-just-selectors/Is there some way to build a interact control button so that, when pressed, a designated action/program is carried out so as to produce a new result to be added to an existing display -- e.g., a button to generate a new random number and add it to an existing list, a button to add another data point to an existing scatter plot, or to eliminate an outlier, etc. An example that I could look at would be enough to get me started.
FWIW, this is what the "Button" gizmo in Mathematica does: "Button[_label_,_action_]
represents a button that is labeled with _label_, and evaluates _action_ whenever it is clicked."Tom BurkeFri, 06 Dec 2013 11:15:52 -0600https://ask.sagemath.org/question/10810/random number generator functionhttps://ask.sagemath.org/question/10802/random-number-generator-function/What is SAGE's equivalent of Mathematica's RandomReal[] function?Tom BurkeWed, 04 Dec 2013 15:28:11 -0600https://ask.sagemath.org/question/10802/interface with mathematica in notebookhttps://ask.sagemath.org/question/7777/interface-with-mathematica-in-notebook/I am transitioning from mathematica to sage. I tried running mathematica commands in the console and they work just fine as mentioned in the sage documentation. However, when I try to call mathematica from notebook it takes forever and nothing happens. It there anything more than having the 'math' command in PATH I need to do to get mathematica working in notebook. I am trying this on a OSX. Does that cause any problems?ShashankMon, 29 Nov 2010 10:06:42 -0600https://ask.sagemath.org/question/7777/How to use algorithm='mathematica free' to calculate definite integral?https://ask.sagemath.org/question/10214/how-to-use-algorithmmathematica-free-to-calculate-definite-integral/Is it possible to use algorithm='mathematica free' to calculate definite integral ?
integrate(x^2,x,algorithm='mathematica_free')
Output:
1/3*x^3
and
integrate(x^2,x,0,1,algorithm='mathematica_free')
Output:
1/3*x^3
but I want 1/3IvanGMon, 17 Jun 2013 08:46:01 -0500https://ask.sagemath.org/question/10214/calling mathematica 9.0 in sagehttps://ask.sagemath.org/question/9625/calling-mathematica-90-in-sage/Hi,
I'm trying to use Mathematica 9.0 in sage. I selected mathematica in roll-down menu and I have it installed and working (math script that calls MAthKernel) in Ubuntu.
Yet sage complaints that Mathematica is not installed:
RuntimeError: Unable to start mathematica because the command 'math' failed.
math is currently working in the terminal and it is in the standard PATH (/usr/local/bin).
Also writing
mathematica(cos(x)), for instance, doesn't work with sage selected in roll-down menu.
Any ideas of what am I missing here?
Regards
Pedro atreyvTue, 11 Dec 2012 22:46:31 -0600https://ask.sagemath.org/question/9625/Gathering sublists based on functional programming (GatherBy)https://ask.sagemath.org/question/9495/gathering-sublists-based-on-functional-programming-gatherby/Hi,
I'm looking at translating a very nice solution to the MrP and MrS puzzle.
http://mathematica.stackexchange.com/questions/13898/how-to-improve-this-code-for-solving-the-mr-s-and-mr-p-puzzle
The translation of the problem involves list comprehensions and functional programming. We can generate the tuples of solutions in the form:
possibilities = [ (i,j) for i in range(2,99) for j in range(2,i)]
Then we would like to group these possibilities into lists that have multiple factorizations...
In this case informationFilter could be a lambda function for mrP:
mrP = lambda a,b : a*b
I am having trouble finding an easy way to do the equivalent of the mathematica function: GatherBy:
GatherBy[possibilities, informationFilter]
So the question is: Given a list of tuples like :
[(3, 2), (4, 2), (4, 3), (5, 2), (5, 3), (5, 4), (6, 2), (6, 3), (6, 4), (6, 5)... (98,97)]
How would you gather them into sublists such that their products are the same...
[(4,3),(6,2)] would be one valid sublist.
Many thanks for letting me "think out loud" on this one. Apologies in advance if the answer is trivial.
./patPatBFri, 02 Nov 2012 06:13:50 -0500https://ask.sagemath.org/question/9495/Comparing Sage and Mathematica for an Introductory Coursehttps://ask.sagemath.org/question/8957/comparing-sage-and-mathematica-for-an-introductory-course/I'm working with a committee that's revising the undergraduate math curriculum for UCLA biology majors. We're getting rid of a lot of paper and pencil calculation that's hardly ever used in mathematical biology and introducing a lot of modeling, dynamical systems and computer work. Earlier, we decided to use Mathematica for the course, but I recently learned about Sage and like the idea of using a free program with similar features to Mathematica.
While the students will be learning some programming during the course, that's not our emphasis and they need to be able to use a fairly high level of interactivity from the beginning. (For example, they should be able to interactively manipulate function parameters in the first or at worst second lab session.) Since I'm very much a newcomer to Sage, I want to ask more experienced users how hard it would be to reproduce the functionality of [this Mathematica notebook](http://db.tt/d332CVVs) in Sage. I've seen the slider examples, but they use quite a bit of code. An equivalent to Equation Trekker, which allows you to specify initial condition for a two-ODE system by clicking on the phase plane, would also be very useful. Has anyone coded such a thing for Sage?jaiaSun, 06 May 2012 18:25:09 -0500https://ask.sagemath.org/question/8957/sage integration differes from Mathematicahttps://ask.sagemath.org/question/8682/sage-integration-differes-from-mathematica/Hi,
I'm trying to integrate
E(x) = a*e^(-0.5*(x/s)^2)*cos(f*x+phi)
Mathematica
A = Integrate[a Exp[-0.5 x^2/\[Sigma]^2] Cos[f x + \[Phi]], x]
gives me
0.626657 a E^(-0.5 f^2 \[Sigma]^2) \[Sigma] (Erf[(0.707107 x)/\[Sigma]+(0.+0.707107 I) f \[Sigma]] (Cos[\[Phi]]-(0.+1. I) Sin[\[Phi]])+Erfi[((0.+0.707107 I) x)/\[Sigma]+0.707107 f \[Sigma]] ((0.-1. I) Cos[\[Phi]]+Sin[\[Phi]]))
Doing
E = a*e^(-0.5*(x/s)^2)*cos(f*x+phi)
A = integrate(E, x)
Sages result is a different one (sorry, cannot copy output, but you can easily reproduce it yourself).
The difference isn't obvious at first glance (at least not to me), but you can see it doing e.g.
A /. {a -> 100, f -> 1, \[Sigma] -> 8, \[Phi] -> 0, x -> 0}
gives 3.11179*10^-15 + 0. I
and Sage
show(A(a=100, f=1, s=8, phi=0, x=0).n())
results in
1.26977421759869e10-11+101.642197289814i
The result differs at least at zero. Anyone any idea what I'm doing wrong?
Cheers!
BenBenMoonMon, 30 Jan 2012 00:22:54 -0600https://ask.sagemath.org/question/8682/Reliability of Sage vs commercial softwarehttps://ask.sagemath.org/question/8583/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.
Danielgod.oneTue, 20 Dec 2011 23:47:22 -0600https://ask.sagemath.org/question/8583/Mathematica graphics in a sage notebook - second takehttps://ask.sagemath.org/question/8405/mathematica-graphics-in-a-sage-notebook-second-take/[This](http://ask.sagemath.org/question/765/mathematica-graphics-in-a-sage-notebook) question was already asked, but the answer doesn't work for me so I was suggested that I ask it again with the specifics of my problem. So here goes. <br>
To quote [Simons's](http://ask.sagemath.org/users/58/simon/) answer:<br>
In [SAGE_ROOT/devel/sage/sage/interfaces/mathematica.py](http://hg.sagemath.org/sage-main/file/2a2abbcad325/sage/interfaces/mathematica.py#l824) you find the show() function:<br>
def show(self, filename=None, ImageSize=600):
r"""
Show a mathematica expression or plot in the Sage notebook.
EXAMPLES::
sage: P = mathematica('Plot[Sin[x],{x,-2Pi,4Pi}]') # optional - mathematica
sage: show(P) # optional - mathematica
sage: P.show(ImageSize=800) # optional - mathematica
sage: Q = mathematica('Sin[x Cos[y]]/Sqrt[1-x^2]') # optional - mathematica
sage: show(Q) # optional - mathematica
<html><div class="math">\frac{\sin (x \cos (y))}{\sqrt{1-x^2}}</div></html>
"""
I'm not sure should I use <i>sage</i> input method or <i>mathematica</i> so I'll do both.<br>
sage input method:<br>
For test that MathKernel works:
mathematica('N[Pi,10]')
returns
3.141592654
Now if I try the first example:
P = mathematica('Plot[Sin[x],{x,-2Pi,4Pi}]')
show(P)
I get nothing, it just appears to work (waiting cursor) but no output. By checking the process list on server, MathKernel is shown.<br>
<br>
Next I tried <i>mathematica</i> input method:<br>
N[Pi,10]
returns<br>
3.141592654
Test works.
Plot[Sin[x],{x,-2Pi,4Pi}]
returns
-Graphics-
EDIT: Ubuntu Server 10.04 without GUI, Mathematica 8.0, Sage 4.7.1enedeneSat, 22 Oct 2011 05:59:45 -0500https://ask.sagemath.org/question/8405/Mathematica graphics in a sage notebookhttps://ask.sagemath.org/question/8339/mathematica-graphics-in-a-sage-notebook/**Is there an easy way to get Mathematica graphics into a sage notebook?**
I have a notebook where I want to compare the Mathematica way of doing things and the related graphics to the sage way and its graphics. The naive ways of doing it do not work:
----
%mathematica
Plot[Sin[x],{x,-4,4}]
just produces
-Graphics-
While
mathematica('Plot[Sin[x],{x,-4,4}]')
returns the `InputForm` of the graphics, i.e.,
Graphics[{{{}, {}, {Hue[0.67, 0.6, 0.6], Line[{<<long list of points>>}],
<<some graphics options>>]
----
There's three work-arounds I can currently think of.
1. Export the graphics from Mathematica using: `Export["file.png", graphics]`
and import it back into sage - but I couldn't find an image import function in sage...
2. Use the JavaGraphics Mathematica package: So
![because code formatting was failing me](http://i.imgur.com/BaPvQ.png)
but this puts the graphics object in a separate window (not in the sage notebook).
3. Extract the graphics data and feed it into a sage plotting function, e.g.
list_plot(mathematica('Plot[Sin[x], {x, -4, 4}][[1, 1, 3, 2, 1]]').sage(), plotjoined = true)
which does what I want, but is a little cumbersome - especially for more complicated graphics.
SimonTue, 20 Sep 2011 17:33:54 -0500https://ask.sagemath.org/question/8339/equivalent command in sage?https://ask.sagemath.org/question/8177/equivalent-command-in-sage/Hi!
I wonder if there an equivalent command in Sage that behaves like "manipulate" in Mathematica?
Thanks,riemannTue, 21 Jun 2011 07:28:42 -0500https://ask.sagemath.org/question/8177/