Thanks for your reply Bruin.
I hope the following code clarifies what I am looking for:

##---------------------------------------------------------------------------------------------------------------------------------------------
#
n=10
F = GF(7)
Rx=PolynomialRing(F,n,'x')
X=Rx.gens()
f= Rx.random_element()
print(f)
#If I want to evaluate f at specific variables say x0 = 1, x5 = 7, then I 
can easily do it as
print(f(x0 = 1, x5 = 7))
#On the other hand, suppose I want to evaluate f at  xi = a, xj = b, where 
1<= i, j <= n vary. I  want to have something like
f(X[i] = 1, X[j] = 5) # and supply values of i, j as input parameters.  Is 
this possible?
#
##---------------------------------------------------------------------------------------------------------------------------------------------

For Example:  I tried this:

f(X[1] = 1, X[2] = 5) 

and got this error:

File "<ipython-input-6-3b58a4eab255>", line 10 f(X[Integer(1)] = 
Integer(1), X[Integer(2)] = Integer(5)) 
^ SyntaxError: keyword can't be an expression

On Friday, April 29, 2022 at 9:25:48 PM UTC+5:30 Nils Bruin wrote:

> Can you explain a little more about what does not work? When I try to 
> replicate your example, everything works as expected:
>
> sage: n=2
> ....: F = GF(7)
> ....: Rx=PolynomialRing(F,n,'x')
> ....: X=Rx.gens()
> sage: f=X[0]+X[1]
> sage: f(x0=1)
> x1 + 1
> sage: f(x0=1,x1=1)
> 2
>
> Alternatively you can evaluate using positional arguments: in a polynomial 
> ring there is a clear implied order on the generators, so the following is 
> unambiguous (and accepted):
>
> sage: f(1,1) #gives values for x0 and x1 in order
> 2
> On Friday, 29 April 2022 at 04:33:36 UTC-7 Ha wrote:
>
>> Hi,
>> I need to create a polynomial ring with arbitrary number of variables [n] 
>> and 
>> at some point during computation should be able to substitute values
>> for a subset of variables.   I can use the following method to generate
>> my ring:
>> ##--------------------------------------------
>> n=2
>> F = GF(7)
>> Rx=PolynomialRing(F,n,'x')
>> X=Rx.gens()
>> ##----------------------------------------------
>> But if I take an element f = x0+x1 then how to substitute values for x0 
>> and x1?
>> In general I could use f(x0 = 1, x1 = 1) but with above method this 
>> doesnot seem to work. 
>>
>> Any help is highly appreciated....
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/a706ed4d-96b2-4e17-9834-2fb3f7da68een%40googlegroups.com.

Reply via email to