Abstract syntax tree precedence example 2026-10-13
Consider Python programs
x=2+3*4 and x=(2+3)*4. Operator precedence places multiplication inside the right operand of addition in the first abstract syntax tree. The parentheses instead place addition inside the left operand of multiplication in the second. Their right-hand sides evaluate to and . No rule that simply reads all operators left to right would recover both structures. [ref]https://docs.python.org/3.14/reference/expressions.html#operator-precedence. Python language reference, section 6.17, multiplicative operators bind more tightly than additive operators
Two abstract syntax trees for variable assignment: operator precedence gives
. Details. x=2+3*4 the value , while parentheses give x=(2+3)*4 the value These are schematic views of Python trees:
Module is omitted, and the Add/Mult and Store markers are written inside their owning nodes. In the actual schema, BinOp has left, op and right fields; Assign has a list of targets and a value. Name(id='x', ctx=Store()) marks the name as a variable assignment target. Reading x in a program expression instead uses Load. A variable assignment is a statement, not an equation asserting that two values are equal. [ref]A restricted recursive evaluator can follow those fields. It accepts only integer literal values and binary addition, subtraction and multiplication; the surrounding variable assignment remains a separate action. Using
type(value) is int excludes Boolean constants, even though Python treats bool as a subclass of int.import ast
OPS = {ast.Add: lambda a, b: a + b,
ast.Sub: lambda a, b: a - b,
ast.Mult: lambda a, b: a * b}
def evaluate(node):
if isinstance(node, ast.Constant) and type(node.value) is int:
return node.value
if isinstance(node, ast.BinOp) and type(node.op) in OPS:
return OPS[type(node.op)](evaluate(node.left), evaluate(node.right))
raise ValueError("outside the integer-expression language")
for source in ("x=2+3*4", "x=(2+3)*4"):
tree = ast.parse(source, optimize=0)
statement = tree.body[0]
print(statement.targets[0].id, evaluate(statement.value))
# x 14
# x 20The children in a rooted tree have ordered roles:
left and right cannot be interchanged. For subtraction, 8-3 gives while 3-8 gives . Operator associativity also matters: 8-3-1 parses as (8-3)-1, giving , whereas 8-(3-1) gives . Here the syntax groups operators to the left; this does not assert the mathematical associativity of subtraction. Operator precedence determines grouping, rather than a general permission to reorder execution. For example, Python evaluates the calls in f()+g()*h() in the order f, g, h, although the multiplication result must be ready before the outer addition. [ref]https://docs.python.org/3.14/reference/expressions.html#evaluation-order. Python language reference, sections 6.16 and 6.17: left-to-right evaluation and left grouping of additive operators
Algebra Created 2026-09-24 Updated 2026-10-13
Algebra studies equations, algebraic operations, and the structures that make their rules work. Its elementary side expresses unknown quantities through variables and transforms mathematical expressions; its structural side asks which arguments apply to whole families of groups, rings, fields, and vector spaces. The useful step is identifying exactly which properties a calculation needs, so that it can be reused in a new setting.
For example, the polynomial equation over the real numbers factors as , giving roots and . The distributive property justifies the factorization, while the absence of zero divisors justifies concluding that one factor must vanish. Over the finite field , the same integer coefficients reduce to , with roots and . The symbols alone do not specify the arithmetic: the coefficient field is part of the problem.
In a ring with zero divisors, a familiar step can fail. Modulo , all four residue classes satisfy . For , the factorization holds modulo , yet neither factor is zero. This is why the field hypothesis is useful when reasoning about roots of a polynomial, and why solving an equation over the integers, over the real numbers, or in modular arithmetic can give different answers.
The structure is also useful beyond scalar arithmetic. Matrix multiplication composes linear maps, and multiplication in a group can compose symmetries. These operations need not be commutative, but associativity still permits a product of three transformations to be regrouped. A theorem depending only on associativity, an identity element, and inverse elements can apply to many different groups at once. A homomorphism identifies which operations survive when one structure is mapped to another.
Historically, al-Khwārizmī's treatise organizes equations involving squares, unknown quantities, and numbers. Frederic Rosen's 1831 English translation includes the calculation now written and geometric explanations for completing the square. In modern notation, gives or ; the historical treatment seeks the positive quantity . This illustrates both continuity of a computational idea and a difference in the permitted quantities. [ref]
https://en.wikisource.org/wiki/The_Compendious_Book_on_Calculation_by_Completion_and_Balancing/Compendium_on_calculating_by_completion_and_reduction. Al-Khwārizmī, Compendium on calculating by completion and reduction, Rosen's 1831 translation, pp. 5–11
Commutative ring Created 2026-09-24 Updated 2026-10-14
A commutative ring is a ring in which multiplication satisfies for every pair. The integers and the polynomial ring are examples. So is , the quotient ring whose elements are residue classes in modular arithmetic. We represent these by and reduce each sum or product to its remainder. All following calculations modulo use this convention.
In , , although neither factor is zero. Thus and are zero divisors: nonzero elements whose product with another nonzero element can vanish. Also . Removing the common factor would falsely assert . The entire row for multiplication by isThe repetitions explain the linear congruences directly. The equation has exactly the two solutions , whereas has none. A common factor can erase information, and a nonzero coefficient does not guarantee that an equation has a solution.
A unit in a ring is an element with a multiplicative inverse, meaning for some . In , the units are exactly and , since . The other nonzero elements, , are zero divisors; for , use . In a nonzero commutative ring, a unit cannot be a zero divisor: multiplying by its multiplicative inverse forces . But a nonzero element need not be a unit or a zero divisor: the integer is neither in .
By contrast, in , every row for a nonzero multiplier is a permutation of . Each such row contains exactly once, giving a multiplicative inverse: , , , and . Hence this commutative ring is a field. For example, now has the unique solution . Reading the tables reveals which algebraic steps the arithmetic permits.
Equality slice of a feasible triangle 2026-10-14
Keep the feasible triangle with a squared-distance objective, but add the equation . An equality requires an exact relation, whereas an inequality allows a range. Here the equality selects a line, and intersecting that line with the original feasible region leaves just the line segment from to :The lower bound comes from ; the upper bound comes from . This is a nonempty closed set even though it has empty interior in the plane. An equality can reduce the dimension of the allowed decisions without making the feasible region empty.
The old optimum violates the added equality. On the surviving line segment, the objective function isThe derivative shows that the unique global minimum is at , giving and value . The nearest point on the entire equality line would be , at with value , but it violates . Both the equality and the original inequalities must hold simultaneously.
Equality slice of a feasible triangle: the allowed line segment ends at the optimum (2,1), while the nearest point on the entire line is infeasible
. Details. Use and to fix the multiplier sign convention in the optimization Lagrangian ; the Lagrange multipliers of and are again zero. At , Karush-Kuhn-Tucker conditions hold with and :The Lagrange multiplier of an equality has no nonnegativity restriction. For an independent global certificate, completing the square gives . On the feasible set, and , so , with equality exactly at .
Equation 2026-10-13
An equation asserts that two mathematical expressions have the same value. Solving it means finding all allowed assignments to its variables that make that assertion true. It converts a relationship into a constraint: a measurement, a geometric intersection, or an equilibrium model can leave an unknown value to determine.
The allowed values matter. The equation has solution set over the rational numbers, but the empty set over the integers. Over the real numbers, has two solutions, and . A mathematical identity, such as , holds for every permitted real . The familiar equality sign therefore does not by itself say whether one is checking a particular value, solving for an unknown, or stating an identity.
For a worked linear equation over the real numbers,The first step subtracts three from both sides; the second divides both sides by the nonzero number two. Reversing the steps recovers the original equation, so these are equivalent equations with the same solution set . Checking the value gives . The role of reversible operations and the classification by solution sets are described in College Algebra 2e, §2.2: Solving Linear Equations in One Variable.
Reversible operations change the graphs of the two sides but preserve the intersection's input value
. Details. When the two sides define real-valued functions and on a common domain of a function, solutions are exactly the input values at which their function graphs intersect. Equivalently, they are the zeros of a function . This gives a useful connection between symbolic algebra and geometry: rearranging an equation can simplify the comparison without changing the inputs where equality holds.
Not every operation is reversible on every domain of a function. Dividing by gives only after restricting to ; it loses the solution if that restriction is forgotten. Squaring both sides can instead introduce an extraneous solution, because distinct real numbers can have the same square. The source equation, its domain of a function, and the direction of each implication should travel together.
Equivalent equations 2026-10-14
Two equations are equivalent on a specified domain of a function if they have the same solution set. Adding the same defined mathematical expression to both sides is reversible. Multiplying or dividing both sides by a mathematical expression is reversible only where that expression is nonzero and invertible in the arithmetic being used. In a field, every nonzero scalar is invertible; a general ring needs an additional check.
For example, and are equivalent equations over the real numbers, by the distributive property. Concluding or additionally uses the absence of zero divisors. The modular example in algebra shows why that extra inference can fail in a ring with zero divisors.
Expression (mathematics) 2026-10-13
A mathematical expression combines symbols according to formation rules, such as , , or . With values for its variables and meanings for its algebraic operations, it can be evaluated. An equation relates two mathematical expressions; an expression alone need not assert anything.
For example, evaluates to seven at and nine at . Neither value solves anything until a condition is imposed: the equation selects from the real numbers. This distinction is useful when moving from a formula to a question about which inputs satisfy it. Evaluation by replacing the variables with assigned values is described in College Algebra 2e, §1.1: Evaluating Algebraic Expressions.
Different written mathematical expressions can have the same value for every input in a common domain of a function. The distributive property expands to , while factorizing reverses that change of form. The mathematical identity between them lets one choose the form suited to the next task: the factored form exposes a multiple root at , and the expanded form exposes its coefficients. Simplifying should preserve values on the stated domain, rather than silently enlarging it.
Extraneous solution 2026-10-14
An extraneous solution satisfies a transformed equation but fails the original equation or its restrictions. The term describes a candidate generated during the calculation, rather than a true solution that can be kept in the final solution set.
Consider the real equationThe square root requires . Because the square root is nonnegative, any solution must also have , so . Squaring givesThe squared equation has candidates and . At , the original equality is . At , it is , which fails: this candidate is an extraneous solution. Thus the original solution set is exactly .
Squaring removes a sign distinction and creates a second intersection at , which fails the original equation
. Details. On the restricted domain of a function , both original sides are nonnegative, so squaring is reversible there and the two equations are equivalent. Retaining the sign restriction or checking every candidate in the original equation achieves the same final solution set. The general need to check candidates after raising both sides to a power is explained in College Algebra 2e, §2.6: Solving Radical Equations.




