`.sagews`

worksheetsThis discussion is prompted by CoCalc issue #54:

This file is shared at:

The first thing to do is to use the `%default_mode`

magic to set the whole worksheet to Maxima mode.

(Note: it's important to put this magic command in its own cell.)

We can now use Maxima syntax.

sqrt(3)/2

cos(x)^2+1

x*log(x)-x

`%`

For example, the mathematical constants $\pi$ and $e$ are represented by `%pi`

and
`%e`

in Maxima, but here starting a cell with `%`

is interpreted as a cell magic.

Similarly, one would normally get numerical expression for $\pi$ and $e$ by evaluating the following in Maxima:

```
%pi, numer
%e, numer
```

<string>:1: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
See http://trac.sagemath.org/5930 for details.
Error in lines 1-1
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1234, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1324, in execute_with_code_decorators
code = code_decorator(code)
File "sage/symbolic/expression.pyx", line 5447, in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:33873)
return self._parent._call_element_(self, *args, **kwds)
File "sage/symbolic/ring.pyx", line 977, in sage.symbolic.ring.SymbolicRing._call_element_ (build/cythonized/sage/symbolic/ring.cpp:11660)
raise ValueError("the number of arguments must be less than or equal to %s"%len(vars))
ValueError: the number of arguments must be less than or equal to 0

Error in lines 1-1
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1234, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1324, in execute_with_code_decorators
code = code_decorator(code)
File "sage/symbolic/expression.pyx", line 5447, in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:33873)
return self._parent._call_element_(self, *args, **kwds)
File "sage/symbolic/ring.pyx", line 977, in sage.symbolic.ring.SymbolicRing._call_element_ (build/cythonized/sage/symbolic/ring.cpp:11660)
raise ValueError("the number of arguments must be less than or equal to %s"%len(vars))
ValueError: the number of arguments must be less than or equal to 0

Error in lines 1-1
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1234, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1324, in execute_with_code_decorators
code = code_decorator(code)
TypeError: 'tuple' object is not callable

Error in lines 1-1
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1234, in execute
flags=compile_flags), namespace, locals)
File "", line 1, in <module>
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1324, in execute_with_code_decorators
code = code_decorator(code)
TypeError: 'tuple' object is not callable

Working around the problem is easy: it is enough to put something before the `%pi`

, `%e`

,
or other `%`

-expression, so that `%`

is no longer the first character in the cell,
and thus does not get interpreted as a cell magic.

For example,

- introduce an initial space in the compute cell before the
`%`

expression, or - introduce an initial blank line in the compute cell before the
`%`

expression, or - introduce an initial comment in the compute cell before the
`%`

expression.

These three are illustrated below.

3.141592653589793

2.718281828459045

3.141592653589793

2.718281828459045

3.141592653589793

2.718281828459045