Download as xls, pdf, or txt
Download as xls, pdf, or txt
You are on page 1of 9

y = 4 sin(x) - x2

Problem 1a
5.00

f(x) = 0.0109648421x^5 + 3.41626605977994E-017x^4 - 0.4376191494x^3 - 1x^2 + 3.3808285272x


R = 0.9993531178
-5.00

-15.00

-25.00

-35.00
-6.0

-4.0

-2.0

0.0

2.0

4.0

6.0

Problem 1b
20.00

0.00

-20.00

function
polynomial

-40.00

Notice that the polynomial curve is a


reasonable fit to the function only within
the range of x for which it was derived, i.e.
- 5 < x < + 5. This is typical of polynomial
fits, a presents a serious hazard in using
them.

-60.00

-80.00

-100.00

-120.00
-8.0

-6.0

-4.0

-2.0

0.0

2.0

4.0

6.0

8.0

Problem 2

-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0

y
-17.0
-4.1
4.0
8.1
9.0
7.4
4.0
-0.4
-5.0
-9.1
-12.0
-12.9
-11.0
-5.6
4.0
18.6
39.0

y = x3+x2-9x-5
50.0
40.0
30.0
20.0

10.0
0.0
-5.0 -4.0 -3.0 -2.0 -1.0
-10.00.0 1.0 2.0 3.0 4.0 5.0
-20.0

Solutions between -3 and -4, 0 and -1, 2 and 3.


Now use Goal Seek to find exact values.
x
-3.279454
-0.540721
2.820093

f(x)

initial guess for x


0.0
-3 or -4
0.0
-1 or -0
0.0
2 or 3

If the initial guess is beyond a maximum or minimum, the next solution will be found instead

Problem 1 a
Function is y = 4 sin(x) - x2

1b: Polynomial is y = 0.011x5 - 0.4376x3 - x2 + 3.3808x

Extra credit, possibili


Use Solver to get more sig
y

y
x
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0

y
-21.16
-16.34
-12.97
-10.85
-9.56
-8.64
-7.64
-6.24
-4.37
-2.17
0.00
1.67
2.37
1.74
-0.36
-3.86
-8.44
-13.65
-19.03
-24.16
-28.84

x
-7.0
-6.5
-6.0
-5.5
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
5.5
6.0
6.5
7.0

from function from polynomial


-51.63
-107.45
-43.11
-71.68
-34.88
-47.30
-27.43
-31.40
-21.16
-21.58
-16.34
-15.89
-12.97
-12.78
-10.85
-11.10
-9.56
-10.00
-8.64
-8.94
-7.64
-7.61
-6.24
-5.93
-4.37
-3.95
-2.17
-1.89
0.00
0.00
1.67
1.39
2.37
1.95
1.74
1.43
-0.36
-0.39
-3.86
-3.56
-8.44
-8.00
-13.65
-13.40
-19.03
-19.22
-24.16
-24.61
-28.84
-28.42
-33.07
-29.10
-37.12
-24.70
-41.39
-12.82
-46.37
9.45

x
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5
4.0
4.5
5.0
Average:

Extra credit, possibility 2


Use multiple linear regression analysis to get polynomial coefficients
x
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5

y
-21.16
-16.34
-12.97
-10.85
-9.56
-8.64
-7.64
-6.24
-4.37
-2.17
0.00
1.67
2.37
1.74
-0.36
-3.86
-8.44
-13.65

x
-5.0
-4.5
-4.0
-3.5
-3.0
-2.5
-2.0
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
3.5

x2
25.0
20.3
16.0
12.3
9.0
6.3
4.0
2.3
1.0
0.3
0.0
0.3
1.0
2.3
4.0
6.3
9.0
12.3

x3

x4
-125.0
-91.1
-64.0
-42.9
-27.0
-15.6
-8.0
-3.4
-1.0
-0.1
0.0
0.1
1.0
3.4
8.0
15.6
27.0
42.9

625.0
410.1
256.0
150.1
81.0
39.1
16.0
5.1
1.0
0.1
0.0
0.1
1.0
5.1
16.0
39.1
81.0
150.1

x5
-3125.0
-1845.3
-1024.0
-525.2
-243.0
-97.7
-32.0
-7.6
-1.0
0.0
0.0
0.0
1.0
7.6
32.0
97.7
243.0
525.2

from function
-21.16
-16.34
-12.97
-10.85
-9.56
-8.64
-7.64
-6.24
-4.37
-2.17
0.00
1.67
2.37
1.74
-0.36
-3.86
-8.44
-13.65
-19.03
-24.16
-28.84
-9.17

4.0
4.5
5.0

-19.03
-24.16
-28.84

4.0
4.5
5.0

16.0
20.3
25.0

64.0
91.1
125.0

256.0
410.1
625.0

1024.0
1845.3
3125.0

SUMMARY OUTPUT
Regression Statistics
Multiple R
0.999316
R Square
0.998633
Adjusted R Squ 0.998177
Standard Error 0.380053
Observations
21
ANOVA
df
Regression
Residual
Total

Intercept
X Variable 1
X Variable 2
X Variable 3
X Variable 4
X Variable 5

SS
MS
F
Significance F
5 1582.554 316.5108 2191.2910047 6.40986918E-021
15 2.166605 0.14444
20 1584.721

Coefficient Standard Et Stat


0 0.156346
0
3.380829 0.122394 27.62241
-1 0.036148 -27.6639
-0.437619 0.017865 -24.49624
0 0.001483
0
0.010965 0.000579 18.94397

P-value
1
2.810184E-014
2.748750E-014
1.641192E-013
1
6.914115E-012

Lower 95%
-0.3332433835
3.1199509058
-1.0770480936
-0.4756969834
-0.0031611553
0.0097311501

Upper 95%Lower 95. Upper 95.0%


0.333243 -0.333243
0.3332433835
3.641706 3.119951
3.6417061487
-0.922952 -1.077048 -0.9229519064
-0.399541 -0.475697 -0.3995413153
0.003161 -0.003161
0.0031611553
0.012199 0.009731
0.0121985341

This gives y = 3.38089 x - x2 - 0.43762 x3 +0.010965 x5


Which is much cleaner than the forms given above (0 values for intercept and 4th power term)

Extra credit, possibility 1


Use Solver to get more significant figures on polynomial
y
from polynomial
-21.47
-15.82
-12.74
-11.08
-9.99
-8.94
-7.61
-5.93
-3.95
-1.89
0.00
1.39
1.95
1.43
-0.39
-3.56
-8.01
-13.42
-19.26
-24.68
-28.53
Sum:

(yf-yavg)2
143.94
51.45
14.49
2.82
0.16
0.27
2.34
8.57
23.05
48.99
84.03
117.38
133.00
118.95
77.51
28.20
0.53
20.13
97.23
224.80
386.87
1584.72
R2:

(yf-yp)2
0.091417
0.271287
0.052368
0.053973
0.182291
0.084856
0.000653
0.09761
0.169515
0.079332
0
0.079332
0.169515
0.09761
0.000653
0.084856
0.182291
0.053973
0.052368
0.271289
0.091415
2.17
0.99863

a1
a2

3.3808
-1

a3 -0.437602
a4 -2.24E-09
a5 0.010964
Using Solver to
minimize cell L26
Could also set a4=0

Use of Excel for polynomial fits and solving equations.

W.R. Wilcox, Clarkson University, spring 2004

Problem 1:
a. Calculate y = 4 sin(x) - x2 from x = - 5 to + 5 using increments of 0.5.
Plot the result and fit the data using a fifth-order polynomial with zero intercept.
(Use trendline and display the equation.)
Right-click on a data point and add trendline. It may be necessary to first d
b. Now plot this same function from x = -7 to + 7. On the same graph, plot
the fifth order polynomial you found in part a.
What general conclusion can you draw from these results?
Problem 2:
a. Plot y = x3 + x2 - 9x -5 for x from x = - 4 to + 4.
From this plot, estimate the values of x at which y = 0.
b. Use goal seek to find more accurate values of x at which y = 0.
Use the results of part a as your initial guesses.

(In Excel 2007 Goal Seek is at Data / What-If

Extra credit:
You will note that the trendline equation in Problem 1 does not give very many significant
figures for the constants in the polynomial. Devise a method to obtain
more significant figures for these constants.

y, spring 2004

y be necessary to first double-click on the graph.

Seek is at Data / What-If Analysis.)

You might also like