ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 17 Aug 2013 13:51:14 +0200How to return a list from callable symbolic expressionhttps://ask.sagemath.org/question/10449/how-to-return-a-list-from-callable-symbolic-expression/I was (wrongfully) expecting the return type of all of the following function calls to be the same, namely a list. Why does the callable symbolic expression (1) return a vector, and how to rewrite (1) such that it does return a list?
# (1)
sage: f(x) = [x,x]
# (2)
sage: g = lambda x: [x,x]
# (3)
sage: def h(x):
....: return [x,x]
sage: type(f(x))
<class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
sage: type(g(x))
<type 'list'>
sage: type(h(x))
<type 'list'>
MarkSat, 17 Aug 2013 13:51:14 +0200https://ask.sagemath.org/question/10449/Getting a function from a symbolic expression (i.e. "y = x+2")https://ask.sagemath.org/question/8858/getting-a-function-from-a-symbolic-expression-ie-y-x2/Hi all,
I'm having trouble understanding how to solve the following problem. Let's say, for instance, that I have an expression
a = y - 2 == x
If I wish to solve this for y,
b = solve(a, y)
This returns another object of type Expression that looks like
"y = x + 2"
My question is, is it possible to obtain a callable symbolic expression x --> x + 2 from this result, b?
I'm trying to solve an implicit equation for a variable and obtain a plottable/differentiable etc. resultchasemeadorsThu, 05 Apr 2012 04:06:26 +0200https://ask.sagemath.org/question/8858/How to make special functions/orthogonal polynomials as callable symbolic expression.https://ask.sagemath.org/question/8446/how-to-make-special-functionsorthogonal-polynomials-as-callable-symbolic-expression/Hello,
I'd like to make some special functions/orthogonal polynomials as callable symbolic
expression. However, those functions always remind me the argument is not an integer.
var('n a x')
f(x) = gen_laguerre(n,a,x)
TypeError: unable to convert x (=n) to an integer
, and
var('n x')
g(x) = spherical_bessel_J(n, x)
TypeError: unable to convert x (=n) to an integer
Even if I tried the "domain" keyword, there's still the same problem:
var('n', domain=ZZ)
var('a x')
f(x) = gen_laguerre(n,a,x)
TypeError: unable to convert x (=n) to an integer
How do I reassure those functions that I will give integers to n later in each calculation?minihairSun, 06 Nov 2011 03:18:21 +0100https://ask.sagemath.org/question/8446/