Teach-an-Engineer · Series Offline · self-contained · KaTeX

Mathematica for Engineers — Calculate, Solve, Plot

Mathematica turns a scientific computation into a single, readable line. You type the expression the way you'd write it on a blackboard, press Shift+Enter, and it comes back with the exact answer, a symbolic form, a numeric value, or a publication-quality picture — whatever you asked for. This guide covers the three verbs every engineer actually uses: calculate, solve, plot.

The one habit that changes everything: In Mathematica, the input is the object. A formula you type lives in the same internal form as a numeric result or a matrix. That is why Simplify can act on the same expression you'd Plot, and why a symbolic solution can later become a numeric one with a single N[...] call.

1. The notebook paradigm

Before syntax, you need the mental model. Mathematica's unit of work is the cell. You type an expression in an input cell, press Shift+Enter, and Mathematica sends the whole cell's content to a background process (the kernel) for evaluation. The result appears as a separate output cell below. Every subsequent cell can refer to previous results by their tag Out[7] = and to variables you have defined.

In[1] := Solve[x^2 == 2 x + 1, x]
→ kernel
Out[1] = {{x -> 1 - Sqrt[2]}, {x -> 1 + Sqrt[2]}}
Figure 1. A single cell round-trip. The kernel evaluates the expression and prints the symbolic result — no numerical values, no approximations, no code generation.

Three things follow from this design that most new users don't expect:

Takeaway: A Mathematica notebook is a chain of evaluated cells; each cell is an expression, and the notebook's state is a set of defined symbols. Everything else — algebra, plots, animations — is a function you call on an expression.

2. The two precision modes — the first gotcha

Every engineer's first surprise with Mathematica is that 1/3 stays as 1/3. There is no 0.333333 unless you ask for it. This isn't a bug: Mathematica treats 1/3 as an exact rational number, because the Wolfram Language keeps symbolic and numeric computation in one model.

Exact

1/3 → 1/3
2^100 → 1267650600228229401496703205376
Sqrt[2] → √2
N[Pi] → 3.14159

Exact values carry full precision. 2^100 has all 31 digits because Mathematica never rounded them off.

Numeric

N[1/3] → 0.333333
N[2^100] → 1.26765×10²⁹
N[Sqrt[2]] → 1.41421
N[Sqrt[2], 50] → 1.41421356237… (50 digits)

Numeric values are doubles by default (~16 digits) or, with N[expr, n], arbitrary-precision numbers you control.

Figure 2. The two precision modes side by side. The right-hand column is what you asked for — Mathematica never rounds on your behalf.

The most important rule: a decimal point in an input forces a numeric value.

\(\dfrac{1}{3}\;=\;\text{exact rational,}\qquad\qquad 1./3\;=\;0.333333\;=\;\text{machine real}.\)

The trailing dot on the numerator promotes the whole expression to a double. Once you are in numeric land, exact arithmetic is gone for that expression. This is why Solve[x^2 == 2. x + 1, x] (note the dot in 2.) returns approximate roots, while Solve[x^2 == 2 x + 1, x] returns the closed form. You will meet this again throughout the guide.

The rule of thumb: leave numbers exact unless you have a reason to approximate. If you find yourself typing a decimal where a fraction or Sqrt[...] would do, you are trading exactness for no gain.
Takeaway: Mathematica defaults to exact symbolic math. Adding a decimal point to any number in an expression promotes it to a numeric (double) value; N[expr, n] converts exact results to n-digit precision on demand.

3. Calculate — the algebra, calculus, linear-algebra toolbox

Every engineer's daily calculations — simplify an expression, differentiate, integrate, expand a Taylor series, solve a matrix equation — map to one Mathematica function per task. The functions read like verbs on the expression. Below, each block shows the input, the output, and what makes the call do what it does.

3.1 Algebra

To simplify an expression, you write Simplify; to factor, Factor; to expand, Expand. They take one expression and return a transformed version.

Simplify[(x^2 - 1)/(x - 1)]
x + 1

Simplify cancels the common factor (x - 1) symbolically — it knows both the numerator and denominator factor over the reals, and it performs the cancellation exactly.

Factor[x^4 - 1]
(-1 + x) (1 + x) (1 + x^2)

The right-hand side is the factored form over the rationals. Mathematica factors by design; Expand is its inverse and multiplies everything out.

3.2 Calculus

Differentiation and integration use the verbs D and Integrate. Because Mathematica is symbolic by default, these functions return symbolic results when they can — and when they can't, they leave the expression in integral form.

D[Sin[x] Cos[x], x]
Cos[x]^2 - Sin[x]^2

D[f, x] takes the derivative of f with respect to x. The output is cos²x − sin²x, which equals cos 2x — a simplification you'd get with Simplify.

Integrate[Exp[-x^2], {x, 0, Infinity}]
√π / 2

Integrate[expr, {x, a, b}] evaluates a definite integral. Mathematica evaluates the Gaussian integral exactly, giving the analytic form \(( \sqrt{\pi}/2 )\).

For Taylor and Maclaurin series, use Series:

Series[Sin[x], {x, 0, 6}]
x - x^3/6 + x^5/120 + O[x]^7

Series[expr, {x, x0, n}] returns the Taylor series of expr around x = x0 to order n. The O[x]^7 term marks the remainder — Mathematica's way of saying "there's more here that I'm not writing down."

3.3 Linear algebra

Matrices are just nested lists. Standard linear-algebra operations — solve a linear system, compute eigenvalues, invert a matrix — are all one-word functions.

A = {{2, 1}, {1, 3}}; b = {5, 4}; LinearSolve[A, b]
{1, 1}

LinearSolve[A, b] returns the vector x satisfying \((A x = b)\). It uses symbolic exact arithmetic by default, so the answer is exact.

Eigenvalues[{{0, 1}, {2, 3}}]
{(3 - Sqrt[13])/2, (3 + Sqrt[13])/2}

Eigenvalues are returned as exact radicals by default. Call N[%] to get numeric approximations.

3.4 Numeric calculation: N and Nest

Once you have an exact symbolic result, converting it to a number is a one-character function: N. If you want higher precision, pass a precision: N[expr, 50]. For iterating a function k times — e.g. f(f(f(x))) — use Nest.

Nest[#^2 + 1 &, 10, 2]
10202

Nest[f, x, k] applies f to x a total of k times. Here (x → x² + 1) is applied twice to 10: 10 → 101 → 10202. The & at the end of the pure function is how Mathematica signals "the function body is done."

Takeaway: Mathematica gives you a verb for every standard calculation — Simplify, Factor, D, Integrate, Series, LinearSolve, Eigenvalues, N. Each is a one-word function on an expression; results are exact by default and can be numerically approximated with N.

4. Solve — from equation to solution

The verbs here form a spectrum from "give me every solution, exactly" to "give me one numeric answer fast". Which one you pick depends on what the equation looks like and what you need.

Have an equation
Do you want all solutions, symbolically?
Do you have a nonlinear system with many variables?
Is it one variable, no closed form, you want speed?
Is it an ODE with initial conditions?
Solve
or Reduce for a full characterization
NSolve
numeric all-solutions
FindRoot
from an initial guess
DSolve (exact)
or NDSolve (numeric)
Figure 3. A decision tree for choosing the right olve function. Most engineering work lives in the first three boxes.

4.1 Solve: algebraic equations, all solutions

Solve[eqn, x] returns a list of rules, one per solution, in the form {x → value}. The rules are usable directly — you can substitute them into another expression with expr /. solution. This "rules everywhere" style is one of the cleanest parts of Mathematica.

Solve[x^2 - 3 x + 2 == 0, x]
{{x -> 1}, {x -> 2}}
Solve[x^3 - 1 == 0, x] /. x -> N[x]
{{x -> 1.}, {x -> -0.5 + 0.866025 I}, {x -> -0.5 - 0.866025 I}}

Solve always returns every complex root. The third root is complex — the cube roots of unity — and Mathematica includes it automatically. If you only want real roots, use Solve[eqn, x, Reals].

4.2 NSolve: numeric all-solutions

NSolve[eqn, x] is the numeric sibling of Solve. It's the right choice when your equation is a polynomial in several variables, or when the coefficients are already numeric and you want every root as a number.

NSolve[Sin[x] == 0.5, x, {x, -Pi, Pi}]
{{x -> 0.523599}, {x -> 2.61799}}

The third argument {x, -Pi, Pi} restricts x to a real interval. Without it, NSolve would return infinitely many roots — so the box is required for transcendental equations.

4.3 FindRoot: one numeric root from a guess

When you have a nonlinear equation with no closed form and you only need one root, FindRoot is the workhorse. It takes an initial guess and iterates numerically (Newton-like).

FindRoot[Exp[-x] == x, {x, 0.5}]
{x -> 0.567143}

The third argument {x, 0.5} tells FindRoot the starting value. Different starting values can lead to different roots in multi-root problems — so pick the guess with physical meaning.

4.4 Reduce: full characterization

For inequalities and logical conditions, Reduce gives a complete description of the solution set:

Reduce[x^2 < 4 && x > 0, x, Reals]
0 < x < 2

Reduce answers "for what values of x is this expression true?" as a human-readable condition. It is the tool for parameter ranges, stability margins, and feasibility checks.

4.5 Differential equations: DSolve and NDSolve

For an ordinary differential equation, DSolve attempts a closed-form solution and NDSolve integrates numerically. Both take the equation plus initial conditions as the first argument.

DSolve[{y''[t] + y[t] == 0, y[0] == 1, y'[0] == 0}, y[t], t]
{{y[t] -> Cos[t]}}

DSolve takes a list of equations (the ODE plus initial conditions), the unknown as a function y[t], and the independent variable t. The result is the closed-form solution.

NDSolve[{x''[t] + 0.1 x'[t] + x[t] == 0, x[0] == 1, x'[0] == 0}, x, {t, 0, 30}]
{x -> InterpolatingFunction[{{0., 30.}}, ...]}

When an ODE has no closed form — e.g. the Van der Pol oscillator — NDSolve returns an InterpolatingFunction: a numerical object you can evaluate at any point in the domain. That object plugs straight into Plot.

Takeaway: Solve and Reduce are symbolic and exhaustive; NSolve is the numeric multi-solution version; FindRoot is a fast single-root workhorse; DSolve and NDSolve handle ODEs exactly and numerically. Solutions come back as rules, ready to substitute with /. .

5. Plot — from an expression to a picture

Plotting in Mathematica has one unusual feature: you never write a "plot function" and then call it. You just write Plot[expr, {x, x0, x1}] and Mathematica figures out the sampling, the y-range, the tick marks, and the colors. The function Plot is a directive: it takes the expression and the domain and produces a picture.

Plot[f[x], {x, a, b}]
1D function
ParametricPlot[{x(t), y(t)}, {t, a, b}]
parametric curve
Plot3D[f[x,y], {x, a, b}, {y, c, d}]
3D surface
BarChart[data]
data visualization
DensityPlot[f[x,y], {x, a, b}, {y, c, d}]
2D density / contour
ListPlot[data]
scatter / line from data
Figure 4. The main plotting family. Each function shares the same shape: [expression, {variables}]. Mathematica infers ranges, ticks, and coloring from the expression.

5.1 Plot: the workhorse

The call is Plot[expr, {x, x_min, x_max}]. That's it. Mathematica picks a sensible vertical range, samples adaptively, and colors the curve.

Plot[Sin[x], {x, 0, 2 Pi}]
↪ (sine curve over [0, 2π])

5.2 Plot with options

Options are keyword-value pairs in square brackets, separated by commas, at the end of the call. This is the same style used by most Wolfram functions.

Plot[Sin[x], {x, 0, 2 Pi}, PlotLabel -> "Sine over one period", AxesLabel -> {"x", "sin x"}, PlotStyle -> Red, Frame -> True]
↪ (labeled, framed, red curve)

PlotLabel, AxesLabel, PlotStyle, Frame are options that customize the picture. Mathematica accepts thousands of these for different functions — a single language for "how to render this result."

5.3 Overlaying curves

To plot multiple expressions on the same axes, pass a list as the first argument:

Plot[{Sin[x], Sin[2 x], Sin[3 x]}, {x, 0, 2 Pi}, PlotLegends -> Automatic]
↪ (three curves with an automatic legend)

The list form is the same convention used by ListPlot, ParametricPlot, and everything else in the plotting family. PlotLegends -> Automatic auto-generates labels.

5.4 3D and other plots

Plot3D takes the function of two variables and two ranges:

Plot3D[Exp[-(x^2 + y^2)], {x, -3, 3}, {y, -3, 3}]
↪ (Gaussian bump surface)

ContourPlot shows level sets of f(x, y); DensityPlot shades by value; VectorPlot draws a field of vectors. Each takes the same [expr, {x, ...}, {y, ...}] shape — you pick the function, the rest is automatic.

5.5 Interactivity: Manipulate

Once you have a plot, wrapping it in Manipulate[plot, {param, pmin, pmax}] adds sliders for the parameters you mention. The plot updates live as you drag.

Manipulate[ Plot[Sin[a x + b], {x, 0, 2 Pi}], {a, 1, 5}, {b, 0, 2 Pi}]
↪ (interactive plot with two sliders)

This is the pattern for exploratory work: write the plot as a function of parameters, wrap it in Manipulate, and let Mathematica build the UI for you. A whole analysis can be turned into a "toy" you can feel.

Takeaway: Plot[expr, {x, x0, x1}] is the whole story. Options customize the picture; lists overlay curves; Plot3D, ContourPlot, and DensityPlot use the same shape for higher dimensions; Manipulate adds sliders to any plot.

6. Worked example: the damped harmonic oscillator

Let's put everything together. The damped harmonic oscillator is the classic equation an engineer will encounter: mass, spring, and dashpot in series.

\[m\ddot{x} + c\,\dot{x} + k\,x = 0,\qquad\text{or equivalently}\qquad \ddot{x} + 2\zeta\omega_n \dot{x} + \omega_n^2 x = 0,\]

where m is mass, c is damping, k is stiffness, and \((\zeta = c/(2\sqrt{mk}))\) is the dimensionless damping ratio. The three regimes of interest — underdamped (\((\zeta < 1)\)), critically damped (\((\zeta = 1)\)), and overdamped (\((\zeta > 1)\)) — come straight from solving the characteristic equation.

Step 1: solve symbolically

sol = DSolve[ {x''[t] + 2 z wn x'[t] + wn^2 x[t] == 0, x[0] == 1, x'[0] == 0}, x[t], t]
{{x[t] -> ... closed form in z, wn, t}}

DSolve returns the exact solution as a rule. Assigning it to sol keeps it in the notebook's state for later substitution.

Step 2: substitute a specific damping ratio and plot

Plot[x[t] /. First[sol] /. {z -> 0.3, wn -> 1}, {t, 0, 20}, PlotLabel -> "Underdamped, ζ = 0.3"]
↪ (decaying oscillation)

The chain /. First[sol] /. {z -> 0.3, wn -> 1} substitutes the symbolic solution and then the numeric parameters — two rule substitutions in one line.

Step 3: sweep the parameter and animate

Manipulate[ Plot[x[t] /. First[sol] /. {z -> zeta, wn -> 1}, {t, 0, 20}, PlotRange -> {-2, 2}, PlotLabel -> "ζ = " <> ToString[zeta]], {zeta, 0.01, 2}]
↪ (slider for ζ: from underdamped to overdamped)

Now the whole behavior — underdamped ringing, critical damping, overdamped monotone decay — is one slider away. This is what "interactive symbolic computation" means in practice.

Step 4: verify numerically

To check that the symbolic solution is right, integrate numerically and compare:

num = NDSolve[ {x''[t] + 2*0.3*1*x'[t] + 1^2*x[t] == 0, x[0] == 1, x'[0] == 0}, x, {t, 0, 20}]; Plot[{x[t] /. First[sol] /. {z -> 0.3, wn -> 1}, x[t] /. First[num]}, {t, 0, 20}, PlotLegends -> {"symbolic", "numeric"}]
↪ (two curves, indistinguishable — the analytic form is correct)
Takeaway: Solve → substitute → plot → manipulate is the working loop. Symbolic solutions are always available for later numerical comparison; Manipulate turns any parameter into a slider with one line of code.

7. An interactive demo: damped oscillator, plotted here

The plot below is a live rendering of the same equation — not Mathematica, but a plain-canvas implementation of Plot[Sin-like damped curve] so you can feel the workflow even without Mathematica. Drag the sliders to see how the damping ratio and natural frequency reshape the response. When you're in Mathematica, the same picture comes from a single Manipulate[Plot[...], {zeta, 0.01, 2}, {wn, 0.5, 3}].

Read it like Mathematica: the sliders are the parameters you would wrap in Manipulate; the canvas is the Plot output; the regime badge is a Reduce-style classification of ζ. The pattern is identical — only the implementation differs.

8. Variations and pitfalls

Once you can calculate, solve, and plot, the questions become about when each tool is right. A few traps show up constantly:

8.1 Exact vs. numeric in a Solve call

As noted in §2, a decimal point in a coefficient makes the whole solve numeric:

Solve[x^2 == 2 x + 1, x] — exact coefficients
{{x -> 1 - Sqrt[2]}, {x -> 1 + Sqrt[2]}}
Solve[x^2 == 2. x + 1, x] — note the dot in 2.
{{x -> -0.414214}, {x -> 2.41421}}

Same equation, different answer style. If you need the closed form, don't introduce a decimal anywhere in the input.

8.2 Solve returns a list of rules

Beginners write sol = Solve[eqn, x] and then try to use sol directly. It won't work — sol is a list, so sol[[1]] gives the first rule and x /. First[sol] substitutes into an expression. Learn the indexing and the /. operator early.

8.3 FindRoot needs a guess; NSolve does not

These two are often confused. NSolve finds every solution in a bounded region. FindRoot finds one solution near your starting value. Use NSolve for polynomials; use FindRoot for transcendental or stiff problems where a single physical solution matters.

8.4 Integrate can fail silently

If Integrate can't find a closed form, it returns the integral unevaluated. Check the output — a symbol like Integrate[...] in your result means Mathematica gave up, and you should switch to NIntegrate for a numeric value.

8.5 Plot options vs. functions

Options go at the end of a call in square brackets: Plot[..., PlotStyle -> Red]. A function you write in the expression is f[x]. Mixing these up is a common first-week error.

8.6 The /. substitution operator

The double-dot operator /. (pronounced "slash dot" or "rule-apply") applies a rule to an expression: expr /. x -> 5 replaces every x in expr with 5. It is the reason solutions from Solve are useful — they are rules, ready to substitute.

8.7 When to use Reduce instead of Solve

Solve returns a list of rules for each solution. Reduce returns a single logical statement describing the full solution set, including inequalities. Use Reduce when you need "for what parameters is this stable?" rather than "what are the roots of this polynomial?".

Takeaway: Watch your decimal points, remember Solve returns a list of rules, prefer NSolve for polynomial all-roots and FindRoot for a single fast root, and use /. to plug solutions back in.

9. The workflow, at a glance

1
Define
an expression
→
2
Simplify / Solve
exact form
→
3
N[...]
numeric value
→
4
Plot[...]
a picture
→
5
Manipulate
a slider
↺
6
Verify with NDSolve
numeric sanity check
Figure 5. The engineer's daily loop in Mathematica: symbolic first, numeric on demand, picture for intuition, slider for exploration, and a numerical ODE solve to sanity-check the symbolic work.

10. Summary

Three verbs, one model:

The design that makes all three coherent: the Wolfram Language treats every result — expression, number, matrix, function, solution, plot — as the same kind of object. That is why N turns a symbolic result numeric, why Plot takes an expression and produces a picture, and why Manipulate can put a slider on any parameter of any expression.

The whole point: Mathematica is not a calculator you call — it's a computational language where the input is the mathematical object. Learn to write expressions, and you learn to calculate, solve, and plot at the same time.

Written as an offline, self-contained HTML document. Math typeset with KaTeX (fonts embedded as data URIs — no network dependencies).
For discussion and refinement, ask me questions below — I'll update the page to answer them.