How to use the pyromaths.outils.Polynomes.randint function in pyromaths

To help you get started, we’ve selected a few pyromaths examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pyromaths / pyromaths / src / pyromaths / ex / lycee / ExoPolynome.py View on Github external
def quest_fonctions_rationnelles():
    from pyromaths.classes.Fractions import Fraction
    from pyromaths.outils import Priorites3

    nomf = ['f', 'g', 'h', 'k'][randrange(4)]
    var = ['t', 'x'][randrange(2)]
    X = Polynome({1:1}, var)
    # intervalle pour les racines entières ou fractionnaire

    rac_min = -9
    rac_max = 9
    b1 = b2 = a1 = a2 = 0
    while b1 == 0 or b2 == 0 or a1 == 0 or a2 == 0:
        b1 = randint(rac_min, rac_max)
        b2 = randint(rac_min, rac_max)
        a1 = randint(-5, 5)
        a2 = randint(-5, 5)
    P = a1 * X + b1
    Q = a2 * X + b2

    borneinf = -10
    bornesup = 10
    racine = eval(Priorites3.priorites("-%r/%r" % (Q[0], Q[1]))[-1][0])
    # Je veux que f soit définie et dérivable sur I=Intervalle
    if (racine >= borneinf) and (racine <= bornesup):
        if (racine - borneinf) < (bornesup - racine):
            Intervalle = [int(round(racine)) + 1, bornesup]
        else:
            Intervalle = [borneinf, int(round(racine)) - 1]
    else:
        Intervalle = [borneinf, bornesup]
github Pyromaths / pyromaths / src / pyromaths / ex / lycee / ExoPolynome.py View on Github external
def quest_fonctions_rationnelles_sur_R():
    from pyromaths.classes.Fractions import Fraction

    nomf = ['f', 'g', 'h', 'k'][randrange(4)]
    var = ['t', 'x'][randrange(2)]
    X = Polynome({1:1}, var)
    # intervalle pour les racines entières ou fractionnaire

    rac_min = -9
    rac_max = 9
    b1 = b2 = a1 = a2 = 0
    while b1 == 0 or b2 == 0 or a1 == 0 or a2 == 0 or a1 * (-float(b2) / a1) + b1 == 0 or (a1 * b2 / a2 - b1) == 0:
        # (a1*b2/a2 - b1)==0 on teste que la racine de Q n'annule pas P donc on ne peut pas simplifier
        b1 = randint(rac_min, rac_max)
        b2 = randint(rac_min, rac_max)
        a1 = randint(-5, 5)
        a2 = randint(-5, 5)
    P = a1 * X + b1
    Q = a2 * X + b2

    borneinf = float("-inf")
    bornesup = float("+inf")
    Intervalle = [borneinf, bornesup]
#     TeXintervalle = "\\mathbb R"

    # dérivée
    numerateur = "%s\\times%s-%s\\times%s" % (P.derive().TeX(parenthese=True), Q.TeX(parenthese=True),
                                          P.TeX(parenthese=True), Q.derive().TeX(parenthese=True))
    numerateur_simplifie = (P.derive() * Q - P * Q.derive()).simplifie()
    # VI = (-Q[0] * Fraction(1) / Q[1]).simplifie()
github Pyromaths / pyromaths / src / pyromaths / ex / lycee / ExoPolynome.py View on Github external
def quest_fonctions_rationnelles():
    from pyromaths.classes.Fractions import Fraction
    from pyromaths.outils import Priorites3

    nomf = ['f', 'g', 'h', 'k'][randrange(4)]
    var = ['t', 'x'][randrange(2)]
    X = Polynome({1:1}, var)
    # intervalle pour les racines entières ou fractionnaire

    rac_min = -9
    rac_max = 9
    b1 = b2 = a1 = a2 = 0
    while b1 == 0 or b2 == 0 or a1 == 0 or a2 == 0:
        b1 = randint(rac_min, rac_max)
        b2 = randint(rac_min, rac_max)
        a1 = randint(-5, 5)
        a2 = randint(-5, 5)
    P = a1 * X + b1
    Q = a2 * X + b2

    borneinf = -10
    bornesup = 10
    racine = eval(Priorites3.priorites("-%r/%r" % (Q[0], Q[1]))[-1][0])
    # Je veux que f soit définie et dérivable sur I=Intervalle
    if (racine >= borneinf) and (racine <= bornesup):
        if (racine - borneinf) < (bornesup - racine):
            Intervalle = [int(round(racine)) + 1, bornesup]
        else:
            Intervalle = [borneinf, int(round(racine)) - 1]
    else:
        Intervalle = [borneinf, bornesup]
github Pyromaths / pyromaths / src / pyromaths / ex / lycee / ExoPolynome.py View on Github external
from pyromaths.classes.Fractions import Fraction

    nomf = ['f', 'g', 'h', 'k'][randrange(4)]
    var = ['t', 'x'][randrange(2)]
    X = Polynome({1:1}, var)
    # intervalle pour les racines entières ou fractionnaire

    rac_min = -9
    rac_max = 9
    b1 = b2 = a1 = a2 = 0
    while b1 == 0 or b2 == 0 or a1 == 0 or a2 == 0 or a1 * (-float(b2) / a1) + b1 == 0 or (a1 * b2 / a2 - b1) == 0:
        # (a1*b2/a2 - b1)==0 on teste que la racine de Q n'annule pas P donc on ne peut pas simplifier
        b1 = randint(rac_min, rac_max)
        b2 = randint(rac_min, rac_max)
        a1 = randint(-5, 5)
        a2 = randint(-5, 5)
    P = a1 * X + b1
    Q = a2 * X + b2

    borneinf = float("-inf")
    bornesup = float("+inf")
    Intervalle = [borneinf, bornesup]
#     TeXintervalle = "\\mathbb R"

    # dérivée
    numerateur = "%s\\times%s-%s\\times%s" % (P.derive().TeX(parenthese=True), Q.TeX(parenthese=True),
                                          P.TeX(parenthese=True), Q.derive().TeX(parenthese=True))
    numerateur_simplifie = (P.derive() * Q - P * Q.derive()).simplifie()
    # VI = (-Q[0] * Fraction(1) / Q[1]).simplifie()
    #===========================================================================
    # print "A simplifier : ", priorites('-%r*Fraction(1)/%r' % (Q[0], Q[1]))[-1][0]
    #===========================================================================
github Pyromaths / pyromaths / src / pyromaths / ex / lycee / ExoPolynome.py View on Github external
def quest_variation_degre3(borneinf=float("-inf"), bornesup=float("+inf")):
    '''Question qui propose l'étude du sens de variation d'un polynôme de degré 3'''
#     Intervalle = [borneinf, bornesup]
    if borneinf == float("-inf") and bornesup == float("+inf"):
        TeX_intervalle = "\\mathbb R"
    else:
        TeX_intervalle = "\\left[%s~;~%s\\right]" % (TeX(borneinf), TeX(bornesup))
    # intervalle pour les racines entières ou fractionnaire
    a = 3 * randint(1, 3)
    rac_min = -9
    rac_max = 9
    # denominateur maximmum pour les racines fractionnaires
#     denom_max = denom1 = 12
    # Valeurs absolues maximales des coefficients d'un polynôme quelconque
#     abs_a = 6
#     abs_b = 10
    abs_c = 10
    # X est le polynome P=x pour faciliter la construction des polynômes,
#     inconnues = ['x', 'y', 'z', 't']
#     nom_poly = ['P', 'Q', 'R', 'S']
    var = "x"
    X = Polynome({1:1}, var=var)
    nomP = ["f", "g", "h", "k", "p", "q"][randrange(6)]
    Pprime = poly_racines_entieres(rac_min, rac_max, X, a1=a)
    P = Pprime.primitive() + randint(-abs_c, abs_c)
github Pyromaths / pyromaths / src / pyromaths / ex / lycee / ExoPolynome.py View on Github external
def quest_fonctions_rationnelles_sur_R():
    from pyromaths.classes.Fractions import Fraction

    nomf = ['f', 'g', 'h', 'k'][randrange(4)]
    var = ['t', 'x'][randrange(2)]
    X = Polynome({1:1}, var)
    # intervalle pour les racines entières ou fractionnaire

    rac_min = -9
    rac_max = 9
    b1 = b2 = a1 = a2 = 0
    while b1 == 0 or b2 == 0 or a1 == 0 or a2 == 0 or a1 * (-float(b2) / a1) + b1 == 0 or (a1 * b2 / a2 - b1) == 0:
        # (a1*b2/a2 - b1)==0 on teste que la racine de Q n'annule pas P donc on ne peut pas simplifier
        b1 = randint(rac_min, rac_max)
        b2 = randint(rac_min, rac_max)
        a1 = randint(-5, 5)
        a2 = randint(-5, 5)
    P = a1 * X + b1
    Q = a2 * X + b2

    borneinf = float("-inf")
    bornesup = float("+inf")
    Intervalle = [borneinf, bornesup]
#     TeXintervalle = "\\mathbb R"

    # dérivée
    numerateur = "%s\\times%s-%s\\times%s" % (P.derive().TeX(parenthese=True), Q.TeX(parenthese=True),
                                          P.TeX(parenthese=True), Q.derive().TeX(parenthese=True))
    numerateur_simplifie = (P.derive() * Q - P * Q.derive()).simplifie()
    # VI = (-Q[0] * Fraction(1) / Q[1]).simplifie()
    #===========================================================================
    # print "A simplifier : ", priorites('-%r*Fraction(1)/%r' % (Q[0], Q[1]))[-1][0]
github Pyromaths / pyromaths / src / pyromaths / ex / lycee / ExoPolynome.py View on Github external
rac_min = -9
    rac_max = 9
    # denominateur maximmum pour les racines fractionnaires
#     denom_max = denom1 = 12
    # Valeurs absolues maximales des coefficients d'un polynôme quelconque
#     abs_a = 6
#     abs_b = 10
    abs_c = 10
    # X est le polynome P=x pour faciliter la construction des polynômes,
#     inconnues = ['x', 'y', 'z', 't']
#     nom_poly = ['P', 'Q', 'R', 'S']
    var = "x"
    X = Polynome({1:1}, var=var)
    nomP = ["f", "g", "h", "k", "p", "q"][randrange(6)]
    Pprime = poly_racines_entieres(rac_min, rac_max, X, a1=a)
    P = Pprime.primitive() + randint(-abs_c, abs_c)
    P = P.simplifie()
    exo = [_(u"\\item Étudier le sens de variations de $%s$ définie par $%s(x)=%s$ sur $%s$.") % (nomP, nomP, P(var), TeX_intervalle)]
    cor = [_(u"\\item Étudier le sens de variations de $%s$ définie par $%s(x)=%s$ sur $%s$.") % (nomP, nomP, P(var), TeX_intervalle)]

    cor.append("\\par $%s'(x)=%s$\\\\" % (nomP, Pprime(var)))
    cor.append(_(u"Je dois étudier le signe de $%s'(%s)$ qui est un polynôme du second degré.\\par") % (nomP, var))

    delta, simplrac, racines, str_racines, factorisation = factorisation_degre2(Pprime, factorisation=False)
    # cor=redaction_factorisation(Pprime,nomP+"'",exo=[],cor=cor)[1]
    # cor.pop(-5)
    redaction_racines(Pprime, nomP + "'", var, cor)
    str_variables, str_signes, str_valeurs, signes, ligne_valeurs = tableau_de_signe(Pprime, nomP + "'", delta, racines, cor, borneinf, bornesup, detail=True)

    # cor.append(tab_signe)
github Pyromaths / pyromaths / src / pyromaths / ex / lycee / ExoPolynome.py View on Github external
def quest_fonctions_rationnelles_sur_R():
    from pyromaths.classes.Fractions import Fraction

    nomf = ['f', 'g', 'h', 'k'][randrange(4)]
    var = ['t', 'x'][randrange(2)]
    X = Polynome({1:1}, var)
    # intervalle pour les racines entières ou fractionnaire

    rac_min = -9
    rac_max = 9
    b1 = b2 = a1 = a2 = 0
    while b1 == 0 or b2 == 0 or a1 == 0 or a2 == 0 or a1 * (-float(b2) / a1) + b1 == 0 or (a1 * b2 / a2 - b1) == 0:
        # (a1*b2/a2 - b1)==0 on teste que la racine de Q n'annule pas P donc on ne peut pas simplifier
        b1 = randint(rac_min, rac_max)
        b2 = randint(rac_min, rac_max)
        a1 = randint(-5, 5)
        a2 = randint(-5, 5)
    P = a1 * X + b1
    Q = a2 * X + b2

    borneinf = float("-inf")
    bornesup = float("+inf")
    Intervalle = [borneinf, bornesup]
#     TeXintervalle = "\\mathbb R"

    # dérivée
    numerateur = "%s\\times%s-%s\\times%s" % (P.derive().TeX(parenthese=True), Q.TeX(parenthese=True),
                                          P.TeX(parenthese=True), Q.derive().TeX(parenthese=True))
    numerateur_simplifie = (P.derive() * Q - P * Q.derive()).simplifie()
    # VI = (-Q[0] * Fraction(1) / Q[1]).simplifie()
    #===========================================================================