Chapter 14
Mathematical Computing, AI and Model Governance
Bachelor Program in Mechatronics Engineering
Engineering Mathematics III
•
Bachelor
Mathematical Computing, AI and Model Governance
Introduction
Mechatronics systems increasingly combine physical devices, mathematical models, embedded computation, sensors, optimization and machine learning. A robot may use differential equations to predict motion, numerical solvers to calculate a trajectory, automatic differentiation to tune a controller, and a learned model to detect anomalies. These capabilities are valuable only when their assumptions, limitations and risks are understood.
This chapter develops an integrated approach to mathematical computing and responsible AI. The central principle is that computation does not replace engineering judgment. Symbolic analysis explains structure, numerical methods provide approximate solutions, and data-driven methods identify patterns from observations. A reliable engineering workflow uses these methods together, verifies results, quantifies sensitivity, documents assumptions and governs deployment throughout the model life cycle.
Learning objectives
By the end of this chapter, you should be able to:
Distinguish symbolic, numerical and data-driven mathematical methods.
Formulate engineering problems as models and identify their assumptions.
Apply automatic differentiation and gradient-based optimization in simple cases.
Evaluate model error, conditioning, sensitivity and uncertainty.
Explain when a machine-learning approximation is justified.
Design a reproducible computational experiment.
Identify risks involving safety, bias, privacy, cybersecurity and accountability.
Propose a governance process for deploying AI-enabled mechatronic systems.
1. Three complementary modes of mathematical computation
1.1 Symbolic computation
Symbolic computation manipulates mathematical expressions exactly or algebraically. Examples include differentiation, integration, simplification, solving linear equations and deriving transfer functions. For example, if a displacement is
x(t) = A sin(ωt),
then symbolic differentiation gives velocity
v(t) = dx/dt = Aω cos(ωt)
where A is amplitude in metres and ω is angular frequency in radians per second. Symbolic results reveal dependencies and can expose cancellations, singularities and conservation relationships.
Symbolic methods are most effective when expressions remain manageable. They may become impractical for large nonlinear systems, discontinuous functions or models containing measured data. An exact symbolic expression can also be misleading if its input parameters are uncertain.
1.2 Numerical computation
Numerical computation represents quantities using finite precision and obtains approximate solutions. It is essential for systems that cannot be solved conveniently in closed form. A continuous-time state model can be written as
dx/dt = f(x, u, t; θ), y = g(x, u, t; θ)
where x is the state vector, u the input vector, y the output, θ model parameters and t time. A numerical integrator approximates the state at discrete times.
For the forward Euler method,
xk+1 = xk + h f(xk, uk, tk; θ)
where h is the time step. The method is simple but may be inaccurate or unstable for large h. For a scalar stable system dx/dt = -λx, with λ > 0, Euler gives xk+1 = (1 - hλ)xk. Stability requires |1 - hλ| < 1, hence 0 < hλ < 2. This condition illustrates why solver settings are part of model validity.
1.3 Data-driven computation
Data-driven methods infer a function or decision rule from observations. A regression model may approximate an output as
y ≈ φ(z; w)
where z is an input vector and w contains adjustable parameters. A common mean-square loss is
J(w) = (1/n) ∑i=1n [yi - φ(zi; w)]²
where n is the number of observations. Unlike a physical model, a learned model does not automatically obey conservation laws, actuator limits or safety constraints. Its validity is therefore restricted by the data distribution and the conditions represented in training and testing.
A model is a purposeful representation, not a complete copy of reality. Model formulation begins with a question: predict position, estimate remaining useful life, detect a fault, or select a controller? The purpose determines the required variables, fidelity and validation evidence.
A disciplined formulation includes:
system boundary and operating regime;
inputs, outputs and hidden states;
governing physical laws;
parameter values and units;
initial and boundary conditions;
assumptions and neglected effects;
uncertainty sources;
acceptance criteria.
For a translational mass–spring–damper system,
m d²x/dt² + c dx/dt + kx = F(t)
where m is mass in kilograms, c damping coefficient in newton-seconds per metre, k stiffness in newtons per metre, x displacement in metres and F applied force in newtons. Each term has units of newtons. The model assumes, among other things, linear spring behaviour, viscous damping, a lumped mass and a known force input. It is inappropriate without modification when deformation is strongly nonlinear or friction dominates.
Introducing velocity v = dx/dt, the model becomes
d/dt [x; v] = [v; (F(t) - cv - kx)/m]
The notation represents a two-component state equation. This form is convenient for simulation, estimation and control.
Verification, validation and uncertainty
Verification asks whether the computational implementation correctly solves the specified model: are equations coded correctly, units consistent and numerical errors controlled? Validation asks whether the model represents the real system adequately for its intended purpose. A model may be verified but invalid because its physical assumptions are unsuitable.
If a computed quantity is Qc and a reference measurement is Qr, the absolute error is
eabs = |Qc - Qr|
and, when Qr ≠ 0, the relative error is
erel = |Qc - Qr| / |Qr|
Relative error is dimensionless. It should not be used when the reference is zero or close to zero; absolute error or a problem-specific scale is then preferable.
3. Automatic differentiation and optimization
3.1 Automatic differentiation
Automatic differentiation (AD) computes derivatives by systematically applying the chain rule to a program. It differs from symbolic differentiation, which manipulates expressions, and finite differences, which estimate derivatives from perturbed function values.
For a composite function y = f(g(x)), the chain rule gives
dy/dx = f′(g(x)) g′(x)
A computational graph records intermediate operations and propagates derivatives. Forward-mode AD is efficient when there are few inputs and many outputs; reverse-mode AD is efficient when there are many inputs and a small number of outputs, as in a scalar loss function of a neural network.
Finite differences can be illustrated by the central approximation
f′(x) ≈ [f(x + h) - f(x - h)]/(2h)
where h is a small perturbation. Truncation error decreases as h decreases, but round-off error can increase because of subtraction of nearly equal finite-precision values. AD generally avoids this step-size trade-off, although it still differentiates the implemented computation, including any coding errors or nonsmooth operations.
3.2 Gradient-based optimization
An optimization problem has the form
minimize J(w) subject to gj(w) ≤ 0, j = 1, …, r hl(w) = 0, l = 1, …, s
where w is the decision vector, J the objective, and gj and hl inequality and equality constraints. Constraints may represent actuator limits, energy requirements, geometry or safety conditions.
Unconstrained gradient descent updates parameters by
wk+1 = wk - η ∇J(wk)
where η > 0 is the step size and ∇J is the gradient. The update moves opposite the local direction of greatest increase. It does not guarantee a global minimum for a nonconvex objective. A sufficiently small or adaptively selected step size, a stopping criterion and independent validation are required.
Worked example: one-parameter least squares
Suppose a calibration model is y ≈ wx and observations are (x1,y1)=(1,2) and (x2,y2)=(2,5). Define
J(w) = (1/2)[(2 - w)² + (5 - 2w)²]
Differentiating,
dJ/dw = -(2 - w) - 2(5 - 2w) = 5w - 12
The stationary point satisfies 5w - 12 = 0, so w = 2.4. Predictions are 2.4 and 4.8. The residuals are −0.4 and 0.2. Since the objective is quadratic with positive second derivative d²J/dw² = 5, this stationary point is the unique global minimum for the unconstrained problem.
If the calibration parameter must satisfy 0 ≤ w ≤ 2, the unconstrained solution is infeasible. The constrained optimum is the boundary value w = 2, demonstrating that engineering constraints can change the answer fundamentally.
4. Sensitivity, conditioning and uncertainty
Sensitivity measures how outputs respond to changes in inputs or parameters. For a scalar output y = f(p), the local sensitivity is ∂y/∂p. A dimensionless relative sensitivity is
Spy = (p/y)(∂y/∂p)
when p and y are nonzero. Approximately, a small relative parameter change produces
∆y/y ≈ Spy ∆p/p
This approximation is local and becomes unreliable for large changes or strongly nonlinear systems.
For multiple variables, the Jacobian is
Jf(x) = [∂fi/∂xj]
It describes local changes in vector-valued functions and is central to kinematics, estimation and optimization. A problem is ill-conditioned when small input or measurement changes cause large output changes. Ill-conditioning is a property of the problem; numerical instability may additionally arise from a poor algorithm.
Uncertainty may be classified as:
Aleatory uncertainty: inherent variability, such as manufacturing variation.
Epistemic uncertainty: incomplete knowledge, such as uncertain friction.
Measurement uncertainty: sensor noise, calibration error and resolution.
Model-form uncertainty: error caused by simplifying the physics.
A local first-order variance approximation for independent parameters is
Var(y) ≈ ∑i (∂f/∂pi)² Var(pi)
where covariance terms are omitted only when the parameters are independent. If parameters are correlated, the general matrix form is
Var(y) ≈ ∇fᵀ Σp ∇f
where Σp is the parameter covariance matrix. This approximation assumes small uncertainties and sufficient smoothness.
5. Machine-learning approximations in engineering
A machine-learning model is justified when it solves a defined engineering need better, faster or more economically than available alternatives. Appropriate uses include approximating an expensive simulator, classifying known fault signatures, compensating for repeatable calibration error, or estimating a hidden state from sensor data.
The workflow should include data collection, cleaning, feature or representation design, partitioning, training, validation, testing and deployment monitoring. The test set must remain independent until final evaluation. Random splitting is inappropriate for time series when it allows future information to leak into training; chronological or group-based splitting is usually safer.
For regression, common metrics include mean absolute error,
MAE = (1/n)∑|yi - ŷi|
and root mean-square error,
RMSE = √[(1/n)∑(yi - ŷi)²]
where yi is the measured value and ŷi the prediction. MAE has the same units as the output. RMSE penalizes large errors more strongly. Neither metric alone establishes safety or suitability.
For classification, accuracy can be misleading when classes are imbalanced. Precision and recall are
Precision = TP/(TP + FP), Recall = TP/(TP + FN)
where TP, FP and FN denote true positives, false positives and false negatives. In a safety-critical fault detector, the cost of a missed fault may greatly exceed the cost of a false alarm, so the decision threshold should be selected using engineering risk rather than accuracy alone.
A learned surrogate must be checked against physical constraints. For example, a predicted temperature should respect plausible bounds, a force estimate should be consistent with actuator limits, and a controller should be tested under disturbances not present in the training set. Hybrid or physics-informed models can combine governing equations with learned residuals:
ypred = yphysics + rdata(z; w)
The residual model should not be assumed safe merely because the physical component is safe.
6. Reproducible computational practice
Reproducibility means that an independent person can obtain materially similar results using the stated data, code, environment and procedure. A professional computational record should identify:
source, version and licensing of data;
preprocessing, filtering and missing-value rules;
units, coordinate conventions and sampling rates;
software versions, dependencies and hardware;
random seeds and train–test partition rules;
model architecture, parameters and stopping criteria;
evaluation metrics and excluded cases;
known limitations and unresolved anomalies.
A useful distinction is repeatability, obtaining consistent results in the same environment, and reproducibility, obtaining consistent results in an independent environment. Containers, environment lock files, version control, automated tests and executable notebooks can support both, but they do not correct flawed assumptions or contaminated data.
Numerical results should be reported with justified precision. Reporting many decimal places does not create accuracy. Dimensional checks, limiting-case checks, conservation checks and comparison with an independent implementation are inexpensive and powerful verification tools.
7. Model governance and responsible AI
Model governance is the system of roles, controls and evidence used to ensure that a model remains fit for purpose throughout its life cycle. It includes design, procurement, development, validation, deployment, monitoring, change control and retirement.
Safety and accountability
A safety-related AI system should fail safely when confidence is low, sensors disagree or operating conditions leave the validated domain. Safety functions should not depend on a statistical model without independent protective mechanisms. Human oversight must be meaningful: operators need authority, information and time to intervene. Responsibility cannot be transferred to an algorithm or vendor.
A model card or technical file should state intended use, prohibited use, training population, performance by operating condition, known failure modes, monitoring thresholds and responsible owners. Any change to data, firmware, model weights or preprocessing should undergo impact assessment and versioned approval.
Bias and fairness
Bias can arise from unrepresentative sampling, historical decisions, measurement differences, missing groups or labels that encode past errors. In industrial systems, relevant groups may include machine types, production batches, environmental conditions, operators or geographic sites rather than only demographic categories. Performance should be stratified across these groups and operating regimes. A single aggregate metric can conceal serious failures in a minority condition.
Fairness is context-dependent. Equal false-negative rates may be more important than equal positive rates in fault detection, while allocation systems may require different criteria. The chosen criterion must be justified by the engineering purpose and risk analysis.
Privacy and cybersecurity
Sensor streams may reveal worker behaviour, production rates, facility layouts or proprietary designs. Data minimization, access control, retention limits, encryption and informed authorization reduce privacy risk. Anonymization is not automatically irreversible, particularly when several data sources can be linked.
AI systems also create cybersecurity concerns: adversarial inputs, poisoned training data, stolen models, insecure update mechanisms and prompt or interface manipulation. Threat modelling should identify assets, attack surfaces, consequences and mitigations. Secure boot, signed updates, network segmentation, logging, least privilege and incident-response procedures are relevant controls for embedded systems.
Governance life-cycle
Model governance life cycle from purpose through retirement
Figure: Model governance life cycle from purpose through retirement
Figure: Governance is a continuing life-cycle rather than a one-time approval.
8. Illustrative case: predictive maintenance for a conveyor motor
Background and problem
A factory wants to reduce unexpected conveyor stoppages. A three-phase motor is instrumented with vibration, current and temperature sensors. The proposed system predicts whether a bearing fault is likely within the next 24 hours.
Analysis
An initial physical model describes motor load and thermal behaviour, while historical labelled events provide examples of normal operation and bearing faults. Engineers identify confounders: production speed, ambient temperature, sensor replacement and maintenance policy. Randomly mixing measurements from the same failure event into training and testing would cause leakage, so entire time periods or machines are held out.
A baseline threshold detector is compared with a supervised classifier. Performance is reported separately for motor type, load range and sensor generation. Recall is prioritized because missed faults have high cost, but false alarms are also assessed because excessive shutdowns can lead operators to ignore warnings.
Approach and safeguards
The classifier is used only as an advisory layer. A hard thermal trip and vibration limit remain independent protective controls. If data quality is poor or the input is outside the validated range, the system reports “insufficient evidence” rather than a confident normal prediction. Maintenance engineers review alerts, and every intervention is logged.
The technical record includes sensor calibration, feature definitions, model version, test results, known failure modes and a rollback procedure. Access to data is restricted because vibration and production records reveal proprietary operating information. Periodic monitoring checks changes in sensor distributions and recall on newly confirmed events.
Outcome and learning points
In this illustrative case, the appropriate outcome is not simply a high test score. The system is acceptable only if it improves maintenance decisions under actual operating conditions without weakening existing safety controls. The case demonstrates five principles: define the decision before selecting a model; prevent leakage; compare against a simple baseline; retain independent safety mechanisms; and govern the model after deployment.
Challenges and limitations
Mathematical computing can create false confidence through visually smooth plots, excessive numerical precision or impressive benchmark scores. Physical models may omit friction, saturation, backlash or thermal effects. Numerical solvers may be unstable, and optimization may find an infeasible or locally poor solution. Machine-learning models may fail under distribution shift, rare faults or sensor drift. Explainability methods can describe model behaviour without proving causal correctness.
Governance also has limitations. Documentation does not guarantee ethical behaviour, and compliance checklists may overlook system interactions. Risk classifications should therefore be proportional to consequences, continuously reviewed and supported by independent technical and safety expertise.
Best-practice checklist
Before approving a computational or AI-enabled engineering model, ask:
Is the intended decision and operating domain explicit?
Are equations, units, data sources and assumptions documented?
Has the implementation been verified independently?
Has performance been validated on representative, leakage-free data?
Are sensitivity, uncertainty and failure modes quantified?
Are safety constraints and fallback modes independent where necessary?
Are privacy, cybersecurity, bias and access controls addressed?
Can results be reproduced from versioned artefacts?
Are ownership, monitoring, change approval and retirement defined?
Chapter Summary
Symbolic, numerical and data-driven methods serve different but complementary purposes. Symbolic computation exposes exact structure; numerical methods solve realistic models approximately; and machine learning approximates relationships from data. Engineering models must specify variables, units, assumptions, operating domains and acceptance criteria. Verification checks computational correctness, whereas validation checks suitability for reality and purpose.
Automatic differentiation applies the chain rule through computational graphs and is useful for optimization, especially when gradients of complex programs are required. Gradient descent is a local method and must be combined with constraints, stopping criteria and validation. Sensitivity analysis, conditioning and uncertainty propagation reveal how parameter and measurement errors affect predictions.
Responsible deployment requires leakage-free evaluation, physical plausibility checks, reproducible records and monitoring after release. Model governance covers the entire life cycle and addresses safety, accountability, fairness, privacy, cybersecurity and controlled change. In mechatronics, AI should augment—not replace—physical understanding, independent safeguards and professional judgment.
Key Terms
Symbolic computation: Algebraic manipulation of mathematical expressions.
Numerical method: An algorithm that obtains approximate numerical solutions.
Data-driven model: A model inferred primarily from measured or simulated data.
State-space model: A representation using state variables, inputs and outputs.
Verification: Checking whether an implementation correctly solves its specified model.
Validation: Checking whether a model is suitable for its intended real-world purpose.
Automatic differentiation: Exact-to-working-precision derivative evaluation through program operations.
Finite difference: Derivative approximation using perturbed function evaluations.
Gradient: Vector of first partial derivatives of a scalar function.
Optimization: Systematic selection of variables to minimize or maximize an objective.
Constraint: Equality or inequality requirement restricting feasible solutions.
Sensitivity: Change in an output caused by change in a parameter or input.
Conditioning: Dependence of problem output on perturbations in input data.
Uncertainty: Lack of exact knowledge or inherent variability in quantities.
Surrogate model: An inexpensive approximation of a more expensive model or experiment.
Data leakage: Use of information in training that would be unavailable at deployment.
Distribution shift: Change between training conditions and operational conditions.
Model governance: Roles, controls and evidence managing a model throughout its life cycle.
Reproducibility: Ability to obtain materially similar results using documented independent procedures.
Human oversight: Responsible human capacity to understand, intervene in and govern system operation.
Review Questions
Short Answer Questions
Distinguish symbolic, numerical and data-driven computation, giving one mechatronics example of each.
What is the difference between verification and validation?
Why can a numerical time step affect the reliability of a simulation?
State two reasons why a machine-learning test score may be misleading.
What information should be included in a reproducible computational record?
Long Answer Questions
Explain how a physical model can be combined with a learned residual model, including benefits and limitations.
Describe automatic differentiation and compare it with finite-difference differentiation.
Discuss sensitivity, conditioning and uncertainty propagation in the design of a sensor-based system.
Explain why safety-related AI requires independent protective mechanisms and defined human oversight.
Develop a model-governance life cycle for an AI-enabled robotic inspection system.
Analytical / Application Questions
A simulator uses forward Euler for dx/dt = -4x. Determine the largest permissible time-step boundary for the strict stability condition and explain why a practical engineer may choose a smaller step.
A fault classifier has TP = 90, FP = 10 and FN = 20. Calculate precision and recall, and explain which additional information is needed before deployment.
A learned temperature estimator performs well in laboratory tests but fails in a hotter factory. Diagnose possible causes and propose a validation and governance response.
Multiple Choice Questions with Answers
Question 1
Which method manipulates mathematical expressions algebraically?
A. Symbolic computation
B. Numerical integration
C. Randomized testing
D. Data logging
Correct Answer: A. Symbolic computation
Question 2
For dx/dt = -λx with λ > 0, forward Euler is strictly stable when:
A. hλ = 0 only
B. 0 < hλ < 2
C. hλ > 2
D. hλ < 0
Correct Answer: B. 0 < hλ < 2
Question 3
Which derivative method applies the chain rule through the operations of a program?
A. Monte Carlo sampling
B. Automatic differentiation
C. Data normalization
D. Grid search
Correct Answer: B. Automatic differentiation
Question 4
In gradient descent, the update wk+1 = wk - η∇J(wk) moves generally:
A. Toward increasing objective value
B. Opposite the local gradient
C. Toward a random feasible point
D. Only along a constraint boundary
Correct Answer: B. Opposite the local gradient
Question 5
Which metric has the same units as a regression output?
A. MAE
B. Relative error
C. Precision
D. Recall
Correct Answer: A. MAE
Question 6
What is data leakage?
A. Loss of electrical power to a sensor
B. Use of unavailable future or test information during training
C. Compression of a dataset
D. Removal of duplicate records
Correct Answer: B. Use of unavailable future or test information during training
Question 7
Validation primarily asks whether:
A. The code compiles
B. The model represents reality adequately for its intended purpose
C. The dataset has zero variance
D. The optimizer uses a small step size
Correct Answer: B. The model represents reality adequately for its intended purpose
Question 8
For a safety-critical fault detector, why might recall be prioritized?
A. It measures storage capacity
B. A missed fault may be more costly than a false alarm
C. It always exceeds precision
D. It eliminates model uncertainty
Correct Answer: B. A missed fault may be more costly than a false alarm
Question 9
Which is an example of epistemic uncertainty?
A. Random variation in repeated identical manufacturing processes
B. Unknown friction caused by insufficient system knowledge
C. A fixed unit conversion
D. A documented sensor resolution
Correct Answer: B. Unknown friction caused by insufficient system knowledge
Question 10
Model governance should normally include:
A. Approval only before initial training
B. Life-cycle monitoring, change control and retirement
C. Only aggregate accuracy reporting
D. Removal of human responsibility
Correct Answer: B. Life-cycle monitoring, change control and retirement