Skip to content

Gemma 4 26B-A4B inference in ~2 GB of RAM on any M-series MacBook

1.9 KB
Raw Blame

1. Derivation of the Quadratic Formula

To solve $ax^2 + bx + c = 0$ for $x$, we use the method of completing the square.

Step 1: Isolate the $x$ terms Subtract $c$ from both sides: $$ax^2 + bx = -c$$

Step 2: Divide by $a$ To make the leading coefficient 1: $$x^2 + \frac{b}{a}x = -\frac{c}{a}$$

Step 3: Complete the square Take half of the coefficient of $x$ (which is $\frac{b}{2a}$), square it ($\frac{b^2}{4a^2}$), and add it to both sides: $$x^2 + \frac{b}{a}x + \frac{b^2}{4a^2} = \frac{b^2}{4a^2} - \frac{c}{a}$$

Step 4: Factor and simplify The left side is now a perfect square. On the right side, find a common denominator ($4a^2$): $$\left(x + \frac{b}{2a}\right)^2 = \frac{b^2 - 4ac}{4a^2}$$

Step 5: Take the square root Take the square root of both sides, remembering to include $\pm$: $$x + \frac{b}{2a} = \pm \sqrt{\frac{b^2 - 4ac}{4a^2}}$$ $$x + \frac{b}{2a} = \pm \frac{\sqrt{b^2 - 4ac}}{2a}$$

Step 6: Solve for $x$ Subtract $\frac{b}{2a}$ from both sides: $$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$


2. Cosine Similarity Formula

Cosine similarity measures the cosine of the angle between two non-zero vectors. It is calculated as: $$\text{similarity}(\mathbf{A}, \mathbf{B}) = \frac{\mathbf{A} \cdot \mathbf{B}}{|\mathbf{A}| |\mathbf{B}|} = \frac{\sum_{i=1}^{n} A_i B_i}{\sqrt{\sum_{i=1}^{n} A_i^2} \sqrt{\sum_{i=1}^{n} B_i^2}}$$


3. Pricing Logic: $20 vs $30

The price difference typically depends on value-added variables such as:

  • Quality/Material: A $30 product might use premium materials compared to a $20 budget version.
  • Features/Complexity: The $30 version may include advanced features or higher capacity.
  • Service/Warranty: The higher price might include extended support or faster shipping.

4. Comparison Table

Feature Case A ($20) Case B ($30)
Target Market Budget-