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, 30 Jan 2016 21:46:43 +0100Symbolic solvehttps://ask.sagemath.org/question/8707/symbolic-solve/Following the [change of variable thread](http://ask.sagemath.org/question/1113),
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))
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)?Green diodSat, 11 Feb 2012 11:56:41 +0100https://ask.sagemath.org/question/8707/Please Append 'solve' Help Documentationhttps://ask.sagemath.org/question/32387/please-append-solve-help-documentation/ Hello,
I have been using SAGE for about 2 years, and only now have I finally figured out how to get the 'solve()' function to print out its solutions in plain form (so I can save the answers as variables, which is EXTREMELY important for me).
In order to do this: I had to sift through the help pages for 'solve', Programming -- Data Types (for both Lists and Dictionaries), and Python's official documentation on Lists and Dictionaries; until I finally figured out that you need to use the code:
print( 'listname' [ ' dict # ' ] [ 'var' ])
Now this may seem very elementary to those whom are fluent in Python, but for general users (like me): there is absolutely no clear indication on how to call one or several elements of several Dictionaries inside of a List.
PLEASE append your documentation so that people can actually use the 'solve' function without having to copy and paste the answers because it isn't shown how to properly use the output when 'solution_dict=true'.
(Note: if you're thinking about the 'for' loop example in the help documentation: it's completely useless for someone who needs to select one or more of those solutions & save them as variables).
Thank you.BLU7211Sat, 30 Jan 2016 21:46:43 +0100https://ask.sagemath.org/question/32387/variables get deleted after calulation, overflow?https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/Hello and happy 1000 questions,
I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code
var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
Errorcode:
Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.
god.oneWed, 11 Jan 2012 08:43:10 +0100https://ask.sagemath.org/question/8619/Finding integer solutions to systems of polynomial equationshttps://ask.sagemath.org/question/8360/finding-integer-solutions-to-systems-of-polynomial-equations/Hi,
I am trying to do something very simple but have been struggling.
Here is a simplified example that I can't get to work. I want to define polynomials with integer coefficients, say
f(A,B) = A+B,
g(A,B) = a*A+b*B,
where I want to assume that a and b are intgers. I want the solver to give me the values of a and b so that f-g is equal to zero as a polynomial in A and B. So, I want it to give me a== 1, b== 1.
I have tried something like this-
R.< A,B > = ZZ[]
f = A+B
var('a', domain = ZZ)
var('b', domain = ZZ)
g = a*A+b*B
solve(f-g==0,a,b),
but what it gives me is [a == -((b-1)*B-A)/A, [1]].
How do I define variables a and b which are integers, but unknown integers? No matter what I seem to do, they are put in Symbolic Ring. How do I get the solve command to give me integer solutions to a set of linear equations?NathanFri, 07 Oct 2011 12:52:03 +0200https://ask.sagemath.org/question/8360/