ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 01 Apr 2016 16:11:17 -0500Symbolic solvehttp://ask.sagemath.org/question/8707/symbolic-solve/Following the [change of variable thread](http://ask.sagemath.org/question/1113/change-of-variable-in-an-integration), I wanted to streamline the whole process.
Namely, using the same example in the above thread, I'd like to say
integral_def_change(x*cos(x^2+1), (x, 0, 2*pi), u==x^2+1, u)
The difference is, I wanted also Sage to automatically solve for x instead of providing x= sqrt(u-1), say. But when I tried
solve(u==x^2+1, x)[0].rhs()
the output was `r1` ???
1- What exactly is r1 ??
A way out (see this [thread](http://ask.sagemath.org/question/1105/solve-and-calculate)) seems to make of the solution a function of `u`
f(u)=solve(u==x^2+1, x)[0].rhs()
Now f is
u |--> -sqrt(u - 1)
2- What can I do to get +sqrt(u - 1) instead? Is this related to the [positive function question there](http://ask.sagemath.org/question/989/is-it-possible-to-define-or-assume-a-general)?Green diodSat, 11 Feb 2012 04:56:41 -0600http://ask.sagemath.org/question/8707/Getting symbolic variable without resetting python variable.http://ask.sagemath.org/question/32949/getting-symbolic-variable-without-resetting-python-variable/When calling
var('x')
the variable x gets set to the symbolic expression x just as if we had called
x = var('x')
In particular, any value stored in x is deleted. Is there a way to get a symbolic variable without setting the python variable to be that symbolic variable? I'm not super familiar with how sage handles symbolic variables so this might be unreasonable.rlg23Fri, 01 Apr 2016 16:11:17 -0500http://ask.sagemath.org/question/32949/How to do symbolic computation with quaternionshttp://ask.sagemath.org/question/9730/how-to-do-symbolic-computation-with-quaternions/I need to do symbolic computations with quaternions. Ideally I'd like to enter something like
Q.<i,j,k> = QuaternionAlgebra(QQ,-1,-1)
a=var('a')
b=var('b')
c=var('c')
q = a*i+b*j+c*k
But it doesn't work : TypeError: unsupported operand parent(s) for '*': 'Symbolic Ring' and 'Quaternion Algebra (-1, -1) with base ring Rational Field'
Looks like SAGE doesn't know how to multiply a variable and a quaternion. Or should I specify the types of the variables ? How ?
Thanks for your help.
Gilles FalquetMon, 21 Jan 2013 20:37:05 -0600http://ask.sagemath.org/question/9730/Declaring variable to be in a particular field/ring/grouphttp://ask.sagemath.org/question/25037/declaring-variable-to-be-in-a-particular-fieldringgroup/Is it possible to have Sage symbolically simplify expressions involving variables subject to the assumption that the variables take values in a defined domain (field/ring/group/etc)?
The closest I've gotten is to declare a dummy polynomial ring over my domain of interest so that its variable has some notion of the domain, e.g.:
<pre>Z3=Integers(3)
Dummy.<x> = PolynomialRing(Z3)
3*x</pre>
evaluates to "0" as I'd expect, but sage fails to simplify "x^3" to "x", which ISTM should be doable if it really understood that x is a variable in Z/3Z.
Related things I've found in my searches that haven't panned out:<br/>
1. var('x', domain=*foo*) -- apparently *foo* can only be one of real/complex/positive (where I'd like to be able to say 'Z3' in the example above)<br/>
2. assume('x is Z3') - doesn't seem to have any effect.a1846583Fri, 28 Nov 2014 10:44:44 -0600http://ask.sagemath.org/question/25037/Symbolic variables in loopshttp://ask.sagemath.org/question/23776/symbolic-variables-in-loops/Hi,
I got a list of symbolic variables defined like this:
P = list(var('P_%d' % i) for i in range(2*n + 1))
But when I try to manipulate these Variables in a for-loop like:
for k in range(2,n + 2,2):
print(P_k)
I'll get an error "NameError: name 'P_k' is not defined"
I'm guessing there is no k in P_k because its one entity 'P_k' :-D
But I hope it's possible to fix this by using "%" like in the definition above.
Anyone knows how to?
ThanksToreroThu, 14 Aug 2014 06:43:42 -0500http://ask.sagemath.org/question/23776/Eliminating variables from a system of equations?http://ask.sagemath.org/question/9582/eliminating-variables-from-a-system-of-equations/I'm (very) new to Sage, but am confused about why I can't get it to solve a simple system like this:
var('x, y, z')
eqns = [ x^2 + y^2 == z, x == y]
but solve(eqns, z) gives an empty list back instead of my desired z = 2y^2
PatrickSurryWed, 28 Nov 2012 12:10:00 -0600http://ask.sagemath.org/question/9582/check if symbolic expression contains a variablehttp://ask.sagemath.org/question/8951/check-if-symbolic-expression-contains-a-variable/check if symbolic expression contains a given variable
Is there a function or method that tests a symbolic expression
<type 'sage.symbolic.expression.Expression'>
to see if it contains a particular variable?
For example to test
y(x) == -3/(x^3 + 3*c + 3*x)
to see if it contains the variable c.
(I'm trying to write a a program to automatically plot the return value of the differential equation function desolve(), and it would help to be able to detect if the return expression contains the 'arbitrary constant' c.)
leonardoFri, 04 May 2012 07:38:37 -0500http://ask.sagemath.org/question/8951/Symbolic variable declarationhttp://ask.sagemath.org/question/8251/symbolic-variable-declaration/what is the difference, when I declare variable like this
a, b, c = var('a, b, c')
or just like this
var('a, b, c')
?OndraSun, 31 Jul 2011 06:57:48 -0500http://ask.sagemath.org/question/8251/