Zulip Chat Archive

Stream: new members

Topic: rational functions


Callum Cassidy-Nolan (Apr 10 2022 at 22:54):

Hi, I was wondering if we have the definition for rational function in mathlib.

For my purposes I have been using:

   (P Q : polynomial ), f = (λ x, P.eval x / Q.eval x)  Q.degree  0

Yaël Dillies (Apr 10 2022 at 22:55):

docs#ratfunc

Callum Cassidy-Nolan (Apr 10 2022 at 23:04):

Since f : R to R then if I try to say ∃ (r : ratfunc ℝ), f = r it doesn't work out since r has type ratfunc R. What's a good way of stating that they are in fact equal?

Yaël Dillies (Apr 10 2022 at 23:07):

You want docs#ratfunc.eval

Callum Cassidy-Nolan (Apr 10 2022 at 23:10):

theorem dumbtest
  (f :   (  )) :
   (r : ratfunc ), r.eval = f 28 := sorry

But lean says:

type mismatch at application
  ratfunc.eval r
term
  r
has type
  ratfunc  : Type
but is expected to have type
  ?m_1 →+* ?m_2 : Type (max ? ?)

Yaël Dillies (Apr 10 2022 at 23:10):

Yeah, you need λ x, f.eval (ring_hom.refl _) x

Kyle Miller (Apr 10 2022 at 23:14):

Caveat: when you evaluate a rational function at a pole, it's going to be junk data (0 I believe), and this will be saying f has the exact same behavior at these points.

Callum Cassidy-Nolan (Apr 10 2022 at 23:15):

I tried modifying dumbtest to use that but It didn't work for me, can you give a MWE version of dumbtest?

Kevin Buzzard (Apr 10 2022 at 23:25):

can you make a MWE of the question first (ie post code with the right imports etc?)

Callum Cassidy-Nolan (Apr 10 2022 at 23:28):

Yes:

import data.real.basic
import field_theory.ratfunc

theorem dumbtest
  (f :   (  )) :
   (r : ratfunc ), r.eval = f 28 := sorry

Kevin Buzzard (Apr 11 2022 at 00:46):

import data.real.basic
import field_theory.ratfunc

theorem dumbtest
  (f :   (  )) :
   (r : ratfunc ),  x, r.eval (ring_hom.id _) x = f 28 x := sorry

Last updated: Dec 20 2023 at 11:08 UTC