Zulip Chat Archive

Stream: Is there code for X?

Topic: Evaluating bivariate polynomial at X


Ahmad Alkhalawi (Oct 11 2024 at 18:37):

Let p : R[X][Y]. Then I can't figure out how to substitute the X variable for something? I know you can do p.sum (fun i a => (aeval x a)*(X:K[X])^i) but is there a built-in way?

Christian Merten (Oct 11 2024 at 18:48):

I can only guess your precise setup, but you are probably looking for docs#Polynomial.map. You can then write

import Mathlib
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S]
open Polynomial

noncomputable example (p : R[X][Y]) (x : S) : S[X] :=
  map (aeval x).toRingHom p

Ahmad Alkhalawi (Oct 11 2024 at 18:51):

That seems to work, thanks

David Ang (Oct 11 2024 at 23:34):

@Ahmad Alkhalawi maybe something in https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Polynomial/Bivariate.html might help?

Ahmad Alkhalawi (Oct 12 2024 at 03:03):

David Ang said:

Ahmad Alkhalawi maybe something in https://leanprover-community.github.io/mathlib4_docs/Mathlib/Algebra/Polynomial/Bivariate.html might help?

I checked that already and couldn't find anything


Last updated: May 02 2025 at 03:31 UTC