mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
* Improve combine_like_terms * Lint fix * add some latex to readme * give compound_interest latex formatting * fix compound interest readme * update combine_like_terms readme * combine_like_terms add delimiters * Convert some alebra output to latex * Add missing right] to latex * Fix makeReadme script * Correct det 2x2 latex * use bmatrix for det 2x2 * update readme and bump version * Make latex matrix one line * made latex for most of algebra * more latex migrations * convert basic_math to latex * re-generate readme * fix double exponent * latex for most of calculus * Improved stationary points gen * made cs latex * Transform geometry to latex * texify misc outputs * texify statistics * regenerate readme * Add tex markers to linear_equations * add list_to_tex for mult_int_22 * upgrade readme * update list_to_tex * add end to list_to_tex * tweak list_to_tex, update readme * Update README.md * Update README.md * lint fixes * lint fix * Remove tests * texify system_of_equations * update system_of_equations tex * regen readme * texify complex_quadratic * update complex_quadratic * regen readme * sqrt to complex_quadratic * complex_quadratic texify * Update README.md * Update README.md * make latexbuilder * regen readme * fix bmatrix * bmatrix conversions * update readme * use times symbol * improve tex of prod_sci_notations * Add missing delim to prod of sci notations * Add missing curly brack to prod-sci-not * lint fixes * texify differentiation * texify stationary points * changed differentation to trig_differentiation * texify stationary points * update readme * Remove left right from stat_points * texify angle_btw_vectors * update readme * add spaces to mod operator * Swap \\% with \\percent * update readme * Replace //percent with non-math % * fix leftover \\percent * latexify vector_cross * change tex multiply to times * update readme * lint fixes * lint fix
34 lines
960 B
Python
34 lines
960 B
Python
from ...generator import Generator
|
|
import random
|
|
import math
|
|
|
|
|
|
def gen_func(maxEltAmt=20):
|
|
s = 0
|
|
v1 = [
|
|
round(random.uniform(0, 1000), 2)
|
|
for i in range(random.randint(2, maxEltAmt))
|
|
]
|
|
v2 = [round(random.uniform(0, 1000), 2) for i in v1]
|
|
for i in range(len(v1)):
|
|
s += v1[i] * v2[i]
|
|
|
|
mags = math.sqrt(sum([i**2
|
|
for i in v1])) * math.sqrt(sum([i**2 for i in v2]))
|
|
solution = ''
|
|
ans = 0
|
|
try:
|
|
ans = round(math.acos(s / mags), 2)
|
|
solution = f"${ans}$ radians"
|
|
except ValueError:
|
|
print('angleBtwVectorsFunc has some issues with math module, line 16')
|
|
solution = 'NaN'
|
|
ans = 'NaN'
|
|
# would return the answer in radians
|
|
problem = f"angle between the vectors ${v1}$ and ${v2}$ is:"
|
|
return problem, solution
|
|
|
|
|
|
angle_btw_vectors = Generator("Angle between 2 vectors", 70,
|
|
gen_func, ["maxEltAmt=20"])
|