ลบเจอบวกเป็นอะไร — กฎการคูณเครื่องหมาย
ลบเจอบวกเป็นอะไร? คำตอบคือ "ลบ" (-) เมื่อนำจำนวนลบ (negative) คูณหรือหารกับจำนวนบวก (positive) ผลลัพธ์จะเป็นลบเสมอ นี่เป็นกฎพื้นฐานของคณิตศาสตร์ที่ใช้ในชีวิตประจำวัน การเขียนโปรแกรม การเงิน และวิทยาศาสตร์ บทความนี้อธิบายกฎการคูณเครื่องหมาย หลักการทางคณิตศาสตร์ ตัวอย่างประยุกต์ใช้ และ Python code สำหรับทำความเข้าใจกฎนี้อย่างละเอียด
กฎการคูณเครื่องหมาย
# sign_rules.py — Sign multiplication rules
import json
class SignRules:
RULES = {
"pos_x_pos": {
"operation": "(+) × (+) = (+)",
"example": "3 × 5 = 15",
"explanation": "บวก × บวก = บวก",
},
"neg_x_neg": {
"operation": "(-) × (-) = (+)",
"example": "(-3) × (-5) = 15",
"explanation": "ลบ × ลบ = บวก",
},
"pos_x_neg": {
"operation": "(+) × (-) = (-)",
"example": "3 × (-5) = -15",
"explanation": "บวก × ลบ = ลบ (บวกเจอลบ = ลบ)",
},
"neg_x_pos": {
"operation": "(-) × (+) = (-)",
"example": "(-3) × 5 = -15",
"explanation": "ลบ × บวก = ลบ (ลบเจอบวก = ลบ)",
},
}
DIVISION_RULES = {
"pos_div_pos": "(+) ÷ (+) = (+) → 15 ÷ 3 = 5",
"neg_div_neg": "(-) ÷ (-) = (+) → (-15) ÷ (-3) = 5",
"pos_div_neg": "(+) ÷ (-) = (-) → 15 ÷ (-3) = -5",
"neg_div_pos": "(-) ÷ (+) = (-) → (-15) ÷ 3 = -5",
}
SUMMARY = """
สรุปง่ายๆ:
เครื่องหมายเหมือนกัน → ผลลัพธ์เป็นบวก (+)
(+)(+) = (+)
(-)(-) = (+)
เครื่องหมายต่างกัน → ผลลัพธ์เป็นลบ (-)
(+)(-) = (-)
(-)(+) = (-)
กฎนี้ใช้ได้ทั้งการคูณ (×) และการหาร (÷)
"""
def show_rules(self):
print("=== กฎการคูณเครื่องหมาย ===\n")
for key, rule in self.RULES.items():
print(f" {rule['operation']:>20} → {rule['example']}")
print(f" {'':>20} ({rule['explanation']})")
print()
def show_division(self):
print("=== กฎการหารเครื่องหมาย ===")
for key, rule in self.DIVISION_RULES.items():
print(f" {rule}")
def show_summary(self):
print(self.SUMMARY)
rules = SignRules()
rules.show_rules()
rules.show_division()
rules.show_summary()
ทำไมลบคูณลบถึงเป็นบวก
# proof.py — Why negative × negative = positive
import json
class NegativeTimesNegative:
EXPLANATIONS = {
"pattern": {
"name": "1. ดูจาก Pattern (รูปแบบ)",
"steps": [
"(-3) × 3 = -9",
"(-3) × 2 = -6",
"(-3) × 1 = -3",
"(-3) × 0 = 0",
"(-3) × (-1) = ???",
],
"observation": "ทุกครั้งที่ตัวคูณลด 1 → ผลลัพธ์เพิ่ม 3",
"conclusion": "(-3) × (-1) = 0 + 3 = 3 (บวก!)",
},
"debt": {
"name": "2. เปรียบเทียบกับหนี้",
"analogy": [
"บวก = ได้เงิน, ลบ = เป็นหนี้",
"(+3) × (+5) = ได้เงิน 3 ครั้ง ครั้งละ 5 = ได้ 15",
"(-3) × (+5) = เป็นหนี้ 3 ครั้ง ครั้งละ 5 = หนี้ 15 = -15",
"(+3) × (-5) = ได้หนี้ 3 ใบ ใบละ 5 = หนี้ 15 = -15",
"(-3) × (-5) = ยกเลิกหนี้ 3 ใบ ใบละ 5 = ได้คืน 15 = +15",
],
},
"algebraic": {
"name": "3. พิสูจน์ทางพีชคณิต",
"proof": [
"เรารู้ว่า: a + (-a) = 0",
"ดังนั้น: (-3) × [5 + (-5)] = (-3) × 0 = 0",
"กระจาย: (-3)(5) + (-3)(-5) = 0",
"เรารู้: (-3)(5) = -15",
"ดังนั้น: -15 + (-3)(-5) = 0",
"แก้สมการ: (-3)(-5) = 15 (บวก!)",
],
},
}
def show_explanations(self):
print("=== ทำไม (-) × (-) = (+) ===\n")
for key, exp in self.EXPLANATIONS.items():
print(f"[{exp['name']}]")
items = exp.get('steps') or exp.get('analogy') or exp.get('proof')
for item in items[:5]:
print(f" {item}")
if 'conclusion' in exp:
print(f" → {exp['conclusion']}")
print()
proof = NegativeTimesNegative()
proof.show_explanations()
Python Calculator
# calculator.py — Python sign calculator
import json
class SignCalculator:
def multiply(self, a, b):
result = a * b
a_sign = "+" if a >= 0 else "-"
b_sign = "+" if b >= 0 else "-"
r_sign = "+" if result >= 0 else "-"
return {
"expression": f"({a}) × ({b})",
"result": result,
"rule": f"({a_sign}) × ({b_sign}) = ({r_sign})",
}
def divide(self, a, b):
if b == 0:
return {"error": "หารด้วย 0 ไม่ได้!"}
result = a / b
a_sign = "+" if a >= 0 else "-"
b_sign = "+" if b >= 0 else "-"
r_sign = "+" if result >= 0 else "-"
return {
"expression": f"({a}) ÷ ({b})",
"result": result,
"rule": f"({a_sign}) ÷ ({b_sign}) = ({r_sign})",
}
def practice_problems(self):
problems = [
(7, -3), (-4, 6), (-8, -2), (5, 9),
(-12, -4), (10, -5), (-6, 3), (-7, -7),
]
print("=== แบบฝึกหัด: คูณเครื่องหมาย ===\n")
for a, b in problems:
r = self.multiply(a, b)
print(f" {r['expression']:>15} = {r['result']:>6} {r['rule']}")
def verify_rules(self):
print(f"\n=== ตรวจสอบกฎ (Python) ===")
cases = [
("บวก × บวก", 5, 3),
("ลบ × ลบ", -5, -3),
("บวก × ลบ", 5, -3),
("ลบ × บวก", -5, 3),
]
for label, a, b in cases:
result = a * b
sign = "บวก (+)" if result > 0 else "ลบ (-)" if result < 0 else "ศูนย์ (0)"
print(f" {label:<12}: ({a}) × ({b}) = {result:>4} → {sign}")
def real_world(self):
print(f"\n=== ตัวอย่างในชีวิตจริง ===")
examples = [
{"scenario": "ขาดทุนวันละ 500 บาท เป็นเวลา 7 วัน", "calc": "(-500) × 7 = -3,500", "meaning": "ขาดทุนรวม 3,500 บาท"},
{"scenario": "ยกเลิกค่าปรับ 200 บาท 3 ครั้ง", "calc": "(-200) × (-3) = 600", "meaning": "ได้คืน 600 บาท"},
{"scenario": "อุณหภูมิลด 2°C ต่อชั่วโมง เป็นเวลา 5 ชม.", "calc": "(-2) × 5 = -10", "meaning": "อุณหภูมิลดลง 10°C"},
]
for ex in examples:
print(f" {ex['scenario']}")
print(f" คำนวณ: {ex['calc']}")
print(f" ความหมาย: {ex['meaning']}")
print()
calc = SignCalculator()
calc.practice_problems()
calc.verify_rules()
calc.real_world()
การบวกและการลบจำนวนลบ
# addition_subtraction.py — Addition and subtraction with negatives
import json
class AddSubNegatives:
RULES = {
"add_pos_pos": {"rule": "(+) + (+) = (+)", "example": "5 + 3 = 8"},
"add_neg_neg": {"rule": "(-) + (-) = (-)", "example": "(-5) + (-3) = -8 (รวมค่าสัมบูรณ์ ใส่เครื่องหมายลบ)"},
"add_pos_neg": {"rule": "(+) + (-) = ขึ้นกับค่าสัมบูรณ์", "example": "5 + (-3) = 2 (5 มากกว่า → ผลเป็นบวก)"},
"add_neg_pos": {"rule": "(-) + (+) = ขึ้นกับค่าสัมบูรณ์", "example": "(-5) + 3 = -2 (5 มากกว่า → ผลเป็นลบ)"},
"sub_rule": {"rule": "a - b = a + (-b)", "example": "5 - (-3) = 5 + 3 = 8 (ลบเจอลบ กลายเป็นบวก!)"},
}
TIPS = [
"ลบกับลบ (ในการลบ): เปลี่ยนเป็นบวก → 5 - (-3) = 5 + 3 = 8",
"บวกจำนวนลบ: เหมือนลบ → 5 + (-3) = 5 - 3 = 2",
"ลบจำนวนบวก: ลบปกติ → 5 - 3 = 2",
"เครื่องหมายเหมือนกัน (คูณ/หาร): ผลเป็นบวก",
"เครื่องหมายต่างกัน (คูณ/หาร): ผลเป็นลบ",
]
def show_rules(self):
print("=== กฎการบวก-ลบจำนวนลบ ===\n")
for key, rule in self.RULES.items():
print(f" {rule['rule']}")
print(f" ตัวอย่าง: {rule['example']}")
print()
def show_tips(self):
print("=== สรุปเคล็ดลับ ===")
for tip in self.TIPS:
print(f" • {tip}")
def mixed_practice(self):
print(f"\n=== แบบฝึกหัดรวม ===")
problems = [
("(-8) + 5", -8 + 5),
("7 + (-12)", 7 + (-12)),
("(-3) - (-9)", -3 - (-9)),
("6 - 10", 6 - 10),
("(-4) × (-6)", -4 * -6),
("8 × (-3)", 8 * -3),
("(-20) ÷ 5", -20 / 5),
("(-15) ÷ (-3)", -15 / -3),
]
for expr, answer in problems:
print(f" {expr:>20} = {answer:>6}")
addsub = AddSubNegatives()
addsub.show_rules()
addsub.show_tips()
addsub.mixed_practice()
การประยุกต์ใช้ในโปรแกรมมิ่ง
# programming.py — Sign rules in programming
import json
class ProgrammingApplications:
EXAMPLES = {
"game_physics": {
"name": "Game Physics",
"description": "ใช้จำนวนลบแทนทิศทาง — ขวา (+), ซ้าย (-), บน (+), ล่าง (-)",
"code": "velocity = -5 # เคลื่อนที่ไปซ้าย\nposition += velocity # ตำแหน่งลดลง",
},
"finance": {
"name": "Financial Calculations",
"description": "รายรับ (+), รายจ่าย (-), กำไร/ขาดทุน",
"code": "profit = revenue - cost # ถ้า cost > revenue → profit เป็นลบ (ขาดทุน)",
},
"temperature": {
"name": "Temperature Conversion",
"description": "อุณหภูมิติดลบ — แปลง °C ↔ °F",
"code": "celsius = -40\nfahrenheit = (celsius * 9/5) + 32 # -40°C = -40°F",
},
"array_index": {
"name": "Array Negative Indexing (Python)",
"description": "ใช้ index ลบเข้าถึง element จากท้าย",
"code": "arr = [10, 20, 30, 40]\narr[-1] # 40 (ตัวสุดท้าย)\narr[-2] # 30 (ตัวรองสุดท้าย)",
},
}
def show_examples(self):
print("=== ประยุกต์ใช้ในโปรแกรมมิ่ง ===\n")
for key, ex in self.EXAMPLES.items():
print(f"[{ex['name']}]")
print(f" {ex['description']}")
print(f" Code: {ex['code'].split(chr(10))[0]}")
print()
def python_demo(self):
print("=== Python Demo ===")
demos = [
("(-7) * 3", (-7) * 3),
("(-4) * (-8)", (-4) * (-8)),
("abs(-15)", abs(-15)),
("max(-5, -2, 0, 3)", max(-5, -2, 0, 3)),
("min(-5, -2, 0, 3)", min(-5, -2, 0, 3)),
("-10 // 3", -10 // 3),
("-10 % 3", -10 % 3),
]
for expr, result in demos:
print(f" {expr:>20} = {result}")
prog = ProgrammingApplications()
prog.show_examples()
prog.python_demo()
FAQ - คำถามที่พบบ่อย
Q: ลบเจอบวกเป็นอะไร?
A: ในการคูณและการหาร: ลบ × บวก = ลบ เช่น (-3) × 5 = -15 กฎ: เครื่องหมายต่างกัน → ผลลัพธ์เป็นลบ ในการลบ: ลบ ลบด้วย บวก → ยิ่งลบมากขึ้น เช่น (-3) - 5 = -8
Q: ลบคูณลบเป็นอะไร?
A: ลบ × ลบ = บวก เช่น (-3) × (-5) = 15 เพราะ: เครื่องหมายเหมือนกัน → ผลลัพธ์เป็นบวก เปรียบเทียบ: ยกเลิกหนี้ = ได้เงินคืน = บวก
Q: บวกเจอลบเป็นอะไร?
A: ในการคูณ: บวก × ลบ = ลบ เช่น 3 × (-5) = -15 ในการบวก: ขึ้นกับค่าสัมบูรณ์ เช่น 3 + (-5) = -2 (เพราะ 5 มากกว่า 3 → ผลเป็นลบ) แต่ 5 + (-3) = 2 (เพราะ 5 มากกว่า 3 → ผลเป็นบวก)
Q: จำกฎง่ายๆ ได้อย่างไร?
A: จำแค่ 2 กฎ: 1) เครื่องหมายเหมือนกัน (++ หรือ --) → ผลเป็นบวก (+) 2) เครื่องหมายต่างกัน (+- หรือ -+) → ผลเป็นลบ (-) กฎนี้ใช้ได้ทั้งคูณและหาร สำหรับบวก-ลบ: a - (-b) = a + b (ลบเจอลบ กลายเป็นบวก)
