# Assignment #1 Maclurin Series Application

Original price was: \$40.00.Current price is: \$30.00.

Category:
Rate this product

CST 8233 – Assignment #1
Maclurin Series Application
Purpose: You are employed by an architecture company to write code for a building
simulation. The company wants to model the start of the motion response of a tall building
hit by strong winds that set it in vibration that builds up catastrophically. The following graph
shows the vibration oscillations growing catastrophically in time (along the x-axis) over a
large number of Oscillations:
The simulation must run on a PC in real time and is part of a larger simulation that includes
the motion of other structures. Because it must run in real-time it is too time consuming to
use the more accurate but slow math library functions, so your task is to investigate a less
accurate but faster Maclaurin Series approximation for the start of the motion where a few
terms might be adequate. The formula you will use for an approximation for the movement
D of the top of the building in meters with time t in seconds after the vibration starts up is:
D(t) = e
tcos(t)
In this application you will investigate the series approximation to the motion for its
accuracy over initial times up to 4 seconds after the start of the vibration.
Algorithm: Determine the Maclaurin Series approximation to D(t) = e
tcos(t) as a power
series in t (all variables are doubles) as given in lectures up to the first 7 non-zero terms (you
need 7 for the truncation error on 6 terms). Then as often as the user wishes to repeat, allow
the user to choose the number of non- zero terms (from 1 to 6) in the series approximation
and what range (between 0.0 and 4.0) of values of t to evaluate in 10 equal increments.
As a check that you have to correct series, you should to derive it two ways to see if they
agree: 1. from 1st principles by differentiation, 2. by the product of the separate et and cos(t)
series.
The purpose of the series approximation is to speed up its execution so no functions are
used in the evaluation of the terms of the series, whether they be math library functions
such as exp() or pow() etc., or any other function, and terms such as x3
for example are
written explicitly in your code as x*x*x and factorials are precalculated and written in as
numbers.
For each value of t the Maclaurin series approximation is output together with the exact
value from the math library. Also output the relative error in two ways:
1. From comparison with the exact value calculated using the math library functions:
Exact % Error = 100*(exact value – series value)/exact value
2
2. From the first truncated term. This gives you an idea of how well the first truncated term
approximates to the error.
Truncation % Error = 100*first truncated term/series value.
The sample output at the end shows you what is expected. Yours should be the same.
Set up an empty project in Visual Studio 2019 with the name ass1. Write the code to
implement the application in a file named ass1.cpp using the C (or/C++) programming
language.
Example output is given at the end. Yours should be very similar but may differ very slightly
due to round-off errors from the way you have evaluated your series. Note that your
assignment might be tested with different parameters than those shown in the example
output.
See the Marking Sheet for how you can lose marks, but you definitely lose 60% or more if:
⚫ the series is wrong
⚫ Your application won’t build in Visual Studio 2019
⚫ Your application crashes in normal operation
⚫ I can’t build it because you submitted the wrong files or the files are missing, even if it’s
an honest mistake – this gets 100% deduction.
Example Output
Evaluate the Maclaurin Series approximation to D(t) = exp(t)*cos(t)
1: Evaluate the series
2: quit
1
Evaluating the series
Please enter the number of (non-zero) terms in the series (1, 2, 3, 4, 5 or 6):
6
Please enter the range of t to evaluate in 10 increments (0.0 < t < +4.0): 4
MACLAURIN SERIES
t D(t) Series D(t) Exact %RExactE %RSerE
0.000e+00 1.00000e+00 1.00000e+00 0.00000e+00 0.00000e+00
4.000e-01 1.37406e+00 1.37406e+00 1.97652e-05 1.89266e-05
8.000e-01 1.55048e+00 1.55055e+00 4.67032e-03 4.29392e-03
1.200e+00 1.20114e+00 1.20307e+00 1.60134e-01 1.42054e-01
1.600e+00 -1.64517e-01 -1.44626e-01 -1.37529e+01 -1.03598e+01
2.000e+00 -3.19683e+00 -3.07493e+00 -3.96409e+00 -3.17776e+00
2.400e+00 -8.66380e+00 -8.12842e+00 -6.58647e+00 -5.04175e+00
2.800e+00 -1.73567e+01 -1.54945e+01 -1.20181e+01 -8.63769e+00
3.200e+00 -2.99298e+01 -2.44907e+01 -2.22089e+01 -1.45779e+01
3.600e+00 -4.66622e+01 -3.28198e+01 -4.21772e+01 -2.39913e+01
4.000e+00 -6.71270e+01 -3.56877e+01 -8.80954e+01 -3.87420e+01
Evaluate the Maclaurin Series approximation to D(t) = exp(t)*cos(t)
1: Evaluate the series
2: quit
1
Evaluating the series
Please enter the number of (non-zero) terms in the series (1, 2, 3, 4, 5 or 6):
5
Please enter the range of t to evaluate in 10 increments (0.0 < t < +4.0): 3
MACLAURIN SERIES
t D(t) Series D(t) Exact %RExactE %RSerE
0.000e+00 1.00000e+00 1.00000e+00 0.00000e+00 0.00000e+00
3.000e-01 1.28957e+00 1.28957e+00 2.90054e-05 2.69193e-05
6.000e-01 1.50381e+00 1.50386e+00 3.42722e-03 2.95478e-03
9.000e-01 1.52797e+00 1.52891e+00 6.19271e-02 4.96870e-02
1.200e+00 1.19546e+00 1.20307e+00 6.32890e-01 4.75767e-01
1.500e+00 2.78125e-01 3.17022e-01 1.22695e+01 9.75120e+00
1.800e+00 -1.52346e+00 -1.37449e+00 -1.08377e+01 -6.37877e+00
2.100e+00 -4.58972e+00 -4.12266e+00 -1.13290e+01 -6.22886e+00
2.400e+00 -9.39181e+00 -8.12842e+00 -1.55428e+01 -7.75156e+00
2.700e+00 -1.65013e+01 -1.34524e+01 -2.26649e+01 -1.00621e+01
3.000e+00 -2.66000e+01 -1.98845e+01 -3.37723e+01 -1.30505e+01
Evaluate the Maclaurin Series approximation to D(t) = exp(t)*cos(t)
1: Evaluate the series
2: quit
2

## Reviews

There are no reviews yet.

Scroll to Top