diff --git a/backend/api/formula_data/linear_algebra_i.py b/backend/api/formula_data/linear_algebra_i.py index 9ae39be..1892d90 100644 --- a/backend/api/formula_data/linear_algebra_i.py +++ b/backend/api/formula_data/linear_algebra_i.py @@ -7,14 +7,45 @@ {"name": "Scalar Multiplication", "latex": r"k\mathbf{u} = \langle ku_1, ku_2 \rangle"}, {"name": "Magnitude (L2 Norm)", "latex": r"\|\mathbf{v}\| = \sqrt{v_1^2 + v_2^2 + \dots + v_n^2}"}, {"name": "Dot Product", "latex": r"\mathbf{u} \cdot \mathbf{v} = u_1v_1 + u_2v_2 + \dots + u_nv_n"}, + {"name": "Dot Product & Angle", "latex": r"\mathbf{u} \cdot \mathbf{v} = \|\mathbf{u}\|\|\mathbf{v}\|\cos(\theta)"}, + {"name": "Cross Product (3D)", "latex": r"\mathbf{u} \times \mathbf{v} = \langle u_2v_3-u_3v_2, \ u_3v_1-u_1v_3, \ u_1v_2-u_2v_1 \rangle"}, + {"name": "Unit Vector", "latex": r"\hat{\mathbf{v}} = \frac{\mathbf{v}}{\|\mathbf{v}\|}"}, + {"name": "Vector Projection", "latex": r"\text{proj}_{\mathbf{v}}(\mathbf{u}) = \frac{\mathbf{u} \cdot \mathbf{v}}{\mathbf{v} \cdot \mathbf{v}}\mathbf{v}"}, ], "Matrix Operations": [ {"name": "Matrix Addition", "latex": r"A + B = [a_{ij} + b_{ij}]"}, {"name": "Matrix-Vector Multiplication", "latex": r"A\mathbf{x} = \mathbf{b}"}, + {"name": "Matrix Multiplication", "latex": r"(AB)_{ij} = \sum_{k=1}^n A_{ik}B_{kj}"}, {"name": "Transpose", "latex": r"(A^T)_{ij} = A_{ji}"}, + {"name": "Transpose Properties", "latex": r"(A^T)^T = A, \quad (AB)^T = B^T A^T"}, + {"name": "Trace", "latex": r"\text{tr}(A) = \sum_{i=1}^n a_{ii}"}, ], - "2x2 Systems": [ + "Determinants & Inverses": [ {"name": "2x2 Determinant", "latex": r"\det(A) = ad - bc"}, {"name": "2x2 Inverse", "latex": r"A^{-1} = \frac{1}{ad-bc} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}"}, + {"name": "3x3 Determinant Expansion", "latex": r"\det(A) = a(ei-fh) - b(di-fg) + c(dh-eg)"}, + {"name": "Inverse via Adjugate", "latex": r"A^{-1} = \frac{1}{\det(A)} \text{adj}(A)"}, + ], + "Linear Systems": [ + {"name": "General System", "latex": r"A\mathbf{x} = \mathbf{b}"}, + {"name": "Homogeneous System", "latex": r"A\mathbf{x} = \mathbf{0}"}, + {"name": "Cramer's Rule", "latex": r"x_i = \frac{\det(A_i)}{\det(A)}"}, + {"name": "Least Squares Solution", "latex": r"\mathbf{\hat{x}} = (A^TA)^{-1}A^T\mathbf{b}"}, + ], + "Lines & Planes": [ + {"name": "Line Equation (Parametric)", "latex": r"\mathbf{r}(t) = \mathbf{r}_0 + t\mathbf{v}"}, + {"name": "Plane Equation (Normal Form)", "latex": r"\mathbf{n} \cdot (\mathbf{r} - \mathbf{r}_0) = 0"}, + {"name": "Distance from Point to Plane", "latex": r"D = \frac{|ax_0 + by_0 + cz_0 + d|}{\sqrt{a^2 + b^2 + c^2}}"}, + ], + "Determinant Properties": [ + {"name": "Multiplicative Property", "latex": r"\det(AB) = \det(A)\det(B)"}, + {"name": "Transpose Property", "latex": r"\det(A^T) = \det(A)"}, + {"name": "Scalar Multiplication", "latex": r"\det(kA) = k^n \det(A)"}, + {"name": "Inverse Property", "latex": r"\det(A^{-1}) = \frac{1}{\det(A)}"}, + ], + "2D Transformations": [ + {"name": "Rotation Matrix (CCW)", "latex": r"R_\theta = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix}"}, + {"name": "Reflection Matrix (x-axis)", "latex": r"T = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}"}, + {"name": "Scaling Matrix", "latex": r"S = \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix}"}, ] } \ No newline at end of file diff --git a/backend/api/formula_data/linear_algebra_ii.py b/backend/api/formula_data/linear_algebra_ii.py index add5433..1d6e9ed 100644 --- a/backend/api/formula_data/linear_algebra_ii.py +++ b/backend/api/formula_data/linear_algebra_ii.py @@ -2,18 +2,49 @@ CLASS_NAME = "LINEAR ALGEBRA II" FORMULAS = { - "Matrix Properties": [ + "Matrix Properties & Classifications": [ {"name": "Invertibility Condition", "latex": r"A \text{ is invertible iff } \det(A) \neq 0"}, {"name": "Matrix Multiplication Property", "latex": r"(AB)^{-1} = B^{-1}A^{-1}"}, - {"name": "Orthogonality", "latex": r"Q^T Q = I"}, + {"name": "Orthogonal Matrix", "latex": r"Q^T Q = I \implies Q^{-1} = Q^T"}, + {"name": "Symmetric Matrix", "latex": r"A^T = A"}, + {"name": "Positive Definite Condition", "latex": r"\mathbf{x}^TA\mathbf{x} > 0 \text{ for all } \mathbf{x} \neq \mathbf{0}"}, ], - "Eigenvalues & Eigenvectors": [ + "Vector Spaces & Bases": [ + {"name": "Linear Independence", "latex": r"c_1\mathbf{v}_1 + \dots + c_k\mathbf{v}_k = \mathbf{0} \implies c_i = 0"}, + {"name": "Rank-Nullity Theorem", "latex": r"\text{rank}(A) + \text{nullity}(A) = n"}, + {"name": "Change of Basis", "latex": r"[\mathbf{x}]_\mathcal{B} = P_{\mathcal{B} \leftarrow \mathcal{C}} [\mathbf{x}]_\mathcal{C}"}, + ], + "Inner Product Spaces": [ + {"name": "Cauchy-Schwarz Inequality", "latex": r"|\langle \mathbf{u}, \mathbf{v} \rangle| \le \|\mathbf{u}\| \|\mathbf{v}\|"}, + {"name": "Triangle Inequality", "latex": r"\|\mathbf{u} + \mathbf{v}\| \le \|\mathbf{u}\| + \|\mathbf{v}\|"}, + {"name": "Projection Formula", "latex": r"\text{proj}_{\mathbf{u}}(\mathbf{v}) = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\|^2}\mathbf{u}"}, + {"name": "Gram-Schmidt Process", "latex": r"\mathbf{u}_k = \mathbf{v}_k - \sum_{j=1}^{k-1} \text{proj}_{\mathbf{u}_j}(\mathbf{v}_k)"}, + ], + "Eigenvalues & Diagonalization": [ {"name": "Characteristic Equation", "latex": r"\det(A - \lambda I) = 0"}, {"name": "Eigenvector Definition", "latex": r"A\mathbf{v} = \lambda\mathbf{v}"}, - ], - "Decompositions & Spaces": [ + {"name": "Eigenspace Definition", "latex": r"E_\lambda = \text{Nul}(A - \lambda I)"}, {"name": "Diagonalization", "latex": r"A = PDP^{-1}"}, - {"name": "Rank-Nullity Theorem", "latex": r"\text{rank}(A) + \text{nullity}(A) = n"}, - {"name": "Projection Formula", "latex": r"\text{proj}_{\mathbf{u}}(\mathbf{v}) = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\|^2}\mathbf{u}"}, + {"name": "Spectral Theorem (Symmetric A)", "latex": r"A = QDQ^T \quad (Q^TQ = I)"}, + ], + "Decompositions": [ + {"name": "Singular Value Decomposition (SVD)", "latex": r"A = U\Sigma V^T"}, + {"name": "QR Decomposition", "latex": r"A = QR \quad (Q \text{ orthogonal}, R \text{ upper triangular})"}, + {"name": "Quadratic Form", "latex": r"Q(\mathbf{x}) = \mathbf{x}^TA\mathbf{x}"}, + ], + "Fundamental Subspaces": [ + {"name": "Column Space C(A)", "latex": r"C(A) = \text{Span}(\mathbf{a}_1, \dots, \mathbf{a}_n)"}, + {"name": "Null Space N(A)", "latex": r"N(A) = \{\mathbf{x} \in \mathbb{R}^n \mid A\mathbf{x} = \mathbf{0}\}"}, + {"name": "Row Space", "latex": r"C(A^T) = \text{Span}(\text{rows of } A)"}, + {"name": "Left Null Space", "latex": r"N(A^T) = \{\mathbf{y} \in \mathbb{R}^m \mid A^T\mathbf{y} = \mathbf{0}\}"}, + ], + "Orthogonal Projections": [ + {"name": "Projection Matrix", "latex": r"P = A(A^TA)^{-1}A^T"}, + {"name": "Projection of b onto C(A)", "latex": r"\mathbf{p} = P\mathbf{b}"}, + {"name": "Error Vector (Orthogonal)", "latex": r"\mathbf{e} = \mathbf{b} - \mathbf{p}"}, + ], + "Markov Chains": [ + {"name": "State Vector Update", "latex": r"\mathbf{x}_{k+1} = P\mathbf{x}_k"}, + {"name": "Steady-State Vector", "latex": r"P\mathbf{q} = \mathbf{q} \quad (\text{Eigenvector for } \lambda=1)"}, ] } \ No newline at end of file diff --git a/backend/api/formula_data/statistics_i.py b/backend/api/formula_data/statistics_i.py index 1434b3c..fa84a02 100644 --- a/backend/api/formula_data/statistics_i.py +++ b/backend/api/formula_data/statistics_i.py @@ -1,11 +1,11 @@ """ STATISTICS I formulas """ - CLASS_NAME = "STATISTICS I" FORMULAS = { "Descriptive Statistics": [ {"name": "Sample Mean", "latex": r"\bar{x} = \frac{\sum x_i}{n}"}, {"name": "Population Mean", "latex": r"\mu = \frac{\sum x_i}{N}"}, + {"name": "Sample Variance", "latex": r"s^2 = \frac{\sum (x_i - \bar{x})^2}{n-1}"}, {"name": "Sample Standard Deviation", "latex": r"s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n-1}}"}, {"name": "Z-Score", "latex": r"z = \frac{x - \mu}{\sigma}"}, ], @@ -13,16 +13,20 @@ {"name": "Addition Rule", "latex": r"P(A \cup B) = P(A) + P(B) - P(A \cap B)"}, {"name": "Multiplication Rule", "latex": r"P(A \cap B) = P(A) \cdot P(B|A)"}, {"name": "Conditional Probability", "latex": r"P(A|B) = \frac{P(A \cap B)}{P(B)}"}, + {"name": "Bayes' Theorem", "latex": r"P(A|B) = \frac{P(B|A)P(A)}{P(B)}"}, {"name": "Expected Value", "latex": r"E(X) = \mu_X = \sum [x_i \cdot P(x_i)]"}, ], "Distributions": [ {"name": "Binomial Probability", "latex": r"P(X=k) = \binom{n}{k} p^k (1-p)^{n-k}"}, {"name": "Mean of Binomial Dist.", "latex": r"\mu_X = np"}, {"name": "Standard Dev. of Binomial", "latex": r"\sigma_X = \sqrt{np(1-p)}"}, + {"name": "Poisson Probability", "latex": r"P(X=k) = \frac{\lambda^k e^{-\lambda}}{k!}"}, + {"name": "Normal Distribution (PDF)", "latex": r"f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}"}, ], "Inferential Statistics": [ {"name": "Confidence Interval (Mean)", "latex": r"\bar{x} \pm z^* \frac{\sigma}{\sqrt{n}}"}, {"name": "Confidence Interval (Proportion)", "latex": r"\hat{p} \pm z^* \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}"}, {"name": "Margin of Error", "latex": r"ME = z^* \frac{\sigma}{\sqrt{n}}"}, + {"name": "Test Statistic (1-Sample Z)", "latex": r"z = \frac{\bar{x} - \mu_0}{\sigma/\sqrt{n}}"}, ] } \ No newline at end of file diff --git a/backend/api/formula_data/statistics_ii.py b/backend/api/formula_data/statistics_ii.py index 980fdbe..fc8c369 100644 --- a/backend/api/formula_data/statistics_ii.py +++ b/backend/api/formula_data/statistics_ii.py @@ -1,5 +1,4 @@ """ STATISTICS II formulas """ - CLASS_NAME = "STATISTICS II" FORMULAS = { @@ -7,21 +6,24 @@ {"name": "Two-Sample t-Test (Means)", "latex": r"t = \frac{(\bar{x}_1 - \bar{x}_2)}{\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}}"}, {"name": "Two-Sample z-Test (Proportions)", "latex": r"z = \frac{(\hat{p}_1 - \hat{p}_2)}{\sqrt{\hat{p}_c(1-\hat{p}_c)(\frac{1}{n_1} + \frac{1}{n_2})}}"}, {"name": "Pooled Proportion", "latex": r"\hat{p}_c = \frac{x_1 + x_2}{n_1 + n_2}"}, + {"name": "CI for Diff. of Means", "latex": r"(\bar{x}_1 - \bar{x}_2) \pm t^* \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}"}, ], "Chi-Square Tests": [ {"name": "Chi-Square Statistic", "latex": r"\chi^2 = \sum \frac{(O - E)^2}{E}"}, {"name": "Expected Count", "latex": r"E = \frac{\text{row total} \times \text{column total}}{\text{table total}}"}, {"name": "Degrees of Freedom (Matrix)", "latex": r"df = (r-1)(c-1)"}, + {"name": "Degrees of Freedom (Goodness of Fit)", "latex": r"df = k - 1"}, ], - "Linear Regression": [ - {"name": "Regression Line", "latex": r"\hat{y} = b_0 + b_1x"}, - {"name": "Slope of Regression", "latex": r"b_1 = r \frac{s_y}{s_x}"}, - {"name": "Y-Intercept", "latex": r"b_0 = \bar{y} - b_1\bar{x}"}, + "Linear & Multiple Regression": [ + {"name": "Simple Regression Line", "latex": r"\hat{y} = b_0 + b_1x"}, {"name": "Correlation Coefficient (r)", "latex": r"r = \frac{1}{n-1} \sum \left(\frac{x_i - \bar{x}}{s_x}\right)\left(\frac{y_i - \bar{y}}{s_y}\right)"}, + {"name": "Coefficient of Determination", "latex": r"R^2 = \frac{SSR}{SST} = 1 - \frac{SSE}{SST}"}, + {"name": "Multiple Regression Model", "latex": r"\hat{y} = b_0 + b_1x_1 + b_2x_2 + \dots + b_kx_k"}, ], "ANOVA (Analysis of Variance)": [ {"name": "F-Statistic", "latex": r"F = \frac{MSG}{MSE}"}, {"name": "Mean Square (Groups)", "latex": r"MSG = \frac{SSG}{k-1}"}, {"name": "Mean Square (Error)", "latex": r"MSE = \frac{SSE}{N-k}"}, + {"name": "Total Sum of Squares", "latex": r"SST = SSG + SSE"}, ] } \ No newline at end of file diff --git a/backend/api/latex_utils.py b/backend/api/latex_utils.py index e186b59..498a560 100644 --- a/backend/api/latex_utils.py +++ b/backend/api/latex_utils.py @@ -136,7 +136,7 @@ def build_layout_comment_block(columns=4, font_size="9pt", margins="0.15in", spa f"% @cheatsheet-layout spacing: {spacing} | change layout options up top to update spacing", f"% @cheatsheet-layout margins: {margins} | change layout options up top to update margins", f"% @cheatsheet-layout orientation: {orientation} | change layout options up top to update orientation", - "%", + "%" ] @@ -148,12 +148,12 @@ def build_dynamic_header(columns=4, font_size="9pt", margins="0.15in", spacing=" spacing_values = get_spacing_values(spacing, font_size) doc_class, doc_class_size = get_document_class(font_size) - # 1. Force the PDF driver to rotate by passing landscape and letterpaper to the document class + # Force the PDF driver to use letterpaper, add landscape if requested doc_options = f"{doc_class_size},fleqn,letterpaper" if orientation == "landscape": doc_options += ",landscape" - # 2. Also pass them to the geometry package + # Also pass them to the geometry package geometry_options = f"letterpaper,margin={margins}" if orientation == "landscape": geometry_options += ",landscape" diff --git a/backend/api/views.py b/backend/api/views.py index 4be731a..e987706 100644 --- a/backend/api/views.py +++ b/backend/api/views.py @@ -372,6 +372,7 @@ def compile_latex(request): font_size = cheatsheet.font_size margins = cheatsheet.margins spacing = cheatsheet.spacing + orientation = getattr(cheatsheet, "orientation", None) or "portrait" content = cheatsheet.build_full_latex() if not content: @@ -380,15 +381,17 @@ def compile_latex(request): content = normalize_latex_layout(content, columns, font_size, margins, spacing, orientation) if normalize_only: + layout_response = { + "columns": columns, + "font_size": font_size, + "margins": margins, + "spacing": spacing, + "orientation": orientation, + } + return Response({ "tex_code": content, - "layout": { - "columns": columns, - "font_size": font_size, - "margins": margins, - "spacing": spacing, - "orientation": orientation, - }, + "layout": layout_response, }) with tempfile.TemporaryDirectory() as tempdir: diff --git a/frontend/src/components/CreateCheatSheet.jsx b/frontend/src/components/CreateCheatSheet.jsx index 830ca93..564aea5 100644 --- a/frontend/src/components/CreateCheatSheet.jsx +++ b/frontend/src/components/CreateCheatSheet.jsx @@ -1273,8 +1273,6 @@ const CreateCheatSheet = ({ onSave, onReset, onRestoreSnapshot, initialData, isS }); }, [columns, compileError, content, contentSource, fontSize, getSelectedFormulasList, margins, onSave, orientation, pdfBlob, spacing, title]); - - const startResize = useCallback((panel) => (event) => { event.preventDefault(); @@ -1763,4 +1761,4 @@ const CreateCheatSheet = ({ onSave, onReset, onRestoreSnapshot, initialData, isS ); }; -export default CreateCheatSheet; +export default CreateCheatSheet; \ No newline at end of file diff --git a/frontend/src/data/subjectVideos.js b/frontend/src/data/subjectVideos.js index e6da17f..af83752 100644 --- a/frontend/src/data/subjectVideos.js +++ b/frontend/src/data/subjectVideos.js @@ -558,7 +558,7 @@ export const CURATED_SUBJECT_VIDEOS = { title: "Linear Regression Explained", videoId: "zITIFTsivN8", channel: "StatQuest with Josh Starmer", - topic: "Linear Regression" + topic: "Linear & Multiple Regression" }, { title: "Hypothesis Testing", @@ -577,8 +577,46 @@ export const CURATED_SUBJECT_VIDEOS = { videoId: "QZ7kgmhdIwA", channel: "CrashCourse", topic: "Two-Sample Inference" - - + }, + ], + "LINEAR ALGEBRA I": [ + { + title: "Vectors | Chapter 1, Essence of linear algebra", + videoId: "fNk_zzaMoSs", + channel: "3Blue1Brown", + topic: "Vector Basics" + }, + { + title: "Multiplying Matrices", + videoId: "XkY2DOUCWMU", + channel: "Khan Academy", + topic: "Matrix Operations" + }, + { + title: "Inverse of a 2x2 Matrix", + videoId: "aGxBncx2fS0", + channel: "The Organic Chemistry Tutor", + topic: "Determinants & Inverses" + }, + ], + "LINEAR ALGEBRA II": [ + { + title: "The determinant | Chapter 6, Essence of linear algebra", + videoId: "Ip3X9LOh2dk", + channel: "3Blue1Brown", + topic: "Matrix Properties & Classifications" + }, + { + title: "Eigenvectors and eigenvalues", + videoId: "PFDu9oVAE-g", + channel: "3Blue1Brown", + topic: "Eigenvalues & Diagonalization" + }, + { + title: "Diagonalization of a Matrix", + videoId: "Y_HVQvj0YyA", + channel: "The Organic Chemistry Tutor", + topic: "Decompositions" }, ], };