def tex_type5(valeurs, variable, cor, exo): # ecrit toutes les etapes de la factorisation if exo: exo.append("$$A = %s$$" %tex_type5_0(valeurs, variable)) cor.append("\\begin{center}") cor.append("$\\begin{aligned}") cor.append("A & = %s \\\\" %tex_type5_0(valeurs, variable)) cor.append("A & = %s^2-%s^2 \\\\" % (tex_binome(valeurs[0], variable, bpar=1), tex_binome(valeurs[1], variable, bpar=1))) cor.append("A & = %s \\\\" %tex_type5_2(valeurs, variable)) if valeurs[0][0] == 0: cor.append("A & = %s \\\\" %tex_type5_3(valeurs, variable)) cor.append("A & = \\boxed{%s} \\\\" %tex_dev0((somme_polynomes(valeurs[0], valeurs[1]), somme_polynomes(valeurs[0], coef_opposes(valeurs[1]))), variable)) cor.append("\\end{aligned}$") cor.append("\\end{center}")
def tex_equations(valeurs, variable, cor): # renvoie un tuple contenant les deux binomes egaux a 0 cor.append("\\begin{center}") cor.append("$\\begin{aligned}") cor.append("%s & =0 & & \\text{ou} & %s &= 0 \\\\" % (tex_binome(valeurs[0], variable), tex_binome(valeurs[1], variable))) eq = equations1(valeurs) if not isinstance(eq, tuple): cor.append("\\text{Aucune } & \\text{solution} & & \\text{ou} & \\text{Aucune } & \\text{solution} \\\\") cor.append("\\end{aligned}$") cor.append("\\end{center}") cor.append(u"L'équation a \\fbox{aucune solution.}") elif not isinstance(eq[0], tuple): cor.append("\\text{Aucune } & \\text{solution} & & \\text{ou} & %s & = %s \\\\" %(tex_coef(eq[1][0], variable), eq[1][1])) if eq[1][0] != 1: cor.append("\\text{Aucune } & \\text{solution} & & \\text{ou} & x & = %s \\\\" %tex_frac(equations2(eq)[1])) cor.append("\\end{aligned}$") cor.append("\\end{center}") cor.append(u'La solution est $\\boxed{%s}$' % tex_frac(equations3(eq)[1])) elif not isinstance(eq[1], tuple): cor.append(" %s & = %s & & \\text{ou} & \\text{Aucune } & \\text{solution} \\\\" %(tex_coef(eq[0][0], variable), eq[0][1])) if eq[0][0] != 1: cor.append(" x & = %s & & \\text{ou} & \\text{Aucune } & \\text{solution} \\\\" %tex_frac(equations2(eq)[0])) cor.append("\\end{aligned}$") cor.append("\\end{center}") cor.append(u'La solution est $\\boxed{%s}$' % tex_frac(equations3(eq)[0])) else: cor.append("%s & = %s & & \\text{ou} & %s & = %s \\\\" %(tex_coef(eq[0][0], variable), eq[0][1], tex_coef(eq[1][0], variable), eq[1][1])) if eq[0][0] != 1 or eq[1][0] != 1: cor.append("x & = %s & & \\text{ou} & x & = %s \\\\" %(tex_frac(equations2(eq)[0]), tex_frac(equations2(eq)[1]))) cor.append("\\end{aligned}$") cor.append("\\end{center}") cor.append(u'Les solutions sont $\\boxed{%s\\,\\text{ et }\\,%s}$' % (tex_frac(equations3(eq)[0]), tex_frac(equations3(eq)[1])))
def tex_type123_1(f, variable, nega, negb): # renvoie (2x+3)(-(x+5)+3x+6) texte = tex_binome(f[0], variable, bpar=1) if nega or negb: texte = texte + '\\,\\big( ' else: texte = texte + '\\,(' if nega: texte = texte + '-' + tex_binome(f[1], variable, bpar=1) else: texte = texte + tex_binome(f[1], variable, bpar=0) if negb: texte = texte + '-' + tex_binome(f[2], variable, bpar=1) else: texte = texte + tex_binome(f[2], variable, bplus=1) if nega or negb: texte = texte + '\\big)' else: texte = texte + ')' return texte
def solveur(enonce,equation,inconnue,corrige=False): enonce.append("\\begin{center}") enonce.append("$\\begin{aligned}") enonce.append("%s & = %s \\\\" %(tex_binome(equation[:2],inconnue),tex_binome(equation[2:],inconnue))) if corrige: if equation[1]!=0: enonce.append("%s & = %s \\red %s \\\\" %(tex_coef(equation[0],inconnue),tex_binome([equation[2],equation[3]],inconnue),tex_coef(-equation[1],0,1))) if equation[2]!=0 and equation[0]!=1: enonce.append("%s & = %s \\\\" %(tex_coef(equation[0],inconnue),tex_binome([equation[2],equation[3]-equation[1]],inconnue))) if equation[2]!=0: enonce.append("%s \\red %s \\black & = %s \\\\" %(tex_coef(equation[0],inconnue),tex_coef(-equation[2],inconnue,1),tex_coef(equation[3]-equation[1],0))) enonce.append("%s & = %s \\\\" %(tex_coef(equation[0]-equation[2],inconnue),tex_coef(equation[3]-equation[1],0))) if (equation[0]-equation[2])!=1: enonce.append("%s & = %s \\div \\red %s \\\\" %(inconnue,tex_coef(equation[3]-equation[1],0),tex_coef(equation[0]-equation[2],0,0,1))) if float(equation[3]-equation[1])/(equation[0]-equation[2]) != (equation[3]-equation[1])/(equation[0]-equation[2]): enonce.append("%s & \\approx \\boxed{%s} \\\\" %(inconnue,round(float(equation[3]-equation[1])/(equation[0]-equation[2]),2))) else: enonce.append("%s & = \\boxed{%s} \\\\" %(inconnue,(equation[3]-equation[1])/(equation[0]-equation[2]))) enonce.append("\\end{aligned}$") enonce.append("\\end{center}")
def tex_type5_3(valeurs, variable): # renvoie (4+2x+3)(4-2x-3) return '(%s%s)\\,(%s%s)' % (tex_binome(valeurs[0], variable), tex_binome(valeurs[1], variable, bplus=1), tex_binome(valeurs[0], variable), tex_binome(coef_opposes(valeurs[1]), variable, bplus=1))
def tex_type5_2(valeurs, variable): # renvoie (4+2x+3)(4-(2x+3)) if valeurs[0][0] == 0: return '(%s%s)\\,\\big( %s-%s\\big)' % (tex_binome(valeurs[0], variable), tex_binome(valeurs[1], variable, bplus=1), tex_binome(valeurs[0], variable), tex_binome(valeurs[1], variable, bpar=1)) else: return '(%s%s)\\,(%s-%s)' % (tex_binome(valeurs[0], variable), tex_binome(valeurs[1], variable, bplus=1), tex_binome(valeurs[0], variable), tex_binome(valeurs[1], variable, bpar=1))
def tex_type5_0(valeurs, variable): # renvoie 16-(2x+3)² if valeurs[0][0] == 0: return '%s-%s^2' % (valeurs[0][1] ** 2, tex_binome(valeurs[1], variable, bpar=1)) else: return '%s^2-%s' % (tex_binome(valeurs[0], variable, bpar=1), valeurs[1][1] ** 2)
def tex_type123_2(valeurs, variable): # renvoie renvoie (2x+3)(-x-5+3x+6) return tex_binome(valeurs[0], variable, bpar=1) + '\\,(' + tex_binome(valeurs[1], variable) + tex_binome(valeurs[2], variable, bplus=1) + ')'