Q1. How can I extract elements from a solution set?
For example, consider:
sage: x, y = var('x, y')
sage: solve([x+y==6, x-y==4], x, y)
[[x == 5, y == 1]]
How can I extract these values for x and y so that I can, for
instance, use them as the coefficients for a polynomial f(t)=x+ty so
that I have f(t)=5+1*t?
I believe the solution set is a sequence so I imagine there is some
simple command which allows one to extract the n^th term in the
sequence, no?
Q2. How can I define the set of all primes up to some limit N but
excluding 2 and multiples of some number D?
My failed attempt at this is:
sage: D=some number I define here
sage: def P(N):
A=set([])
for i in range(N+1):
if i in Primes and i/=2 and D%i>0:
P=A.add(i)
return P
I imagine the fixes to these two problems are relatively simple but I
am new to Sage and am having some teething problems. Any help would
be much appreciated. Thanks.
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org