Artificial intelligence has become the defining technology of our age. It writes essays, translates languages, detects patterns in medical images, recommends loans, screens job applicants, predicts consumer behaviour, and even generates music and art. Yet while millions use AI every day, few understand what happens beneath the surface. AI may appear magical, but its foundations are mathematics. Behind every chatbot, recommendation engine, facial-recognition system, and large language model lies a structure built from linear algebra, calculus, probability, statistics, optimisation, and geometry. Understanding these foundations helps us recognise why AI is powerful, why it sometimes invents information, and how it can reproduce social injustice while appearing objective. The so-called “black box” of neural networks is therefore not completely black. It is a highly complex mathematical machine. How Does ChatGPT “Learn”? A large language model such as ChatGPT does not learn as a human child does. It has no consciousness, personal experience, or human understanding. Instead, it is trained to detect statistical patterns in enormous collections of text and predict which word or token is most likely to come next. The first major mathematical ingredient is linear algebra. Computers cannot directly understand words such as “justice,” “doctor,” “poverty,” or “democracy.” These words must be converted into numerical representations called vectors. A vector is an ordered list of numbers. In modern AI systems, each word or token may be represented by hundreds or thousands of numerical coordinates. Once language is converted into vectors, the model performs vast numbers of matrix operations. Matrices are rectangular arrangements of numbers, and matrix multiplication allows the model to transform, compare, combine, and transmit information from one layer of the neural network to another. A modern neural network may contain billions of adjustable numerical parameters organised into enormous matrices. During training, the model repeatedly modifies them so that its predictions become more accurate. This is where calculus enters. Suppose the model is given the sentence, “The sun rises in the…” and predicts “west” instead of “east.” The system calculates an error, often called a loss. Training aims to reduce this loss across billions of examples. To do so, the model uses backpropagation. This process applies the chain rule of calculus to determine how much each parameter contributed to the error. The model then uses gradient descent, an optimisation method, to adjust the parameters in a direction that reduces the loss. Imagine a traveller on a mountain in thick fog, trying to reach the valley. The traveller cannot see the whole landscape but can feel the local slope. By repeatedly stepping downhill, the traveller reaches a lower region. Gradient descent works similarly, except that its mathematical “landscape” may have billions of dimensions. Probability is the third essential pillar. AI does not normally produce one absolutely certain answer. It assigns probabilities to many possible next words. After the phrase, “The patient was taken to the…,” words such as “hospital” or “clinic” may receive high probabilities, while unrelated words receive very low probabilities. The model selects from these possibilities according to its design and settings. The fluency of AI therefore emerges from repeated probabilistic prediction guided by mathematical optimisation. Why Does AI Hallucinate? One major weakness of modern AI is hallucination: the production of false, fabricated, or unsupported information presented confidently. To understand this, we must examine the geometry of high-dimensional space. Words and concepts are represented through embeddings. An embedding place each word, sentence, or idea at a point in a high-dimensional mathematical space. Concepts used in similar contexts are placed relatively close together. For example, “doctor,” “hospital,” “patient,” and “medicine” may occupy neighbouring regions, while “planet,” “galaxy,” and “telescope” form another cluster. These relationships are not stored as dictionary definitions. They are encoded as distances, directions, angles, and patterns among vectors. This geometry allows AI to detect analogies and semantic similarities. However, it can also create confusion. In a space with hundreds or thousands of dimensions, two ideas may appear statistically close because they occur in similar contexts, even though they are not factually interchangeable. When answering a question, the model navigates this mathematical space and generates likely continuations. It does not automatically verify every claim against reality. If the training data contains gaps, contradictions, weak associations, or misleading patterns, the model may construct a plausible but false answer. Hallucination is therefore not “lying.” Lying requires intention; AI has none. It produces a mathematically probable sequence that may sound correct without being factually grounded. This is why AI-generated information must be checked, especially in medicine, law, finance, education, journalism, and public policy. Algorithmic Bias: When Mathematics Reproduces Inequality Mathematics is often seen as neutral, but models are designed by people, trained on human data, and deployed within unequal societies. If historical data contains discrimination, an AI system may learn that discrimination as though it were a valid pattern. Consider a hiring algorithm trained on past recruitment records. If a company historically hired more men than women for technical positions, the model may infer that male candidates are more suitable, even when gender is excluded. Variables such as career gaps, college attended, residential area, or language style may act as indirect proxies. A similar problem occurs in loan approval. A model may use income, postal code, employment history, and repayment records to estimate risk. But if certain communities have faced generations of economic exclusion, the model may reproduce that disadvantage under the label of “statistical prediction.” In policing, predictive systems may direct more surveillance toward neighbourhoods already over-policed. More surveillance produces more recorded incidents, which then appear to justify even more surveillance. Mathematics can thereby create a feedback loop of inequality. The equations are not malicious. The problem is that the data, objectives, categories, and assumptions may reflect human prejudice. Fairness itself is mathematically difficult. Should a model have equal accuracy for all groups? Equal approval rates? Equal false-positive rates? Equal opportunity? These goals can conflict. No single formula automatically produces justice. This is where statistics meets ethics and social justice. The Human Responsibility Behind the Machine The AI revolution is not only technological. It is mathematical and moral. Linear algebra gives AI its structure. Calculus teaches it how to improve. Probability allows it to predict. High-dimensional geometry helps it organise meaning. Statistics enables it to learn from data. But none of these tools can decide what society should value. That decision remains human. We must educate the public not only to use AI, but also to question it. Schools and universities should teach the mathematics of AI alongside its ethical consequences. Policymakers should demand transparency, testing, and accountability. Companies should audit models for bias and error. Users should not treat fluent answers as unquestionable truth. The future will not belong merely to those who can operate AI tools. It will belong to those who understand their logic, recognise their limitations, and use them responsibly. The machine may calculate, predict, and generate. But responsibility for truth, fairness, and human dignity still belongs to us.
|