Skip to main content
SciNet
  • Home
  • All Courses
  • Calendar
  • Certificates
  • SciNet
    Main Site Documentation my.SciNet
  • CCDB
  • More
Close
Toggle search input
English
English Français
You are currently using guest access
Log in
SciNet
Home All Courses Calendar Certificates SciNet Collapse Expand
Main Site Documentation my.SciNet
CCDB
Expand all Collapse all
  1. PHY1610 - Winter 2026
  2. 4. Numerics and documentation

4. Numerics and documentation

Completion requirements
Opened: Friday, 6 February 2026, 12:00 AM
Due: Friday, 13 February 2026, 11:59 PM

In this assignment, your task is to write a fully commented and documented module - using Doxygen - that can solve the fixed point equation f(x) = x for arbitrary functions f.

The primary function in this module should be of the following form:

std::pair<double,int> solve_fixed_point(std::function<double(double)> f, double x0,  double reltol, int max);

Here, "std::function<double(double)>" is a C++ way to pass a function to another function; it requires the "<functional>" header.

The pair returned should contain the solved value of x and the number of times f was repeatedy called. To use "std::pair", you need to include the "<utility>" header.

This function should use the following method: Starting from a given guess "x0" for x, compute a new value x'=f(x) to replace x, and repeat until the relative difference |(x'-x)/x| is smaller than "reltol". The number of repeats should not exceed "max".

In addition, the module should have a second function called "relative_error" that can compute the relative error given f and x, i.e., how much f(x) and x differ relatively.

Your module should have a proper header file and separate cpp file, with comments in Doxygen format.

As an example use case, the program solverexample.ccp (see below) should work with this module.

Use a Makefile to build the module, to build and run the example use case, and to create the documentation for the module with Doxygen (both in pdf and in html format).

Use git version control throughout with several meaningful commits. Make sure your repo contains:

  • The header and cpp file of the module
  • The example code solverexample.cpp
  • The Makefile
  • The Doxygen file
  • The documentation pdf that Doxygen produced.

Submit the assignment with git2zip as in the previous assignments. The deadline for this assignment is Friday February 13th, at 23:59 PM. The late policy can be found in the syllabus. 


  • solverexample.cpp solverexample.cpp
    6 February 2026, 11:45 AM
You are currently using guest access (Log in)
Data retention summary


All content on this website is made available under the Creative Commons Attribution 4.0 International licence, with the exception of all videos which are released under the Creative Commons Attribution-NoDerivatives 4.0 International licence.
Powered by Moodle