Hi,

I am taking a c++ class for beginners. I have been assigned this project and am a little bit overwhelmed. I will be posting my code every so often as i go. Any help, hints or sugestions would be greatly appreciated.

Thanks

DESCRIPTION: A standard but complex problem in civil engineering and mechanics is to determine how tall a mast can be before it will begin to buckle under its own weight. You will write a program that finds the maximum lengths of masts made of different materials. The following quantities are defined:

L=mast length (meters)

Y=young’s modulus of the material (N/m2 )

=(density * cross sectional area) (kg/m)

I2=r4/2 r=radius of round mast (meters)

X=dimensional quantity related to above quantities by:

X=4 g L3 g=9.8m/sec2

9 YI2

THEORY: We need to find L in the above equation – L is the length of the mast. To find L, we must know all the other quantities. We know all the other quantities EXCEPT X. So, we need to find X, then we can find L. It has been found that the mast will just begin to buckle when X has the value corresponding to the smallest positive root of the function:

F(X)=X0 - .375X1 + .028125X2 - .0008789X3 + .000012X4

This function actually continues on but the additional terms are so small that we ignore them.

So, we need to find the root of this equation – that is the X value that makes F(X)=0. It is this X value that we will use in the first equation to find L.

DETAILS: This is what you need to do in your program:

1. Find the value of X:

a. Let X range from 0 to 5 in increments of .25 and calculate F(X).

b. In this range, you need to find the two X values where F(X) changes sign. These two X values give us our starting point for finding the X value we need. Once you find two F(X) values that change sign, you can stop calculating F(X).

c. Now, using the two X values from step b. above, we’ll find the final value of X. To do this, we’ll use the formula below over and over again to get a good value for X (this is called the secant routine for root finding). We’ll keep calculating Xi+1 until we’ve fixed four places to the right of the decimal point (initially, you’ll need to guess how many times you’ll need to calculate Xi+2 to set up your loop).

Xi+1 = Xi – F(Xi)(Xi-1-Xi) Xi-1 = one of the X values from step b above

F(Xi-1) – F(Xi) Xi = the other X value from step b above

Then, the next time you calculate:

Xi-1 will be the value that was Xi last time

Xi will be the Xi+1 value that you just calculated

and you will use these two values to calculate the next Xi+1

Then, the next time you calculate:

Xi-1 will be the value that was Xi last time (notice this is the first Xi+1 value you calculated)

Xi will be the Xi+1 value that you just calculated

and you will use these two values to calculate the next Xi+1

and so on, until when you compare, each Xi+1 value has the same 4 digits to the right of the decimal point.

Now, for your program, instead of comparing, do the loop 5 times, then output the last two X values, then ask the user if they want to continue finding X or move on to the rest of the program.

After 5 times, you should have the X value you need!

2. Finding the L value: now we can calculate the maximum mast length for any material. We will assume all masts have a radius of 0.100 meters. Here’s the pertinent information for different materials:

MATERIAL YOUNG’S MODULUS DENSITY

(N/m2) * 1010 (kg/m3) * 103

_____________________________________________________________

Aluminum (cast) 5.6 – 7.7 2.70

Brass 9.02 8.44

Gold 7.85 19.8

Iron (cast) 8.4-9.8 7.86

Lead 1.5-1.67 11.0

Platinum 16.7 21.4

Steel 20.0 7.83

Tin 3.9-5.39 7.29

Tungsten 35.5 18.8

Your program needs to calculate the maximum mast length for each of these materials. For materials that have a range for Young’s modulus, calculate the mast length for both the upper and lower end of the range.

OUTPUT: Your program needs to output the following:

a. the two X values where F(X) changes sign (from step 1, b above)

b. the final X value (from step 1, c above)

c. the name of each material and its corresponding maximum mast length(s). This should be in table/chart form.

I am taking a c++ class for beginners. I have been assigned this project and am a little bit overwhelmed. I will be posting my code every so often as i go. Any help, hints or sugestions would be greatly appreciated.

Thanks

DESCRIPTION: A standard but complex problem in civil engineering and mechanics is to determine how tall a mast can be before it will begin to buckle under its own weight. You will write a program that finds the maximum lengths of masts made of different materials. The following quantities are defined:

L=mast length (meters)

Y=young’s modulus of the material (N/m2 )

=(density * cross sectional area) (kg/m)

I2=r4/2 r=radius of round mast (meters)

X=dimensional quantity related to above quantities by:

X=4 g L3 g=9.8m/sec2

9 YI2

THEORY: We need to find L in the above equation – L is the length of the mast. To find L, we must know all the other quantities. We know all the other quantities EXCEPT X. So, we need to find X, then we can find L. It has been found that the mast will just begin to buckle when X has the value corresponding to the smallest positive root of the function:

F(X)=X0 - .375X1 + .028125X2 - .0008789X3 + .000012X4

This function actually continues on but the additional terms are so small that we ignore them.

So, we need to find the root of this equation – that is the X value that makes F(X)=0. It is this X value that we will use in the first equation to find L.

DETAILS: This is what you need to do in your program:

1. Find the value of X:

a. Let X range from 0 to 5 in increments of .25 and calculate F(X).

b. In this range, you need to find the two X values where F(X) changes sign. These two X values give us our starting point for finding the X value we need. Once you find two F(X) values that change sign, you can stop calculating F(X).

c. Now, using the two X values from step b. above, we’ll find the final value of X. To do this, we’ll use the formula below over and over again to get a good value for X (this is called the secant routine for root finding). We’ll keep calculating Xi+1 until we’ve fixed four places to the right of the decimal point (initially, you’ll need to guess how many times you’ll need to calculate Xi+2 to set up your loop).

Xi+1 = Xi – F(Xi)(Xi-1-Xi) Xi-1 = one of the X values from step b above

F(Xi-1) – F(Xi) Xi = the other X value from step b above

Then, the next time you calculate:

Xi-1 will be the value that was Xi last time

Xi will be the Xi+1 value that you just calculated

and you will use these two values to calculate the next Xi+1

Then, the next time you calculate:

Xi-1 will be the value that was Xi last time (notice this is the first Xi+1 value you calculated)

Xi will be the Xi+1 value that you just calculated

and you will use these two values to calculate the next Xi+1

and so on, until when you compare, each Xi+1 value has the same 4 digits to the right of the decimal point.

Now, for your program, instead of comparing, do the loop 5 times, then output the last two X values, then ask the user if they want to continue finding X or move on to the rest of the program.

After 5 times, you should have the X value you need!

2. Finding the L value: now we can calculate the maximum mast length for any material. We will assume all masts have a radius of 0.100 meters. Here’s the pertinent information for different materials:

MATERIAL YOUNG’S MODULUS DENSITY

(N/m2) * 1010 (kg/m3) * 103

_____________________________________________________________

Aluminum (cast) 5.6 – 7.7 2.70

Brass 9.02 8.44

Gold 7.85 19.8

Iron (cast) 8.4-9.8 7.86

Lead 1.5-1.67 11.0

Platinum 16.7 21.4

Steel 20.0 7.83

Tin 3.9-5.39 7.29

Tungsten 35.5 18.8

Your program needs to calculate the maximum mast length for each of these materials. For materials that have a range for Young’s modulus, calculate the mast length for both the upper and lower end of the range.

OUTPUT: Your program needs to output the following:

a. the two X values where F(X) changes sign (from step 1, b above)

b. the final X value (from step 1, c above)

c. the name of each material and its corresponding maximum mast length(s). This should be in table/chart form.

Last edited on

Topic archived. No new replies allowed.