Skip to main content

Numerical Calculus: Newton–Raphson App & Validation

MATLAB App Designer Newton–Raphson project with safeguarded root finding, numerical validation, convergence analysis, initial-guess sensitivity, and explicit failure-mode diagnostics.

Newton-Raphson residual convergence for three nonlinear root-finding problems

This project modernizes an archived MATLAB App Designer Newton–Raphson root-finding application. The original app is preserved as historical material, while a separate reproducible MATLAB runner audits the numerical behavior, validates the method against independent reference roots, and makes several failure modes explicit rather than hiding them behind a graphical interface.

The packaged App Designer source implements first-order Newton–Raphson. An embedded historical screenshot contains additional tabs labelled “Newton-Raphson 2” and “Fulse-Position,” but those methods are not present in the packaged source code, so this public project does not claim them as implemented algorithms.

Original App Designer behavior

The recovered application accepts an equation entered as text, an initial guess, a repeat count, and an approximate-error threshold. It converts the equation to a symbolic expression, differentiates it, applies Newton updates, and displays the estimated root together with the function value.

Source-derived UI settingDefault
Initial guess, x01
Repeat count3
Error threshold0.05%
Displayed error metricEa = 100(xr − x0)/xr

Safeguarded Newton implementation

The archived callback has no hard iteration cap, derivative-near-zero safeguard, finite-value test, real-domain check, or robust stopping rule for roots near zero. The public validation runner adds a maximum iteration count, derivative thresholding, residual-decreasing backtracking, domain checks, residual tolerance, and step-size tolerance while retaining the standard Newton update x(k+1) = x(k) − f(x(k))/f′(x(k)).

Validation functions

Three validation functions with their numerical roots
Figure 1. Nonlinear validation functions and reference roots. Algebraic, trigonometric, and exponential equations are used to test the safeguarded Newton implementation independently of the archived app example.
EquationInitial guessNewton rootFinal residualIterations
x³ − x − 21.51.5213797068054.530 × 10⁻¹⁴3
cos(x) − x1.00.73908513321504
exp(−x) − x0.50.5671432904104.552 × 10⁻¹⁵3

The resulting roots agree with independent MATLAB fzero reference solutions to approximately machine precision. None of these three well-conditioned validation cases requires backtracking.

Residual convergence

Newton-Raphson residual convergence for three equations
Figure 2. Safeguarded Newton residual convergence. The residual falls rapidly to near machine precision for all three standard validation problems.

Root-estimate error

Absolute Newton root-estimate error across iterations
Figure 3. Absolute root-estimate error. Newton iterates converge to the independently computed reference roots with very small final absolute error.

Tangent-line interpretation

Newton tangent-line construction for the cubic validation equation
Figure 4. Newton–Raphson tangent geometry for x³ − x − 2. The first iterations illustrate the geometric interpretation of Newton’s method: each local tangent intercept generates the next root estimate.

Sensitivity to the initial guess

Newton iteration count and final residual versus initial guess
Figure 5. Initial-guess sensitivity. Iteration count varies across the initial-condition sweep, reinforcing that Newton–Raphson is a local iterative method rather than a globally guaranteed root finder.

Archived app example and a real-domain failure

The equation displayed in the original app interface is f(x) = x³ + √x − sin(x²). Its real-domain root is x = 0. Starting from the archived default x0 = 1, plain undamped Newton produces 1 → 0.521149 → −0.661385. The negative iterate leaves the intended real domain of the square-root term. The cleaned solver uses backtracking to remain in x ≥ 0 and converge to the root instead.

Archived Newton example leaving the real domain and safeguarded residual convergence
Figure 6. Archived UI example diagnostic. The upper panel shows the undamped Newton trajectory leaving the real domain. The lower panel shows the safeguarded solver converging to the zero root.
Archived-example metricResult
Real root0
Safeguarded final root0
Final residual0
Safeguarded Newton iterations38
Total backtracking steps73

Why the original percentage error fails at a zero root

The historical app computes approximate percentage error by dividing the latest change by the new iterate. This is poorly conditioned when the true root is near zero and becomes undefined when the new iterate is exactly zero. In the archived example, the solver reaches zero residual while the app-style error becomes infinite.

Residual and app-style percentage error near a zero-valued root
Figure 7. Residual versus the historical percentage-error metric near x* = 0. The residual converges correctly to zero, while the percentage error remains ill-conditioned and becomes infinite at the exact zero root.

Source audit and project scope

The public repository preserves the original Calculus.mlapp and Numerical_Calculus.prj files as historical material, together with a text source audit describing the recovered callback behavior. The standalone runner is the reproducible entry point used for the quantitative results on this page.

This project focuses on first-order Newton–Raphson. It does not claim that the additional historical UI tabs were completed, and it does not claim global convergence for arbitrary nonlinear equations. Backtracking improves robustness but is not a substitute for a bracketing method when guaranteed root isolation is required.

Reproducibility

The cleaned validation runner requires no external MATLAB toolboxes and automatically exports the validation metrics, histories, and numerical results used here. The seven website figures are stored directly in the portfolio repository as self-contained vector assets generated from the validated output data. The reported calculations were validated in MATLAB R2022b.