Title: ENGINEERING COMPUTING ENG1602
1ENGINEERING COMPUTING ENG1602
BACHELOR of ENGINEERING
Week 3 Lecture 1 Microsoft EXCEL CASE
STUDY REGRESSION FOURIER SERIES
2CASE STUDY LEAST SQUARES
- Often the Engineer has to fit a (Mathematical)
model to some experimental data - the data will
not generally fit perfectly as there may be
errors ( in measurement, or un-modelled small
effects, etc.) - Take the case of a simple linear model - one has
to find a line that best fits What does that
mean?
3CURVE FITTING
- If f(x) is an unknown function defined by pairs
of x values and corresponding y values, so that y
f(x) over the given range. - It is desired to select another known function
g(x, C1, C2,...... Cn)
and then determine the constants
C1, C2, ...... Cn such that g(x) fits
the given values of f(x) with minimum Error.
4Best Fit - Minimum Error - 1.
- Simple Strategy - If there are m pairs of data
and n unknown constants in the chosen function
g(x), it being assumed that n lt m - Then Select n pairs of values from the m
available. - Substitute Solve for the values of the n
constants from the n resulting simultaneous
equations.
5Best Fit - Minimum Error - 2.
- Then the function g(x) will fit the data exactly
at the n chosen points. - but there may be serious errors at the (m-n)
unused points. - Note that the chosen function g(x) must be such
that n lt m, otherwise there are not enough
equations to solve for the unknown constants. - However if m gt n then which n points should be
selected ?
6Example Fit y g(x) A Bx ( n 2 ) to 3
Data Points ( m 3 )
Point 2
y
Error
Point 3 Exact
B
Simple Solution using Data Points 1 3 to
solve for A B
1
Point 1 Exact
A
x
7Analysis of the Solution
- Whilst the function fits exactly at two points,
there are serious errors elsewhere - Also totally different results would result
depending which two of the three available points
were chosen to determine the constants - It is possible to do better !
8Intuitive Line of Best Fit
Point 2 Error
y
Point 3 Error
Intuitive Solution using Data Points 1, 2 3
Point 1 Error
x
9Using All the Specified Points in the Analysis -
1.
- If the Error at a given point i is defines
as - Then Best Fit could be defined by the values of
the constants that minimise
10Using All the Specified Points in the Analysis -
2.
- This approach is not so easy to analyse
- A better approach is to minimise the Sum of
(errors)2 - the so called LEAST SQUARES Criteria
- Where S is called the sum of the residuals
11For our Straight Line Application
12Solving for Constants a b
13Least Squares Fit - Conclusions
- These relationships involve all the data points
specified - One could write a Java Program to read the data
and work our the constants or - EXCEL has a wide range of REGRESSION facilities (
which also return some diagnostics on how well
the data fits the model - since you always get an
answer even if the data doesnt fit the model by
any reasonable intuitive meaning - you should
always check how good the answer is).
14Using EXCEL - TRENDLINEs -1.
- First you must create a chart or graph of the
given data - Use Excels Graph Wizard icon after
highlighting the cells containing the given x and
y data - Then pull open an area on your work sheet for the
graph or select INSERT CHART for a separate sheet
15Using EXCEL - TRENDLINEs -2.
- For technical applications, always use the
XYScatter Graph option - follow the other screen
prompts to create a graph with straight line
segments between each point - To insert a TRENDLINE select the graph by Left
clicking on it with the mouse - Select INSERT TRENDLINE from the pull down Menu
and follow the instructions - When finished you can check how well the
generated Trendline fits the given data
16CASE STUDY Fourier Series
- A famous French Engineer, Fourier, proposed that
reasonable functions could be expressed as the
sum of sinusoids of different frequencies - f(x) -gt Sum of sinusoids - called Fourier
Analysis - Sum of sinusoids -gt f(x) - called Fourier
Synthesis
17Typical Sinusoids
18Fourier Series - 1.
- If a function is periodic ( and meets a few other
criteria for reasonable), then it may be
represented by a Fourier Series and there are
formulae for calculating the coefficients
(amplitudes and phases of the sinusoids) - Important applications of this theory involve
certain Electrical and Mechanical systems that
are linear and Time/Shift Invariant).
19Fourier Series Example
Show how a square wave can be created from its
Fourier Sine Series Components
A square wave comprises only odd harmonics
(1,3,5,7) (see Lab 2)
20Fourier Series - 2.
- Without developing the theory further - we can
say that if we excite the system with a sinusoid
of a certain frequency - then the response is
also sinusoidal of the same frequency but with
different amplitude and phase. - Moreover if the excitation consists of a sum of
sinusoids, then the system responds to each
sinusoid independently. - To determine what a system does to input f(x) we
simply decompose f(x) into a sum of sinusoids
21Fourier Series - 3.
- Then work out the new amplitude and phase of each
component from the equations describing the
systems performance - Finally Add together the various sinusoids (
using the new amplitudes and phases) to get the
output
22Damped Vibration Analysis
Example Shock Absorber in a car Assuming that
platform vibration is driven by the a square
wave, what how will the mass vibrate?
23Mass Vibration Waveform
Plot of the mass vibration waveform using
1,3,5,7,9 harmonics of the platform driving
force waveform (See Lab 2)