-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathalgebra.html
More file actions
2759 lines (2381 loc) · 151 KB
/
algebra.html
File metadata and controls
2759 lines (2381 loc) · 151 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Algebra - Math from Zero to CS - Better Dev</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="topbar">
<button class="sidebar-toggle" aria-label="Open navigation" aria-expanded="false">
<span class="hamburger-icon"></span>
</button>
<a href="index.html" class="logo">Better Dev</a>
</header>
<div class="sidebar-backdrop" aria-hidden="true"></div>
<aside class="sidebar" aria-label="Site navigation">
<div class="sidebar-header">
<span class="sidebar-title">Navigation</span>
<button class="sidebar-close" aria-label="Close navigation">×</button>
</div>
<div class="sidebar-search">
<input type="text" class="sidebar-search-input" placeholder="Search topics..." aria-label="Search topics">
<div class="sidebar-search-results"></div>
</div>
<nav class="sidebar-nav">
<div class="sidebar-group">
<a href="index.html">Home</a>
</div>
<div class="sidebar-group">
<div class="sidebar-group-label">Mathematics</div>
<a href="pre-algebra.html">Pre-Algebra</a>
<a href="algebra.html">Algebra</a>
<a href="sequences-series.html">Sequences & Series</a>
<a href="geometry.html">Geometry</a>
<a href="calculus.html">Calculus</a>
<a href="discrete-math.html">Discrete Math</a>
<a href="linear-algebra.html">Linear Algebra</a>
<a href="probability.html">Probability & Statistics</a>
<a href="binary-systems.html">Binary & Number Systems</a>
<a href="number-theory.html">Number Theory for CP</a>
<a href="computational-geometry.html">Computational Geometry</a>
<a href="game-theory.html">Game Theory</a>
</div>
<div class="sidebar-group">
<div class="sidebar-group-label">Data Structures & Algorithms</div>
<a href="dsa-foundations.html">DSA Foundations</a>
<a href="arrays.html">Arrays & Strings</a>
<a href="stacks-queues.html">Stacks & Queues</a>
<a href="hashmaps.html">Hash Maps & Sets</a>
<a href="linked-lists.html">Linked Lists</a>
<a href="trees.html">Trees & BST</a>
<a href="graphs.html">Graphs</a>
<a href="sorting.html">Sorting & Searching</a>
<a href="patterns.html">LeetCode Patterns</a>
<a href="dp.html">Dynamic Programming</a>
<a href="advanced.html">Advanced Topics</a>
<a href="string-algorithms.html">String Algorithms</a>
<a href="advanced-graphs.html">Advanced Graphs</a>
<a href="advanced-dp.html">Advanced DP</a>
<a href="advanced-ds.html">Advanced Data Structures</a>
<a href="leetcode-650.html">The 650 Problems</a>
<a href="competitive-programming.html">CP Roadmap</a>
</div>
<div class="sidebar-group">
<div class="sidebar-group-label">Languages & Systems</div>
<a href="cpp.html">C++</a>
<a href="golang.html">Go</a>
<a href="javascript.html">JavaScript Deep Dive</a>
<a href="typescript.html">TypeScript</a>
<a href="nodejs.html">Node.js Internals</a>
<a href="os.html">Operating Systems</a>
<a href="linux.html">Linux</a>
<a href="git.html">Git</a>
<a href="backend.html">Backend</a>
<a href="system-design.html">System Design</a>
<a href="networking.html">Networking</a>
<a href="cloud.html">Cloud & Infrastructure</a>
<a href="docker.html">Docker & Compose</a>
<a href="kubernetes.html">Kubernetes</a>
<a href="message-queues.html">Queues & Pub/Sub</a>
<a href="selfhosting.html">VPS & Self-Hosting</a>
<a href="databases.html">PostgreSQL & MySQL</a>
<a href="stripe.html">Stripe & Payments</a>
<a href="distributed-systems.html">Distributed Systems</a>
<a href="backend-engineering.html">Backend Engineering</a>
</div>
<div class="sidebar-group">
<div class="sidebar-group-label">JS/TS Ecosystem</div>
<a href="js-tooling.html">Tooling & Bundlers</a>
<a href="js-testing.html">Testing</a>
<a href="ts-projects.html">Building with TS</a>
</div>
<div class="sidebar-group">
<div class="sidebar-group-label">More</div>
<a href="seans-brain.html">Sean's Brain</a>
</div>
</nav>
</aside>
<!-- Page Header -->
<div class="container">
<div class="page-header">
<div class="breadcrumb"><a href="index.html">Home</a> » Algebra</div>
<h1>Algebra</h1>
<p>Variables, equations, functions, and polynomials -- the language of math and the backbone of programming logic.</p>
<div class="tip-box" style="margin-top: 1rem;">
<div class="label">Why Algebra Matters for Programming</div>
<p>Every program you've ever used is built on algebraic thinking. Variables in code work exactly like variables in algebra. Equations become algorithms. Functions map inputs to outputs. Understanding algebra deeply will make you a much stronger programmer and problem-solver.</p>
</div>
</div>
</div>
<!-- Table of Contents + Content -->
<div class="page-with-toc">
<!-- Sidebar TOC -->
<aside class="sidebar-toc">
<div class="toc">
<h4>Table of Contents</h4>
<a href="#variables">1. Variables & Expressions</a>
<a href="#linear-equations">2. Solving Linear Equations</a>
<a href="#inequalities">3. Inequalities</a>
<a href="#functions">4. Functions</a>
<a href="#systems">5. Systems of Equations</a>
<a href="#polynomials">6. Polynomials</a>
<a href="#factoring">7. Factoring</a>
<a href="#quadratics">8. Quadratic Equations</a>
<a href="#exponents">9. Exponent Rules</a>
<a href="#logarithms">10. Logarithms</a>
<a href="#sequences">11. Sequences & Series</a>
<a href="#quiz">12. Practice Quiz</a>
</div>
</aside>
<!-- Main Content -->
<div class="content">
<div class="container">
<!-- Inline TOC for mobile -->
<div class="toc" style="display:none;" id="mobile-toc">
<h4>Table of Contents</h4>
<a href="#variables">1. Variables & Expressions</a>
<a href="#linear-equations">2. Solving Linear Equations</a>
<a href="#inequalities">3. Inequalities</a>
<a href="#functions">4. Functions</a>
<a href="#systems">5. Systems of Equations</a>
<a href="#polynomials">6. Polynomials</a>
<a href="#factoring">7. Factoring</a>
<a href="#quadratics">8. Quadratic Equations</a>
<a href="#exponents">9. Exponent Rules</a>
<a href="#logarithms">10. Logarithms</a>
<a href="#sequences">11. Sequences & Series</a>
<a href="#quiz">12. Practice Quiz</a>
</div>
<!-- ==================== SECTION 1 ==================== -->
<section id="variables">
<h2>1. Variables and Expressions</h2>
<h3>What Are Variables?</h3>
<p>
A <strong>variable</strong> is a letter (like <em>x</em>, <em>y</em>, or <em>n</em>) that stands in for an unknown number. Think of it as a labeled box that can hold any value. In the expression <strong>x + 5</strong>, the variable <em>x</em> could be 1, 7, -3, or any other number -- we just don't know which one yet.
</p>
<p>
Variables let us write general rules that work for <em>any</em> number, not just a specific one. Instead of saying "3 plus 5 is 8," we can say "x + 5" and it works for every possible value of x.
</p>
<div class="example-box">
<div class="label">Variables in Daily Life</div>
<p>You use variables constantly without realizing it:</p>
<ul>
<li><strong>"I'll be there in <em>t</em> minutes"</strong> -- <em>t</em> is a variable for time</li>
<li><strong>"Speed limit is <em>s</em> mph"</strong> -- <em>s</em> varies by road</li>
<li><strong>"The bill comes to $<em>x</em>"</strong> -- <em>x</em> depends on what you ordered</li>
<li><strong>"There are <em>n</em> people coming"</strong> -- <em>n</em> is unknown until people RSVP</li>
</ul>
</div>
<div class="tip-box">
<div class="label">Why This Matters for CS</div>
<p>Variables in algebra are exactly the same idea as variables in programming. When you write <code>let x = 10;</code> in JavaScript or <code>x = 10</code> in Python, you're creating a named container that holds a value -- just like in algebra. Understanding algebraic variables makes programming variables intuitive.</p>
</div>
<h3>Algebraic Expressions</h3>
<p>
An <strong>algebraic expression</strong> is a mathematical phrase that contains numbers, variables, and operations. Here are the key vocabulary words:
</p>
<ul>
<li><strong>Term</strong> -- a single chunk separated by + or - signs. In <code>3x + 7</code>, the terms are <code>3x</code> and <code>7</code>.</li>
<li><strong>Coefficient</strong> -- the number multiplied by the variable. In <code>3x</code>, the coefficient is <strong>3</strong>.</li>
<li><strong>Constant</strong> -- a term with no variable. In <code>3x + 7</code>, the constant is <strong>7</strong>.</li>
<li><strong>Like terms</strong> -- terms with the same variable and exponent. <code>3x</code> and <code>5x</code> are like terms. <code>3x</code> and <code>3x²</code> are NOT like terms.</li>
</ul>
<h3>Simplifying Expressions</h3>
<p>To simplify an expression, <strong>combine like terms</strong> by adding or subtracting their coefficients.</p>
<div class="example-box">
<div class="label">Example -- Combining Like Terms</div>
<p>Simplify: <strong>4x + 3 + 2x - 1</strong></p>
<p>Step 1: Group the like terms: <code>(4x + 2x) + (3 - 1)</code></p>
<p>Step 2: Combine: <code>6x + 2</code></p>
<p>Answer: <strong>6x + 2</strong></p>
</div>
<div class="tip-box">
<div class="label">Visual Method for Beginners</div>
<p>If you're struggling with like terms, try color-coding or underlining. Use one color for all <em>x</em> terms, another for all <em>x²</em> terms, and another for constants. Only combine terms of the same color!</p>
</div>
<div class="example-box">
<div class="label">More Practice with Like Terms</div>
<p><strong>1) Simplify: 5a + 2b + 3a - b</strong><br>
Group: (5a + 3a) + (2b - b) = <strong>8a + b</strong></p>
<p><strong>2) Simplify: 2x² + 4x + x² - 2x + 7</strong><br>
Group: (2x² + x²) + (4x - 2x) + 7 = <strong>3x² + 2x + 7</strong></p>
<p><strong>3) Simplify: -3y + 5 + 7y - 2 + y</strong><br>
Group: (-3y + 7y + y) + (5 - 2) = <strong>5y + 3</strong></p>
<p><strong>Key insight:</strong> Only combine terms with identical variable parts. 3x and 3x² cannot be combined!</p>
</div>
<h3>The Distributive Property</h3>
<div class="formula-box">
a(b + c) = ab + ac
</div>
<p>
The distributive property says that multiplying a number by a group of numbers added together is the same as multiplying the number by each one individually and then adding the results. You "distribute" the multiplication across each term inside the parentheses.
</p>
<div class="example-box">
<div class="label">Example -- Distributive Property</div>
<p>Expand: <strong>3(2x + 4)</strong></p>
<p>Step 1: Multiply 3 by each term inside: <code>3 * 2x + 3 * 4</code></p>
<p>Step 2: Simplify: <code>6x + 12</code></p>
<p>Answer: <strong>6x + 12</strong></p>
</div>
<div class="example-box">
<div class="label">Example -- Distribute then Combine</div>
<p>Simplify: <strong>2(x + 3) + 4x</strong></p>
<p>Step 1: Distribute: <code>2x + 6 + 4x</code></p>
<p>Step 2: Combine like terms: <code>6x + 6</code></p>
<p>Answer: <strong>6x + 6</strong></p>
</div>
<div class="example-box">
<div class="label">More Distribution Practice</div>
<p><strong>1) Expand: 4(2x - 3)</strong><br>
4 × 2x + 4 × (-3) = <strong>8x - 12</strong></p>
<p><strong>2) Expand: -3(x + 5)</strong><br>
-3 × x + (-3) × 5 = <strong>-3x - 15</strong></p>
<p><strong>3) Expand: 0.5(4y - 6)</strong><br>
0.5 × 4y + 0.5 × (-6) = <strong>2y - 3</strong></p>
<p><strong>4) Expand and simplify: 3(2x + 1) - 2(x - 4)</strong><br>
= 6x + 3 - 2x + 8<br>
= (6x - 2x) + (3 + 8) = <strong>4x + 11</strong></p>
</div>
<div class="warning-box">
<div class="label">Common Mistake</div>
<p>Don't forget to distribute to <em>every</em> term inside the parentheses. A common error: writing <code>3(2x + 4) = 6x + 4</code> instead of the correct <code>6x + 12</code>. The 3 must multiply both the 2x AND the 4.</p>
</div>
<h3>Distributing with Fractions</h3>
<p>Distribution works the exact same way when fractions are involved. Your brain might panic, but the rule hasn't changed: <strong>multiply by each term inside the parentheses</strong>.</p>
<div class="formula-box">
<strong>The rule is always:</strong> a × (b + c) = a×b + a×c<br><br>
<span style="color:#555555;">It doesn't matter if a, b, or c are fractions, negatives, or have exponents. Same rule.</span>
</div>
<div class="example-box">
<div class="label">Example -- 3n × (40 + n³/2)</div>
<p>This is the kind of expression that shows up in Big-O analysis. Let's go step by step.</p>
<p style="margin-top:0.5rem;"><strong>Step 1: Identify what you're distributing</strong></p>
<p>a = 3n, b = 40, c = n³/2</p>
<p style="margin-top:0.5rem;"><strong>Step 2: Distribute -- multiply 3n by each term</strong></p>
<p>= 3n × 40 + 3n × (n³/2)</p>
<p style="margin-top:0.5rem;"><strong>Step 3: Simplify each part</strong></p>
<p>First part: 3n × 40 = <strong>120n</strong></p>
<p>Second part: 3n × n³ = 3n<sup>4</sup>, then ÷ 2 = <strong>3n<sup>4</sup>/2</strong></p>
<p style="margin-top:0.5rem;"><strong>Result:</strong> 120n + 3n<sup>4</sup>/2</p>
</div>
<div class="example-box">
<div class="label">Example -- n/2 × (n + 1)</div>
<p>This is n(n+1)/2 written differently. Let's distribute:</p>
<p>= (n/2) × n + (n/2) × 1</p>
<p>= n²/2 + n/2</p>
<p>= <strong>(n² + n) / 2</strong></p>
<p style="margin-top:0.5rem;"><em>This is the expanded form of n(n+1)/2 -- the sum of 1 to n.</em></p>
</div>
<div class="example-box">
<div class="label">Example -- Distributing a Negative with Fractions</div>
<p><strong>-(x/3 + 2/5)</strong></p>
<p>Distribute the -1:</p>
<p>= (-1) × x/3 + (-1) × 2/5</p>
<p>= <strong>-x/3 - 2/5</strong></p>
</div>
<h3>Splitting Fractions (When You Can and Can't)</h3>
<p>This is the source of so much confusion. Here's the <strong>exact rule</strong>:</p>
<div class="formula-box">
<strong>Splitting the NUMERATOR -- ALWAYS valid:</strong><br>
(a + b) / c = a/c + b/c ✓<br><br>
<strong>Splitting the DENOMINATOR -- NEVER valid:</strong><br>
c / (a + b) ≠ c/a + c/b ✗
</div>
<div class="example-box">
<div class="label">Valid Split: (40 + n³) / 2</div>
<p>The denominator is a single term (just 2), so we can split the numerator:</p>
<p>(40 + n³) / 2 = 40/2 + n³/2 = <strong>20 + n³/2</strong></p>
<p style="margin-top:0.5rem;">Why does this work? Division distributes over addition in the numerator. Think of dividing a pizza: if you split 8 slices among 2 people, each person gets 4. If you split (5 + 3) slices among 2 people, each gets 5/2 + 3/2 = 2.5 + 1.5 = 4. Same result.</p>
</div>
<div class="warning-box">
<div class="label">Invalid Split: DON'T Do This</div>
<p><code>12 / (x + 4) ≠ 12/x + 12/4</code></p>
<p>If x = 2: Left side = 12/6 = 2. Right side = 6 + 3 = 9. Not even close!</p>
<p style="margin-top:0.5rem;">When the <strong>denominator</strong> has addition/subtraction, you <strong>cannot</strong> split. The fraction must stay as one piece, or you need to find another approach.</p>
</div>
<h3>Common Denominator: Making Fractions Combine</h3>
<p>When you need to add a whole number to a fraction, convert the whole number to a fraction first:</p>
<div class="example-box">
<div class="label">Example -- Combining 40 + n³/2 Into One Fraction</div>
<p>Step 1: Write 40 as 40/1</p>
<p>Step 2: Common denominator is 2, so: 40/1 = 80/2</p>
<p>Step 3: Add: 80/2 + n³/2 = <strong>(80 + n³) / 2</strong></p>
<p style="margin-top:0.5rem;"><em>This is useful when you want to simplify an expression into a single fraction.</em></p>
</div>
<div class="example-box">
<div class="label">Example -- Combining 3n with a Fraction</div>
<p>You have 3n × 40/2. How to compute this?</p>
<p><strong>Method 1 (just multiply):</strong> 3n × 40/2 = (3n × 40) / 2 = 120n/2 = <strong>60n</strong></p>
<p><strong>Method 2 (simplify first):</strong> 40/2 = 20, so 3n × 20 = <strong>60n</strong></p>
<p>Both methods give the same answer. Use whichever feels simpler.</p>
</div>
</section>
<!-- ==================== SECTION 2 ==================== -->
<section id="linear-equations">
<h2>2. Solving Linear Equations</h2>
<p>
An <strong>equation</strong> is a statement that two expressions are equal, connected by an equals sign. <strong>Solving</strong> an equation means finding the value of the variable that makes the statement true.
</p>
<div class="formula-box">
The Golden Rule: Whatever you do to one side, you must do to the other.
</div>
<p>
This is the single most important idea in equation solving. An equation is like a perfectly balanced scale. If you add 5 to the left side, you must add 5 to the right side too, or the scale tips over and the equation becomes false.
</p>
<h3>One-Step Equations</h3>
<p>These require a single operation to isolate the variable.</p>
<div class="example-box">
<div class="label">Example 1 -- Addition</div>
<p>Solve: <strong>x + 5 = 12</strong></p>
<p>Goal: Get x by itself.</p>
<p>Subtract 5 from both sides: <code>x + 5 - 5 = 12 - 5</code></p>
<p>Result: <strong>x = 7</strong></p>
<p>Check: 7 + 5 = 12. Correct!</p>
</div>
<div class="tip-box">
<div class="label">Why Do We "Move" Numbers to the Other Side?</div>
<p>We don't actually move numbers. We add the same amount to both sides to keep the equation balanced. Saying "move 5 to the other side" is shorthand for "subtract 5 from both sides." The goal is always to isolate the variable.</p>
</div>
<div class="example-box">
<div class="label">Example 2 -- Multiplication</div>
<p>Solve: <strong>3x = 21</strong></p>
<p>Divide both sides by 3: <code>3x / 3 = 21 / 3</code></p>
<p>Result: <strong>x = 7</strong></p>
<p>Check: 3(7) = 21. Correct!</p>
</div>
<h3>Two-Step Equations</h3>
<p>Strategy: undo addition/subtraction first, then undo multiplication/division.</p>
<div class="example-box">
<div class="label">Example 3 -- Two Steps</div>
<p>Solve: <strong>2x + 3 = 11</strong></p>
<p>Step 1: Subtract 3 from both sides: <code>2x = 8</code></p>
<p>Step 2: Divide both sides by 2: <code>x = 4</code></p>
<p>Check: 2(4) + 3 = 8 + 3 = 11. Correct!</p>
</div>
<div class="example-box">
<div class="label">More Two-Step Practice</div>
<p><strong>1) Solve: 3x - 4 = 14</strong><br>
Add 4: 3x = 18<br>
Divide by 3: <strong>x = 6</strong><br>
Check: 3(6) - 4 = 18 - 4 = 14 ✓</p>
<p><strong>2) Solve: -2x + 7 = 1</strong><br>
Subtract 7: -2x = -6<br>
Divide by -2: <strong>x = 3</strong><br>
Check: -2(3) + 7 = -6 + 7 = 1 ✓</p>
<p><strong>3) Solve: 5 + 4y = 21</strong><br>
Subtract 5: 4y = 16<br>
Divide by 4: <strong>y = 4</strong><br>
Check: 5 + 4(4) = 5 + 16 = 21 ✓</p>
</div>
<div class="tip-box">
<div class="label">Strategy: Work Backwards from Order of Operations</div>
<p>To solve 2x + 3 = 11, ask yourself: "What operations were done to x?" Answer: "First multiplied by 2, then added 3." To undo this, work backwards: first subtract 3, then divide by 2. Always undo addition/subtraction before multiplication/division.</p>
</div>
<div class="example-box">
<div class="label">Example 4 -- Negative Coefficient</div>
<p>Solve: <strong>-5x + 10 = -15</strong></p>
<p>Step 1: Subtract 10 from both sides: <code>-5x = -25</code></p>
<p>Step 2: Divide both sides by -5: <code>x = 5</code></p>
<p>Check: -5(5) + 10 = -25 + 10 = -15. Correct!</p>
</div>
<h3>Multi-Step Equations (Variables on Both Sides)</h3>
<p>When the variable appears on both sides, move all variable terms to one side and all constants to the other.</p>
<div class="tip-box">
<div class="label">When You Get Negative Answers</div>
<p>Don't worry if x comes out negative! Many students think negative answers are "wrong," but they're often correct. For example, if x - 3 = -8, then x = -5. Negative numbers are perfectly valid solutions. Always check your answer by substituting back.</p>
</div>
<div class="example-box">
<div class="label">Example 5 -- Variables on Both Sides</div>
<p>Solve: <strong>5x + 3 = 2x + 18</strong></p>
<p>Step 1: Subtract 2x from both sides: <code>3x + 3 = 18</code></p>
<p>Step 2: Subtract 3 from both sides: <code>3x = 15</code></p>
<p>Step 3: Divide both sides by 3: <code>x = 5</code></p>
<p>Check: 5(5) + 3 = 28, and 2(5) + 18 = 28. Correct!</p>
</div>
<div class="example-box">
<div class="label">More Variables on Both Sides Practice</div>
<p><strong>1) Solve: 4x + 1 = x + 10</strong><br>
Subtract x: 3x + 1 = 10<br>
Subtract 1: 3x = 9<br>
Divide by 3: <strong>x = 3</strong></p>
<p><strong>2) Solve: 6y - 5 = 4y + 7</strong><br>
Subtract 4y: 2y - 5 = 7<br>
Add 5: 2y = 12<br>
Divide by 2: <strong>y = 6</strong></p>
<p><strong>3) Solve: 3a + 8 = 7a - 4</strong><br>
Subtract 3a: 8 = 4a - 4<br>
Add 4: 12 = 4a<br>
Divide by 4: <strong>a = 3</strong></p>
</div>
<div class="example-box">
<div class="label">Example 6 -- Distributive Property First</div>
<p>Solve: <strong>3(x - 2) = 2x + 1</strong></p>
<p>Step 1: Distribute: <code>3x - 6 = 2x + 1</code></p>
<p>Step 2: Subtract 2x from both sides: <code>x - 6 = 1</code></p>
<p>Step 3: Add 6 to both sides: <code>x = 7</code></p>
<p>Check: 3(7 - 2) = 3(5) = 15, and 2(7) + 1 = 15. Correct!</p>
</div>
<h3>Equations with Fractions</h3>
<p>The trick: <strong>multiply every term by the least common denominator (LCD)</strong> to clear all the fractions first. Then solve normally.</p>
<div class="example-box">
<div class="label">Example 7 -- Clearing Fractions</div>
<p>Solve: <strong>(x/2) + (x/3) = 5</strong></p>
<p>The LCD of 2 and 3 is 6. Multiply every term by 6:</p>
<p><code>6(x/2) + 6(x/3) = 6(5)</code></p>
<p><code>3x + 2x = 30</code></p>
<p><code>5x = 30</code></p>
<p><code>x = 6</code></p>
<p>Check: 6/2 + 6/3 = 3 + 2 = 5. Correct!</p>
</div>
<div class="warning-box">
<div class="label">Common Mistake</div>
<p>When clearing fractions, you must multiply <em>every single term</em> by the LCD -- including terms that aren't fractions. A very common error is only multiplying the fraction terms and forgetting the constant on the other side.</p>
</div>
<div class="tip-box">
<div class="label">Why This Matters for CS</div>
<p>Solving equations is essentially what computers do when they evaluate expressions and solve algorithms. When you write code that calculates a value from a formula -- say, converting Celsius to Fahrenheit with <code>f = (9/5) * c + 32</code> -- you're applying the same equation-solving logic. Understanding how to rearrange formulas is also key for deriving algorithms, analyzing complexity, and optimizing code.</p>
</div>
</section>
<!-- ==================== SECTION 3 ==================== -->
<section id="inequalities">
<h2>3. Inequalities</h2>
<p>
An <strong>inequality</strong> is like an equation, but instead of saying two things are equal, it says one is bigger or smaller. The four inequality symbols are:
</p>
<table>
<thead>
<tr><th>Symbol</th><th>Meaning</th><th>Example</th></tr>
</thead>
<tbody>
<tr><td><</td><td>Less than</td><td>x < 5 (x is less than 5)</td></tr>
<tr><td>></td><td>Greater than</td><td>x > 3 (x is greater than 3)</td></tr>
<tr><td>≤</td><td>Less than or equal to</td><td>x ≤ 10 (x is at most 10)</td></tr>
<tr><td>≥</td><td>Greater than or equal to</td><td>x ≥ 0 (x is non-negative)</td></tr>
</tbody>
</table>
<h3>Solving Inequalities</h3>
<p>
You solve inequalities almost exactly like equations, with <strong>one critical exception</strong>: when you multiply or divide both sides by a <strong>negative number</strong>, you must <strong>flip the inequality sign</strong>.
</p>
<div class="example-box">
<div class="label">Example -- Standard Inequality</div>
<p>Solve: <strong>2x + 1 < 9</strong></p>
<p>Step 1: Subtract 1 from both sides: <code>2x < 8</code></p>
<p>Step 2: Divide both sides by 2: <code>x < 4</code></p>
<p>Solution: x can be any number less than 4.</p>
</div>
<div class="example-box">
<div class="label">Example -- Flipping the Sign</div>
<p>Solve: <strong>-3x + 6 ≤ 15</strong></p>
<p>Step 1: Subtract 6 from both sides: <code>-3x ≤ 9</code></p>
<p>Step 2: Divide both sides by -3 <strong>(flip the sign!)</strong>: <code>x ≥ -3</code></p>
<p>Solution: x can be -3 or any number greater than -3.</p>
</div>
<div class="warning-box">
<div class="label">Common Mistake</div>
<p>Forgetting to flip the inequality sign when multiplying or dividing by a negative number. This is the number one mistake students make with inequalities. Ask yourself: "Am I dividing by a negative?" If yes, flip the sign.</p>
</div>
<h3>Graphing Inequalities on a Number Line</h3>
<p>
You can visualize inequality solutions on a number line:
</p>
<ul>
<li><strong>x < 4</strong> -- Draw an <strong>open circle</strong> at 4 (meaning 4 is NOT included) and shade everything to the <strong>left</strong>.</li>
<li><strong>x ≥ -3</strong> -- Draw a <strong>filled circle</strong> at -3 (meaning -3 IS included) and shade everything to the <strong>right</strong>.</li>
<li>Open circle = strict inequality (< or >), filled circle = includes the endpoint (≤ or ≥).</li>
</ul>
<div class="tip-box">
<div class="label">Why This Matters for CS</div>
<p>Inequalities show up constantly in programming: loop conditions (<code>while i < n</code>), array bounds checking (<code>if index >= 0 && index < length</code>), and algorithm analysis ("this algorithm runs in O(n) when n ≥ 1"). Understanding how inequalities work helps you reason about when loops terminate and whether your array accesses are safe.</p>
</div>
</section>
<!-- ==================== SECTION 4 ==================== -->
<section id="functions">
<h2>4. Functions</h2>
<h3>What Is a Function?</h3>
<p>
A <strong>function</strong> is an input-output machine: you feed it an input, it follows a rule, and it produces exactly one output. The key idea is that <em>each input gives exactly one output</em>. If you put the same number in twice, you get the same result both times.
</p>
<p>
We usually write functions using the notation <strong>f(x)</strong>, which reads as "f of x." The letter f is the name of the function, and x is the input. For example:
</p>
<div class="formula-box">
f(x) = 2x + 3
</div>
<p>This function takes any number x, doubles it, then adds 3.</p>
<div class="example-box">
<div class="label">Example -- Evaluating a Function</div>
<p>If <strong>f(x) = 2x + 3</strong>, find f(4).</p>
<p>Replace x with 4: <code>f(4) = 2(4) + 3 = 8 + 3 = 11</code></p>
<p>Answer: <strong>f(4) = 11</strong></p>
</div>
<h3>Domain and Range</h3>
<ul>
<li><strong>Domain</strong> -- the set of all valid inputs (x-values). Ask: "What values of x can I plug in without breaking anything?"</li>
<li><strong>Range</strong> -- the set of all possible outputs (y-values). Ask: "What values can actually come out?"</li>
</ul>
<p>
For example, the function f(x) = 1/x has a domain of all real numbers <em>except 0</em> (because dividing by zero is undefined). Its range is also all real numbers except 0 (because 1/x never equals zero).
</p>
<h3>Linear Functions: y = mx + b</h3>
<p>
The most important type of function in beginning algebra is the <strong>linear function</strong>. Its graph is a straight line.
</p>
<div class="formula-box">
y = mx + b<br><br>
m = slope (steepness and direction of the line)<br>
b = y-intercept (where the line crosses the y-axis)
</div>
<ul>
<li><strong>Slope (m)</strong> tells you how much y changes for each 1-unit increase in x. A slope of 2 means "go up 2 for every 1 you go right." A negative slope means the line goes downhill.</li>
<li><strong>Y-intercept (b)</strong> is the y-value when x = 0. It's where the line crosses the vertical axis.</li>
</ul>
<div class="example-box">
<div class="label">Example -- Identifying Slope and Intercept</div>
<p>For the line <strong>y = -3x + 7</strong>:</p>
<p>Slope: <strong>m = -3</strong> (the line goes down 3 units for every 1 unit to the right)</p>
<p>Y-intercept: <strong>b = 7</strong> (the line crosses the y-axis at the point (0, 7))</p>
</div>
<h3>Slope Formula</h3>
<p>Given two points on a line, (x<sub>1</sub>, y<sub>1</sub>) and (x<sub>2</sub>, y<sub>2</sub>), the slope is:</p>
<div class="formula-box">
m = (y<sub>2</sub> - y<sub>1</sub>) / (x<sub>2</sub> - x<sub>1</sub>)
</div>
<p>This is often described as "rise over run" -- the vertical change divided by the horizontal change.</p>
<div class="example-box">
<div class="label">Example -- Finding Slope from Two Points</div>
<p>Find the slope of the line through <strong>(1, 2)</strong> and <strong>(4, 11)</strong>.</p>
<p><code>m = (11 - 2) / (4 - 1) = 9 / 3 = 3</code></p>
<p>The slope is <strong>3</strong>. The line rises 3 units for every 1 unit to the right.</p>
</div>
<h3>Understanding Slope Intuitively</h3>
<div class="example-box">
<div class="label">Slope in Different Contexts</div>
<p><strong>Positive slope:</strong> Line goes upward left-to-right (like climbing a hill)</p>
<p>• m = 2: For every 1 step right, go up 2 steps</p>
<p>• m = 0.5: For every 1 step right, go up 0.5 steps (gentle incline)</p>
<p><strong>Negative slope:</strong> Line goes downward left-to-right (like descending a hill)</p>
<p>• m = -1: For each 1 step right, go down 1 step (45° decline)</p>
<p>• m = -3: For each 1 step right, go down 3 steps (steep decline)</p>
<p><strong>Zero slope:</strong> m = 0 means horizontal line (no rise or fall)</p>
<p><strong>Undefined slope:</strong> Vertical line (infinite steepness)</p>
</div>
<h3>Finding the Equation of a Line</h3>
<div class="example-box">
<div class="label">Given Slope and Y-Intercept</div>
<p><strong>Write the equation of a line with slope -2 and y-intercept 5:</strong></p>
<p>Use y = mx + b directly: <strong>y = -2x + 5</strong></p>
</div>
<div class="example-box">
<div class="label">Given Two Points</div>
<p><strong>Find the equation passing through (3, 7) and (5, 13):</strong></p>
<p>Step 1: Find slope: m = (13 - 7)/(5 - 3) = 6/2 = 3</p>
<p>Step 2: Use point-slope form with either point. Using (3, 7):</p>
<p>y - 7 = 3(x - 3)</p>
<p>y - 7 = 3x - 9</p>
<p>y = 3x - 2</p>
<p><strong>Answer: y = 3x - 2</strong></p>
<p>Check with other point: 3(5) - 2 = 15 - 2 = 13 ✓</p>
</div>
<div class="example-box">
<div class="label">Given Slope and One Point</div>
<p><strong>Find the equation with slope 4 passing through (-1, 3):</strong></p>
<p>Point-slope form: y - y₁ = m(x - x₁)</p>
<p>y - 3 = 4(x - (-1))</p>
<p>y - 3 = 4(x + 1)</p>
<p>y - 3 = 4x + 4</p>
<p><strong>y = 4x + 7</strong></p>
</div>
<h3>Graphing Lines Step-by-Step</h3>
<div class="tip-box">
<div class="label">Method 1: Using Slope and Y-Intercept</div>
<p>For y = 2x - 3:</p>
<p>1. Plot the y-intercept: (0, -3)</p>
<p>2. Use slope 2 = 2/1 to find next point: from (0, -3), go right 1 and up 2 to reach (1, -1)</p>
<p>3. Continue: from (1, -1) go right 1 and up 2 to reach (2, 1)</p>
<p>4. Draw line through these points</p>
</div>
<div class="tip-box">
<div class="label">Method 2: Using Two Points</div>
<p>For y = -x + 4:</p>
<p>1. Choose any x-values, say x = 0 and x = 4</p>
<p>2. When x = 0: y = -(0) + 4 = 4, so (0, 4)</p>
<p>3. When x = 4: y = -(4) + 4 = 0, so (4, 0)</p>
<p>4. Plot these points and draw the line</p>
</div>
<h3>Special Forms of Linear Equations</h3>
<div class="formula-box">
Standard Form: Ax + By = C<br>
Point-Slope Form: y - y₁ = m(x - x₁)<br>
Slope-Intercept Form: y = mx + b<br>
Intercept Form: x/a + y/b = 1
</div>
<div class="example-box">
<div class="label">Converting Between Forms</div>
<p><strong>Convert 3x + 2y = 6 to slope-intercept form:</strong></p>
<p>Solve for y:</p>
<p>2y = -3x + 6</p>
<p>y = (-3x + 6)/2</p>
<p><strong>y = -1.5x + 3</strong></p>
<p>So slope = -1.5, y-intercept = 3</p>
</div>
<div class="tip-box">
<div class="label">Why This Matters for CS</div>
<p>Functions in algebra map directly to functions in programming. The concept of domain is like input validation -- what inputs are acceptable? In graphics programming, linear functions define lines on screen. Slope appears in machine learning as the "weight" in linear regression models. And the idea that a function always produces the same output for the same input is the foundation of "pure functions" in functional programming.</p>
</div>
</section>
<!-- ==================== SECTION 5 ==================== -->
<section id="systems">
<h2>5. Systems of Equations</h2>
<p>
A <strong>system of equations</strong> is a set of two (or more) equations with the same variables. The <strong>solution</strong> is the values of the variables that satisfy ALL equations simultaneously. Geometrically, for two linear equations, the solution is where the two lines intersect.
</p>
<h3>Method 1: Substitution</h3>
<p>
<strong>Idea:</strong> Solve one equation for one variable, then substitute that expression into the other equation.
</p>
<div class="example-box">
<div class="label">Example -- Substitution Method</div>
<p>Solve the system:</p>
<p><code>y = 2x + 1</code> ... (Equation 1)</p>
<p><code>3x + y = 16</code> ... (Equation 2)</p>
<p><strong>Step 1:</strong> Equation 1 already has y isolated: <code>y = 2x + 1</code></p>
<p><strong>Step 2:</strong> Substitute into Equation 2:</p>
<p><code>3x + (2x + 1) = 16</code></p>
<p><code>5x + 1 = 16</code></p>
<p><code>5x = 15</code></p>
<p><code>x = 3</code></p>
<p><strong>Step 3:</strong> Plug x = 3 back into Equation 1:</p>
<p><code>y = 2(3) + 1 = 7</code></p>
<p>Solution: <strong>(x, y) = (3, 7)</strong></p>
<p>Check in Equation 2: 3(3) + 7 = 9 + 7 = 16. Correct!</p>
</div>
<h3>Method 2: Elimination</h3>
<p>
<strong>Idea:</strong> Add or subtract the equations to eliminate one variable.
</p>
<div class="example-box">
<div class="label">Example -- Elimination Method</div>
<p>Solve the system:</p>
<p><code>2x + 3y = 12</code> ... (Equation 1)</p>
<p><code>4x - 3y = 6</code> ... (Equation 2)</p>
<p><strong>Step 1:</strong> Notice that 3y and -3y will cancel if we add the equations.</p>
<p><strong>Step 2:</strong> Add Equation 1 + Equation 2:</p>
<p><code>(2x + 4x) + (3y - 3y) = 12 + 6</code></p>
<p><code>6x = 18</code></p>
<p><code>x = 3</code></p>
<p><strong>Step 3:</strong> Plug x = 3 into Equation 1:</p>
<p><code>2(3) + 3y = 12</code></p>
<p><code>6 + 3y = 12</code></p>
<p><code>3y = 6</code></p>
<p><code>y = 2</code></p>
<p>Solution: <strong>(x, y) = (3, 2)</strong></p>
<p>Check in Equation 2: 4(3) - 3(2) = 12 - 6 = 6. Correct!</p>
</div>
<div class="example-box">
<div class="label">Example -- Elimination with Multiplication</div>
<p>Solve the system:</p>
<p><code>3x + 2y = 16</code> ... (Equation 1)</p>
<p><code>x + 4y = 22</code> ... (Equation 2)</p>
<p><strong>Step 1:</strong> The variables don't cancel yet. Multiply Equation 2 by -3 so the x terms cancel:</p>
<p><code>3x + 2y = 16</code></p>
<p><code>-3x - 12y = -66</code></p>
<p><strong>Step 2:</strong> Add the equations:</p>
<p><code>-10y = -50</code></p>
<p><code>y = 5</code></p>
<p><strong>Step 3:</strong> Plug y = 5 into Equation 2:</p>
<p><code>x + 4(5) = 22</code></p>
<p><code>x + 20 = 22</code></p>
<p><code>x = 2</code></p>
<p>Solution: <strong>(x, y) = (2, 5)</strong></p>
</div>
<div class="tip-box">
<div class="label">Which Method Should You Use?</div>
<p><strong>Substitution</strong> is easiest when one variable is already isolated (like y = ...) or has a coefficient of 1. <strong>Elimination</strong> is easiest when the coefficients line up nicely or can be made to cancel with simple multiplication.</p>
</div>
<div class="tip-box">
<div class="label">Why This Matters for CS</div>
<p>Systems of equations are everywhere in CS. In computer graphics, finding where two lines intersect is solving a 2-variable system. Linear programming (used for optimization problems like scheduling and resource allocation) involves solving systems of equations and inequalities. Machine learning's linear regression solves systems of equations to find the best-fit line. At scale, these become matrix equations -- which is why linear algebra matters so much for CS.</p>
</div>
<h3>Understanding Solutions Graphically</h3>
<div class="tip-box">
<div class="label">What Does the Solution Mean?</div>
<p>The solution to a system of two linear equations is the <strong>intersection point</strong> of the two lines. This point satisfies both equations simultaneously.</p>
</div>
<div class="example-box">
<div class="label">Types of Solutions</div>
<p><strong>One Solution (Most Common):</strong> Lines intersect at exactly one point</p>
<p>• Example: y = 2x + 1 and y = -x + 4 intersect at (1, 3)</p>
<p><strong>No Solution:</strong> Lines are parallel (never intersect)</p>
<p>• Example: y = 2x + 1 and y = 2x + 5 (same slope, different y-intercepts)</p>
<p><strong>Infinite Solutions:</strong> Lines are identical (overlap completely)</p>
<p>• Example: y = 2x + 1 and 2y = 4x + 2 (same line written differently)</p>
</div>
<h3>More Practice Examples</h3>
<div class="example-box">
<div class="label">Substitution Method Practice</div>
<p><strong>Solve: x + y = 5 and 2x - y = 1</strong></p>
<p>From equation 1: y = 5 - x</p>
<p>Substitute into equation 2: 2x - (5 - x) = 1</p>
<p>2x - 5 + x = 1</p>
<p>3x = 6</p>
<p>x = 2</p>
<p>So y = 5 - 2 = 3</p>
<p><strong>Solution: (2, 3)</strong></p>
<p>Check: 2 + 3 = 5 ✓ and 2(2) - 3 = 1 ✓</p>
</div>
<div class="example-box">
<div class="label">Elimination Method Practice</div>
<p><strong>Solve: 2x + 3y = 7 and 4x - 3y = 5</strong></p>
<p>Notice the y-coefficients are opposites (3 and -3), so add directly:</p>
<p>(2x + 4x) + (3y - 3y) = 7 + 5</p>
<p>6x = 12</p>
<p>x = 2</p>
<p>Substitute back: 2(2) + 3y = 7 → 4 + 3y = 7 → y = 1</p>
<p><strong>Solution: (2, 1)</strong></p>
</div>
<div class="example-box">
<div class="label">Real-World Application</div>
<p><strong>Concert tickets cost $15 for adults and $8 for children. If 200 tickets were sold for $2,250 total, how many of each type were sold?</strong></p>
<p>Let a = adult tickets, c = child tickets</p>
<p>Total tickets: a + c = 200</p>
<p>Total revenue: 15a + 8c = 2250</p>
<p>From equation 1: c = 200 - a</p>
<p>Substitute: 15a + 8(200 - a) = 2250</p>
<p>15a + 1600 - 8a = 2250</p>
<p>7a = 650</p>
<p>a = ~93 adult tickets, c = ~107 child tickets</p>
</div>
</section>
<!-- ==================== SECTION 6 ==================== -->
<section id="polynomials">
<h2>6. Polynomials</h2>
<h3>What Are Polynomials?</h3>
<p>
A <strong>polynomial</strong> is an expression made up of terms where variables are raised to non-negative integer powers. Each term has a coefficient and a variable part. Here are some examples:
</p>
<ul>
<li><code>5x + 3</code> -- a polynomial with 2 terms (a <strong>binomial</strong>)</li>
<li><code>x² + 4x - 7</code> -- a polynomial with 3 terms (a <strong>trinomial</strong>)</li>
<li><code>2x³ - x² + 5x - 1</code> -- a polynomial with 4 terms</li>
</ul>
<p>
The <strong>degree</strong> of a polynomial is the highest exponent. The degree of <code>x² + 4x - 7</code> is <strong>2</strong>. The degree of <code>2x³ - x² + 5x - 1</code> is <strong>3</strong>.
</p>
<h3>Adding and Subtracting Polynomials</h3>
<p>Simply combine like terms (terms with the same variable and exponent).</p>
<div class="example-box">
<div class="label">Example -- Adding Polynomials</div>
<p><strong>(3x² + 2x + 1) + (x² - 5x + 4)</strong></p>
<p>Combine like terms:</p>
<p>x² terms: <code>3x² + x² = 4x²</code></p>
<p>x terms: <code>2x + (-5x) = -3x</code></p>
<p>Constants: <code>1 + 4 = 5</code></p>
<p>Answer: <strong>4x² - 3x + 5</strong></p>
</div>
<div class="example-box">
<div class="label">Example -- Subtracting Polynomials</div>
<p><strong>(5x² + 3x - 2) - (2x² - x + 6)</strong></p>
<p>Distribute the negative sign: <code>5x² + 3x - 2 - 2x² + x - 6</code></p>
<p>Combine like terms: <code>3x² + 4x - 8</code></p>
<p>Answer: <strong>3x² + 4x - 8</strong></p>
</div>
<div class="warning-box">
<div class="label">Common Mistake</div>
<p>When subtracting polynomials, remember to distribute the negative sign to <em>every</em> term in the second polynomial. A common error: <code>(5x² + 3x - 2) - (2x² - x + 6) = 3x² + 2x + 4</code>. The mistake is not flipping -x to +x and +6 to -6.</p>
</div>
<h3>Multiplying Polynomials (FOIL)</h3>
<p>
To multiply two binomials, use <strong>FOIL</strong>: <strong>F</strong>irst, <strong>O</strong>uter, <strong>I</strong>nner, <strong>L</strong>ast.
</p>
<div class="example-box">
<div class="label">Example -- FOIL Method</div>
<p>Multiply: <strong>(x + 3)(x + 5)</strong></p>
<p><strong>F</strong>irst: <code>x * x = x²</code></p>
<p><strong>O</strong>uter: <code>x * 5 = 5x</code></p>
<p><strong>I</strong>nner: <code>3 * x = 3x</code></p>
<p><strong>L</strong>ast: <code>3 * 5 = 15</code></p>
<p>Combine: <code>x² + 5x + 3x + 15 = x² + 8x + 15</code></p>
<p>Answer: <strong>x² + 8x + 15</strong></p>
</div>
<div class="example-box">
<div class="label">Example -- FOIL with Negatives</div>
<p>Multiply: <strong>(2x - 1)(x + 4)</strong></p>
<p><strong>F</strong>irst: <code>2x * x = 2x²</code></p>
<p><strong>O</strong>uter: <code>2x * 4 = 8x</code></p>
<p><strong>I</strong>nner: <code>-1 * x = -x</code></p>
<p><strong>L</strong>ast: <code>-1 * 4 = -4</code></p>
<p>Combine: <code>2x² + 8x - x - 4 = 2x² + 7x - 4</code></p>
<p>Answer: <strong>2x² + 7x - 4</strong></p>
</div>
<div class="tip-box">
<div class="label">Beyond FOIL</div>
<p>FOIL only works for two binomials. For larger polynomials, use the general rule: multiply every term in the first polynomial by every term in the second, then combine like terms. FOIL is just a shortcut for this process when each polynomial has exactly two terms.</p>
</div>
<h3>Special Products (Memorize These!)</h3>
<p>These patterns appear so often that memorizing them will save you time and reduce errors.</p>
<h4>Perfect Square Trinomials</h4>
<div class="formula-box">
(a + b)² = a² + 2ab + b²<br>
(a - b)² = a² - 2ab + b²
</div>
<div class="example-box">
<div class="label">Example: Expanding (x + 5)²</div>
<p>(x + 5)² = x² + 2(x)(5) + 5²</p>
<p>= x² + 10x + 25</p>
</div>
<div class="example-box">
<div class="label">Example: Expanding (3y - 2)²</div>
<p>(3y - 2)² = (3y)² - 2(3y)(2) + 2²</p>
<p>= 9y² - 12y + 4</p>
</div>
<div class="warning-box">
<div class="label">Common Mistake</div>
<p><strong>(x + 5)² ≠ x² + 25!</strong></p>
<p>You MUST include the middle term (2ab). This is one of the most common algebra mistakes.</p>
</div>
<h4>Difference of Squares</h4>
<div class="formula-box">
(a + b)(a - b) = a² - b²
</div>
<div class="example-box">
<div class="label">Example: (x + 7)(x - 7)</div>
<p>= x² - 7² = x² - 49</p>
<p>The middle terms cancel out because one is +7x and one is -7x.</p>
</div>
<h4>Sum and Difference of Cubes</h4>
<div class="formula-box">
a³ + b³ = (a + b)(a² - ab + b²)<br>
a³ - b³ = (a - b)(a² + ab + b²)
</div>
<div class="tip-box">
<div class="label">Memory Trick: SOAP</div>
<p>For a³ ± b³, use SOAP: <strong>S</strong>ame sign, <strong>O</strong>pposite sign, <strong>A</strong>lways <strong>P</strong>ositive</p>
<p>a³ + b³ = (a <strong>+</strong> b)(a² <strong>-</strong> ab <strong>+</strong> b²)</p>
</div>
<h3>Multiplying Polynomials with More Than Two Terms</h3>
<div class="example-box">
<div class="label">Example: (x + 2)(x² + 3x - 1)</div>
<p>Distribute each term in the first polynomial:</p>
<p>= x(x² + 3x - 1) + 2(x² + 3x - 1)</p>
<p>= x³ + 3x² - x + 2x² + 6x - 2</p>
<p>= <strong>x³ + 5x² + 5x - 2</strong></p>
</div>
<div class="example-box">
<div class="label">Example: (x² + x + 1)(x - 1)</div>