Question: Do in Maple 8 Non - Linear Regression Study carefully the Maple code provided in the next 8 pages, that applies non - linear regression

Do in Maple
8 Non-Linear Regression
Study carefully the Maple code provided in the next 8 pages, that applies non-linear
regression to approximate the trigonometric function
cos(x50)sin(x50)
in the interval 0,4.
Modify the code to apply non-linear regression to approximate an arbitrary trigonometric
function made of cos and sin terms. Your code should be able to work with an arbitrary
number of higher frequency terms.
Test your code with the following trigonometric function:
cos(x2)+cos(2x2)+sin(x2)+sin(2x2)
in the interval 0,4.
How many higher frequency terms do you need to add into your model, in order to get a
reasonable approximation of this function? Illustrate the quality of your approximation
by a plot similar to the ones contained in the Maple code, i.e. overlapping the sampling
data and the data produced by the model.
Code:
n :=50;
x :=[seq(Pi*i/n, i =1.. n)];
y :=[seq(evalf(cos(Pi*i/n)*sin(Pi*i/n)), i =1.. n)];
S := evalf(sum((y[i]- a1*sin(omega*x[i])- a2*cos(omega*x[i]))^2, i =1.. n));
Sa1 := diff(S, a1);
Sa2 := diff(S, a2);
sols := solve({Sa1, Sa2},{a1, a2});
assign(sols);
a1;
a2;
dataPoints := plot([seq([x[i], y[i]], i =1.. n)], style = point);
lb := min(op(x));
ub := max(op(x));
quadraticRegression := plot(a1*sin(omega*z)+ a2*cos(omega*z), z = lb .. ub, color = blue);
plots[display]({dataPoints, quadraticRegression});
 Do in Maple 8 Non-Linear Regression Study carefully the Maple code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!