How to use the pyromaths.outils.Arithmetique.signe 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 / troisiemes / fractions.py View on Github external
def decomp_prod(a, b):  #renvoie un tuple contenant les deux fractions apres simplification et un tuple contenant les nb par lesquels on

    #simplifie le produit de fractions

    c = pgcd(a[0], b[1])
    d = pgcd(a[1], b[0])
    sgn1 = signe(a[1])
    sgn2 = signe(b[1])
    if c == d == 1:
        return (((sgn1 * a[0]) // c, (sgn1 * a[1]) // d), ((sgn2 * b[0]) //
                d, (sgn2 * b[1]) // c), '')
    else:
        return (((sgn1 * a[0]) // c, (sgn1 * a[1]) // d), ((sgn2 * b[0]) //
                d, (sgn2 * b[1]) // c), (c, d))
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github external
def decomp_prod(a, b):  #renvoie un tuple contenant les deux fractions apres simplification et un tuple contenant les nb par lesquels on

    #simplifie le produit de fractions

    c = pgcd(a[0], b[1])
    d = pgcd(a[1], b[0])
    sgn1 = signe(a[1])
    sgn2 = signe(b[1])
    if c == d == 1:
        return (((sgn1 * a[0]) // c, (sgn1 * a[1]) // d), ((sgn2 * b[0]) //
                d, (sgn2 * b[1]) // c), '')
    else:
        return (((sgn1 * a[0]) // c, (sgn1 * a[1]) // d), ((sgn2 * b[0]) //
                d, (sgn2 * b[1]) // c), (c, d))
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github external
def tex_den_com0(a, b, c, sgn):  # renvoie l'ecriture au format tex de la mise au meme denominateur des fraction a et b
    if not isinstance(c, tuple):  # les deux fractions ont deja le meme denominateur
        return ''
    else:
        (sgn1, sgn2) = (signe(a[1]), signe(b[1]))
        if c[0] == 1:
            if c[1] == 1:
                d = (a[0] * sgn1, a[1] * sgn1, b[0] * sgn2, b[1] * sgn2)
                return ''
            else:
                d = (a[0] * sgn1, a[1] * sgn1, sgn, b[0] * sgn2, c[1], b[1] * 
                     sgn2, c[1])
                return '\dfrac{%s}{%s}%s\\dfrac{%s_{\\times %s}}{%s_{\\times %s}}' % \
                    d
        elif c[1] == 1:
            d = (a[0] * sgn1, c[0], a[1] * sgn1, c[0], sgn, b[0] * sgn2,
                 b[1] * sgn2)
            return '\dfrac{%s_{\\times %s}}{%s_{\\times %s}}%s\\dfrac{%s}{%s}' % \
                d
        else:
            d = (
github Pyromaths / pyromaths / src / pyromaths / ex / quatriemes / developpements.py View on Github external
def tex_dev1(a, bplus=0, bpar=0, bpn=0):  # renvoi le developpement (a)²+2*a*b+(b)², (a)²-2*a*b+(b)², (a)²-(b)² ou a*c+a*d+b*c+b*d

    # a est de la forme ((3, 2)(3, 2)) pour (3x+2)(3x+2)

    (ca, cb, cc, cd) = (a[0][0], a[0][1], a[1][0], a[1][1])  # coefficients a, b, c et d
    if a[0] == a[1]:  # (a+b)² ou (a-b)²
        if signe(ca) == signe(cb):  # (a+b)²
            (ca, cb) = (abs(ca), abs(cb))
            texte = '%s^2+2\\times %s\\times %s+%s^2' % (tex_coef(ca,
                    'x', bpc=1), tex_coef(ca, 'x', bpn=1), tex_coef(cb,
                    '', bpn=1), tex_coef(cb, '', bpn=1, bpc=1))
            if bpar:
                return '(' + texte + ')'
            else:
                return texte
        else:

            # (a-b)²

            (ca, cb) = (abs(ca), abs(cb))
            texte = '%s^2-2\\times %s\\times %s+%s^2' % (tex_coef(ca,
                    'x', bpc=1), tex_coef(ca, 'x', bpn=1), tex_coef(cb,
                    '', bpn=1), tex_coef(cb, '', bpn=1, bpc=1))
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github external
def tex_den_com0(a, b, c, sgn):  # renvoie l'ecriture au format tex de la mise au meme denominateur des fraction a et b
    if not isinstance(c, tuple):  # les deux fractions ont deja le meme denominateur
        return ''
    else:
        (sgn1, sgn2) = (signe(a[1]), signe(b[1]))
        if c[0] == 1:
            if c[1] == 1:
                d = (a[0] * sgn1, a[1] * sgn1, b[0] * sgn2, b[1] * sgn2)
                return ''
            else:
                d = (a[0] * sgn1, a[1] * sgn1, sgn, b[0] * sgn2, c[1], b[1] *
                     sgn2, c[1])
                return '\dfrac{%s}{%s}%s\\dfrac{%s_{\\times %s}}{%s_{\\times %s}}' % \
                    d
        elif c[1] == 1:
            d = (a[0] * sgn1, c[0], a[1] * sgn1, c[0], sgn, b[0] * sgn2,
                 b[1] * sgn2)
            return '\dfrac{%s_{\\times %s}}{%s_{\\times %s}}%s\\dfrac{%s}{%s}' % \
                d
        else:
            d = (
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github external
def den_com1(a, b):  #renvoie un tuple contenant les fractions a et b avec le meme denominateur
    c = den_com0(a, b)
    sgn1 = signe(a[1])
    sgn2 = signe(b[1])
    return (((a[0] * c[0]) * sgn1, (a[1] * c[0]) * sgn1), ((b[0] * c[1]) *
            sgn2, (b[1] * c[1]) * sgn2))
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github external
def den_com1(a, b):  # renvoie un tuple contenant les fractions a et b avec le meme denominateur
    c = den_com0(a, b)
    sgn1 = signe(a[1])
    sgn2 = signe(b[1])
    return (((a[0] * c[0]) * sgn1, (a[1] * c[0]) * sgn1), ((b[0] * c[1]) * 
            sgn2, (b[1] * c[1]) * sgn2))
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github external
def den_com1(a, b):  #renvoie un tuple contenant les fractions a et b avec le meme denominateur
    c = den_com0(a, b)
    sgn1 = signe(a[1])
    sgn2 = signe(b[1])
    return (((a[0] * c[0]) * sgn1, (a[1] * c[0]) * sgn1), ((b[0] * c[1]) *
            sgn2, (b[1] * c[1]) * sgn2))
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github external
def tex_den_com1(a, sgn):  # renvoie l'ecriture au format tex de la somme des fractions au meme denominateur
    if not isinstance(a, tuple):  # les deux fractions ont deja le meme denominateur
        return ''
    else:
        (sgn1, sgn2) = (signe(a[0][1]), signe(a[1][1]))
        b = (a[0][0] * sgn1, a[0][1] * sgn1, sgn, a[1][0] * sgn2, a[1][1] * 
             sgn2)
        return '\dfrac{%s}{%s}%s\\dfrac{%s}{%s}' % b
github Pyromaths / pyromaths / src / pyromaths / ex / troisiemes / fractions.py View on Github external
def inverse(a):  # renvoie l'inverse de la fraction a
    sgn1 = signe(a[0])
    return (sgn1 * a[1], sgn1 * a[0])