Visual Debugging
Visual debugging means using a plot to notice a mistake.
The plot does not replace reasoning. It gives your reasoning evidence.
A wrong curve
Suppose you meant to compute:
y = x * x
but accidentally wrote:
y = x + x
The numbers may not alarm you at first. The plot makes the mistake visible.
Compare expected and computed curves
Ready to run.
The computed line is straight. The expected curve bends upward. That difference points back to the formula.
Do not trust a pretty plot
A plot can also mislead if:
- axes are unlabeled;
- units are unclear;
- arrays are accidentally sorted or shuffled;
- the wrong columns are plotted;
- the range hides the important region.
Visual debugging still needs careful questions.
Write down what you see
After a plot, write one or two plain sentences:
The computed curve is linear, but the expected curve bends upward.
This suggests the formula used addition instead of multiplication.
That habit turns a picture into an inspection result.
What should you do after making an inspection plot?
Select one choice, then check.
Hint
Turn the visible pattern into one or two sentences before deciding what caused it.
Solution
Write what the plot shows. Separate observation from explanation: first describe the visible evidence, then state what computation or data issue it suggests.