Exercise: Fitting a Wave

In this exercise, you will find the parameters of an unknown equation by solving a system of linear equations.

We'll cover the following

Task

In this exercise, you will fit a wave by finding the unknown parameters of the equation

y=a sin(πt)+b sin(2πt)+c sin(3πt)+d sin(4πt)y=a\space sin(\pi t)+b\space sin(2\pi t)+c\space sin(3\pi t)+d\space sin(4\pi t)

using the data:

(t0,y0)=(0.25,3)(t_0, y_0)=(0.25, 3)

(t1,y1)=(0.5,2)(t_1, y_1)=(0.5, 2)

(t2,y2)=(0.75,3)(t_2, y_2)=(0.75, -3)

(t3,y3)=(1,0)(t_3, y_3)=(1, 0)

Problem statement

By substituting the values given above, form a system of four linear equations and solve for the unknown parameters: a,b,ca, b, c and dd

Create a plot of the wave for tt going from 00 to 11. Show the four measurements given above with dots. Add legends to your graphs as well.

A basic structure of the code is given to get you started.

Get hands-on with 1200+ tech skills courses.