Ask Your Question

td01's profile - activity

2021-12-11 17:59:39 +0100 received badge  Notable Question (source)
2020-05-13 20:03:56 +0100 received badge  Popular Question (source)
2013-09-29 11:43:04 +0100 commented question Difficulty with sagetex

Thanks again, went over a Python tutorial again and got to grips with indentation and a after a little experimentation found the 4 spaces for myself and all going well now! Thanks.

2013-09-25 18:56:18 +0100 received badge  Scholar (source)
2013-09-25 18:56:18 +0100 marked best answer Difficulty with sagetex

I think your problem is indentation. This document works for me. Remember that indentation is syntax for Python.

%!TEX TS-program = sage
\documentclass[12pt]{article}
%In case I ever wanted to do horizontally
%\usepackage[landscape]{geometry}
\usepackage{amsmath,amssymb}
\usepackage[pdftex]{graphicx}
\usepackage{sagetex}


\begin{document}

\begin{sagesilent}
def nmax(max=100):
    n = 1
    an = 20
    while n <= max:
          yield an
          n += 1
          an = 0.9*an-5

a = nmax(30)
S=[]
for i in a:
     S.append(i.n())
\end{sagesilent}

$\sage{S}$

\end{document}
2013-09-25 18:55:50 +0100 commented question Difficulty with sagetex

Many thanks kcrisman, works for me too now! Am going to have to study the indentation a bit more when typing into sagetex. Thanks a lot for your speedy response.

2013-09-25 16:23:39 +0100 asked a question Difficulty with sagetex

Please forgive any short comings as I am new to sage, python and sagetex, perhaps I'm trying to run before I can walk or even crawl!

I am trying to run the the sageblock below to obtain the sequence 'S' and reference individual elements of the list 'S'. It works fine in Sage but cannot get any where with sagetex.

    \begin{sagesilent}
    def nmax(max=100):
        n = 1
        an = 20
       while n <= max:
          yield an
          n += 1
          an = 0.9*an-5

          a = nmax(30)
          S=[]
          for i in a:
          S.append(i.n())
\end{sagesilent}

produces the error

** Error in Sage code on line 36 of sequences01.tex! Traceback follows. Traceback (most recent call last):
File "sequences01.sagetex.py", line 43, in <module> _st_.inline(_sage_const_3 , latex(S)) NameError: name 'S' is not defined

When I try to access 'S' with $\sage{S}$, am beginning to feel at a loss as to where to look now.