Ask Your Question
0

How to display a function with the values of the variables?

asked 2013-04-23 15:49:47 +0100

anonymous user

Anonymous

updated 2015-01-14 14:21:18 +0100

FrédéricC gravatar image

For the generation of worksheets I need to know, if its possible to show a function with the assigned values? What could be a process to do that?

My hope is to generate a output like: (lamda_z,s_k) |--> lambda_z * s_k = 5 * 4 = 20

\begin{sagesilent}
tension (lambda_z, s_k) = lambda_z * s_k
lambda_za = 5
s_ka = 4

\end{sagesilent}
$ \sage {tension (lambda_za, s_ka)}$
\end{document}

thank you

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2013-04-26 14:54:05 +0100

Jason Grout gravatar image

How about something like:

\begin{sagesilent}
tension (lambda_z, s_k) = lambda_z * s_k
lambda_za = 5
s_ka = 4

\end{sagesilent}
$ \sage {tension} = \sage{tension (lambda_za, s_ka)}$
\end{document}

You won't get the 5*4 output, but you'll get the definition of the function, at least.

edit flag offensive delete link more
0

answered 2013-04-28 07:20:05 +0100

slelievre gravatar image
\documentclass[a4paper]{article}

\usepackage{amsmath}
\usepackage{sagetex}

\newcommand{\tension}{\operatorname{tension}}

\begin{document}
\pagestyle{empty}

\begin{sagesilent}
tension(lambda_z, s_k) = lambda_z * s_k
lambda_za = 5
s_ka = 4
s = str(tension(lambda_z,s_k))
ss = s.replace('lambda_z','\lambda_z')
sss = s.replace('lambda_z',str(lambda_za)).replace('s_k',str(s_ka))
\end{sagesilent}

Evaluating the function
$$\tension : \sage{tension}$$
at the values
$$\lambda_z = \sage{lambda_za},\quad s_k = \sage{s_ka},$$
step by step:
$$\tension(\lambda_z,s_k) = \sagestr{ss} = \sagestr{sss} = 
\sage{tension(lambda_za,s_ka)}.$$

\end{document}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-04-23 15:49:47 +0100

Seen: 487 times

Last updated: Apr 28 '13