Hi!

On 2017-07-03, Fjordforsk A/S <fjordfors...@gmail.com> wrote:
> Hi, how does one write 10^(-8) ?
>
> Is it as the conventional way 10**(-8) or is it 10exp(-8) ?

Sage is based on Python, thus, 10**(-8) definitely works.

In addition, Sage uses a preparser to make the user interface still
a bit nicer than Python. Therefore, 10^(-8) works as well.

I don't know if you use Sage only by its user interface, or if
you also write programs. In the former case, my answer ends here.
In the latter case, I give you a bit more background, that may help
to avoid some pitfalls in programming:

In the user interface, You can also write
        f(t) = sin(t^2)
and Sage's preparser will translate it into a sequence of commands that
defines t as a symbolic variable and f as a symbolic function

Here is what the preparser does internally:
    sage: preparse('f(t) = sin(t^2)')
    '__tmp__=var("t"); f = symbolic_expression(sin(t**Integer(2))).function(t)'

If you write a .py or .pyx module, the preparser would not be invoked,
und thus you have to write 10**(-8), whereas 10^(-8) would be interpreted
as bit-wise XOR.

And since var('t') inserts the new variable t into the global namespace, 
to define the function f(t)=sin(t^2), you have to write something like
    t = var('t')
    f = symbolic_expression(sin(t**2)).function(t)
in your code.

Here, "2" would result in a Python integer, which is not the same
as a Sage Integer. Hence, if it is important for you to use the Sage
types rather than the Python types, you have to replace 2 by Integer(2)
or ZZ(2). And of course, you have to import these things first.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to