Transition from Mathematica to SAGE

203 views
Skip to first unread message

valer...@gmail.com

unread,
Jan 18, 2017, 5:17:17 PM1/18/17
to sage-cloud
I apologize if this has been discussed already. I tried to search the group but with no results.

I am new to SAGE but I have used Mathematica for a long time. I wonder if there is a sort of "dictionary" Mathematica->SAGE that will allow me to quickly find how to do with SAGE what I already know how to do with Mathematica.

For example, right now I would like to know how long a computation takes. In Mathematica, this is done with the command Timing[computation]. How can it be done in SAGE?

Of course there are plenty of other Mathematica commands that I would like to "translate" to SAGE, and while the already available help pages and tutorials help, it always takes me some time to find out how to do what I already know how to do instantly in Mathematica.

Thank you for any help or suggestions.






William Stein

unread,
Jan 18, 2017, 10:01:10 PM1/18/17
to sage-cloud
There is no such list.  Make a list of questions and we would love to answer all of them!

E.g., the first answer is:

%time computation

to time it once, and 

%timeit computation

to run many timings and provide an average.

You can also do

---
%time
a bunch
of code in a cell
---

and


---
%timeit
a bunch
of code in a cell
---

in a Sage worksheet.


---

Regarding 2d and 3d graphics, things are much like mathematica, except use lowercase and underscores and parenthesis, so 

  ContourPlot[y^2 + 1 - x^3 - x, {y, -pi, pi}, {x, -pi, pi}]

becomes

%var x, y
contour_plot(y^2 + 1 - x^3 - x, (y,-pi,pi), (x,-pi,pi))

Note that you have explicitly declare x and y to be symbolic variables.

Type contour_plot? to learn a lot about contour_plot, and see tons of examples.  Also, a good way to find sage docs is to google for "sage" and "something else"...

-- William

--


You received this message because you are subscribed to the Google Groups "sage-cloud" group.


To unsubscribe from this group and stop receiving emails from it, send an email to sage-cloud+unsubscribe@googlegroups.com.


To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/3cabe2b1-2322-4e0d-8adf-2feba0a7a9a9%40googlegroups.com.


For more options, visit https://groups.google.com/d/optout.


Screen Shot 2017-01-18 at 6.57.28 PM.png

valer...@gmail.com

unread,
Jan 20, 2017, 5:45:43 AM1/20/17
to sage-cloud
Thank you. I will be sure to post my questions here...
To unsubscribe from this group and stop receiving emails from it, send an email to sage-cloud+...@googlegroups.com.

valer...@gmail.com

unread,
Feb 3, 2017, 12:46:38 PM2/3/17
to sage-cloud
Following up on my earlier post, here are a couple of examples of how I use Mathematica and would like to know the right way to do it in SAGE (I actually know how to do the first one in SAGE, but probably not in the best way):
1) Finding the intersection of a generic tangent line to f(x) with f(x):
f[x_]:= x^2(x^2-1)
L[a_,x_]:=f[a]+f'[a](x-a)
Solve[L[a,x]==f[x],x]

2) Testing if |f(z)| < f(|z|) for various choices of f:
Pl[f_,r_]:=Plot[Abs[f[r Exp[I t]]]/f[r],{t,0,2Pi}]

Thanks for any suggestions.

William Stein

unread,
Feb 4, 2017, 9:40:34 AM2/4/17
to sage-cloud
Hi,

Since these questions have nothing really to do with SageMath*Cloud*
itself, I think you'll get much quicker and better responses at

https://groups.google.com/forum/#!forum/sage-support
> https://groups.google.com/d/msgid/sage-cloud/24c81ab5-9e89-4849-8a2a-07dc1ca96f6b%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Best Regards,
William Stein

CEO, SageMath, Inc.

valer...@gmail.com

unread,
Feb 4, 2017, 3:26:31 PM2/4/17
to sage-cloud
thanks, I will post them there
Reply all
Reply to author
Forward
0 new messages