Skip to content

To-do 10

What should you prepare before the session?

Practice your skills by reviewing the previous sessions

Topic 1: Interfaces

  • Terminal: concepts and basic commands
  • Git: concepts and basic commands
  • AI: concepts

Topic 2: Go language

  • Go concepts
  • Go syntax and go tool
  • Writing Go programs
  • Goroutines

Practice implementing math formulas/problems in Go

For example:

AXPY in parallel

Implement the AXPY operation

\[ {\mathbb{y}} = a {\mathbb{x}} + {\mathbb{y}} \]

in parallel.

How can you limit the number of goroutines in case the vectors have many entries?

Parallel exponential series

The exponential function can be approximated by the truncated Taylor series:

\[ e^x \approx \sum_{n=0}^{N} \frac{x^n}{n!} \]

A. Implement a function:

func expApprox(x float64, N int) float64
that computes the series sequentially.

B. Write a second function:

func expApproxParallel(x float64, N int) float64
that computes the series in parallel.

Numerical integration

Consider the approximation of the integral in one dimension:

\[ \int_a^b f(x),dx \]

using the midpoint rule:

\[ \sum_{i=0}^{N-1} f(x_i)\Delta x \]

A. Implement a function:

func integrate(f func(float64) float64, a, b float64, N int) float64
that computes the midpoint rule sequentially.

B. Write a parallel version of the midpoint rule.