File binomischeformeln.py changed (mode: 100644) (index a147186..967d165) |
... |
... |
import numpy as np |
2 |
2 |
import sympy as s |
import sympy as s |
3 |
3 |
from sympy import pprint, Symbol, sin, exp, sqrt, series, latex, symbols, simplify, expand |
from sympy import pprint, Symbol, sin, exp, sqrt, series, latex, symbols, simplify, expand |
4 |
4 |
from sympy import init_printing |
from sympy import init_printing |
|
5 |
|
import io |
5 |
6 |
|
|
6 |
7 |
cols = 2 |
cols = 2 |
7 |
8 |
rows = 5 |
rows = 5 |
|
... |
... |
def a2le(list): |
46 |
47 |
temp.append(le(list[i])) |
temp.append(le(list[i])) |
47 |
48 |
return temp |
return temp |
48 |
49 |
|
|
49 |
|
def binomischeform1(test1): |
|
|
50 |
|
def binomischeform1(): |
|
51 |
|
test1 = (np.random.randint(-11, 11, cols * rows)*a+np.random.randint(-11, 11, cols*rows)*b)**2 |
50 |
52 |
out_ang = "\\begin{equation*} \n" |
out_ang = "\\begin{equation*} \n" |
51 |
53 |
for i in range(len(a2l(test1))): |
for i in range(len(a2l(test1))): |
52 |
54 |
if i%rows is 0: |
if i%rows is 0: |
|
... |
... |
def binomischeform1(test1): |
68 |
70 |
# out_ang = " \\\\ ".join(a2l(test1))+"" |
# out_ang = " \\\\ ".join(a2l(test1))+"" |
69 |
71 |
out_los += "\\end{equation*}" |
out_los += "\\end{equation*}" |
70 |
72 |
return out_ang, out_los |
return out_ang, out_los |
|
73 |
|
|
|
74 |
|
|
|
75 |
|
def binomischeform3(): |
|
76 |
|
a,b,c = symbols('a b c') |
|
77 |
|
zahlen1 = np.random.randint(-11,11,cols*rows) |
|
78 |
|
zahlen2 = np.random.randint(-11, 11, cols * rows) |
|
79 |
|
out_ang = "\\begin{equation*}" |
|
80 |
|
for i in range(len(zahlen1)): |
|
81 |
|
if i%rows is 0: |
|
82 |
|
out_ang += "\\begin{aligned}[c]\n"+l((zahlen1[i]*a+zahlen2[i]*b)*(zahlen1[i]*a-zahlen2[i]*b))+"\\\\" |
|
83 |
|
if i%rows is not 0 and i%rows is not rows-1: |
|
84 |
|
out_ang += l((zahlen1[i]*a+zahlen2[i]*b)*(zahlen1[i]*a-zahlen2[i]*b))+"\\\\" |
|
85 |
|
if i%rows is rows-1: |
|
86 |
|
out_ang += l((zahlen1[i]*a+zahlen2[i]*b)*(zahlen1[i]*a-zahlen2[i]*b)) + "\n\\end{aligned} \n\\qquad \n" |
|
87 |
|
out_ang+="\end{equation*}" |
|
88 |
|
out_los = "\\section{Lösung:}\n\\begin{equation*} \n \hspace{-" + str(cols * 20) + "px}" |
|
89 |
|
for i in range(len(zahlen1)): |
|
90 |
|
if i%rows is 0: |
|
91 |
|
out_los += "\\begin{aligned}[c]\n"+le((zahlen1[i]*a+zahlen2[i]*b)*(zahlen1[i]*a-zahlen2[i]*b))+"\\\\" |
|
92 |
|
if i%rows is not 0 and i%rows is not rows-1: |
|
93 |
|
out_los += le((zahlen1[i]*a+zahlen2[i]*b)*(zahlen1[i]*a-zahlen2[i]*b))+"\\\\" |
|
94 |
|
if i%rows is rows-1: |
|
95 |
|
out_los += le((zahlen1[i]*a+zahlen2[i]*b)*(zahlen1[i]*a-zahlen2[i]*b)) + "\n\\end{aligned} \n\\qquad \n" |
|
96 |
|
out_los += "\end{equation*}" |
|
97 |
|
return out_ang, out_los |
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
71 |
102 |
x, y, z, a, b, c = symbols('x y z a b c') |
x, y, z, a, b, c = symbols('x y z a b c') |
72 |
103 |
|
|
73 |
|
test1 = (np.random.randint(1, 11, cols * rows)*a+np.random.randint(1, 11, cols*rows)*b)**2 |
|
74 |
104 |
|
|
|
105 |
|
binomischeform3() |
|
106 |
|
#exit() |
|
107 |
|
#test2 = (np.random.randint(1,11,cols*rows)*a-) |
75 |
108 |
|
|
76 |
109 |
#print(out_ang) |
#print(out_ang) |
77 |
110 |
|
|
78 |
111 |
#print("{0}\n{1}".format(binomischeform1(test1))) |
#print("{0}\n{1}".format(binomischeform1(test1))) |
79 |
112 |
#print(len(binomischeform1(test1))) |
#print(len(binomischeform1(test1))) |
80 |
113 |
|
|
81 |
|
b = binomischeform1(test1) |
|
|
114 |
|
b = binomischeform1() |
|
115 |
|
#b= binomischeform3() |
82 |
116 |
|
|
83 |
117 |
# print(b[0]) |
# print(b[0]) |
84 |
118 |
# print(b[1]) |
# print(b[1]) |
85 |
|
|
|
86 |
|
f = open("latexout2.tex", "w") |
|
|
119 |
|
f = io.open("latexout2.tex","w",encoding="utf-8") |
|
120 |
|
#f = open("latexout2.tex", "w", "utf-8") |
87 |
121 |
f.write("{}\n{}".format(b[0],b[1])) |
f.write("{}\n{}".format(b[0],b[1])) |
88 |
122 |
|
|
89 |
123 |
#print("{}\n{}".format(b[0],b[1])) |
#print("{}\n{}".format(b[0],b[1])) |