Courses / Computer Science I
Programming II

Program Design for Scientific or Engineering Tasks

Computer Science I 187 words Free to read

Computing for Science

Scientific and engineering programs process heavy numbers, where correctness requires strict numerical care.

The first hazard is floating-point arithmetic. Computers store real decimals approximately, meaning 0.1 + 0.2 does not equal 0.3.

Comparison TypeCode SyntaxSafe for Floats?
Exact Equalitya == bNo (fails due to rounding)
Tolerance Check|a - b| < \varepsilonYes (checks if close)

Common Pitfall: Never compare floats with ==. Accumulating rounding errors mean computation order matters.

Reliability & Units

Scientific code lives or dies by units and dimensions. Mixing meters with feet, or radians with degrees, causes real disaster. Always track units explicitly.

Structure your code for reliability:

Factor math into tested functions and cross-check results against known limiting behaviors.

Program Design for Scientific or Engineering Tasks

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

11practice questions
2interactive scenes

Programming II