# Finding the temperature at the end of the interval but can't seem to get the answer?

• October 30th, 2013, 10:47 PM
dritail
Finding the temperature at the end of the interval but can't seem to get the answer?
I've been trying to get the numbers for hours now but i can seem to get it right. Here's the problem below:

During the initial period, when the heater is not yet functioning at peak efficiency the heating will increase the temperature inside the building at a rate given by the following equations. During the initial period when the air conditioner is not yet functioning at peak efficacy the air conditioner will decrease the temperature inside the building at a rate given by the same equations.

Interval = (Time since turning on / 2.0 ) - 3.0
Factor multiplying Temperature change per minute = exp( Interval) / ( 1 + exp(Interval) )
These equations can also be used after the heating or air conditioner reaches peak efficiency. These equations converge to 1, so after the heating or air conditioner reach peak efficiency these equations will always give a value of 1.
NOTE: the value of these equations needs to be multiplied by the RATE TEMPERATURE CHANGES. The RATE TEMPERATURE CHANGES is EITHER the change in temperature inside the building in degrees Celsius per minute caused by heat being extracted by the air conditioning OR the change in temperature inside the building in degrees Celsius per minute caused by the heat being generated by the heating .Temperature change in degrees per minute = Factor multiplying Temperature change per minute * RATE TEMPERATURE CHANGES

Temperature at end of this interval = Temperature at the start of the interval + temperature change due to heat escaping during the this interval + temperature change due to heat generated by the heating system during this interval + temperature change due to heat removed by the cooling system during this interval

i have a:
...rate of -.05 for heat escape w/o cooling or heating
...rate of 0.10 for heat escape w/ cooling
...rate of 0.125 for heat increase w/ heating
...Starting temp=38.00
...Time interval 3.50

i can't seem to find the temp at the ending interval?

What i tried doing:

Code:

```#include<iostream> #include<cmath> using namespace std; int main () {         double intervals=0.00;                 double tempPerMin=0.00;         double tempAtEnd=0.00;         double naturalChange=0.00;                 double coolChange=0.00;                 double heatChange=0.00;                 intervals=(0.0/2.0)-3.0;         tempPerMin=(exp(intervals))/(1+exp(intervals));         naturalChange=(-0.05)*tempPerMin*3.5;         coolChange=(0.1)*(tempPerMin)*3.5;         heatChange=(0.125)*(tempPerMin)*3.5;                 tempAtEnd=38.00-coolChange+naturalChange-heatChange;         cout<<tempAtEnd;     return 0; }```
the temperature at the end of the interval is suppose to be 37.81 but i can't get the answer. I'm pretty sure this is a logical error from the equations i used but i can't seem to find it. Any hints?
• October 31st, 2013, 04:53 AM
2kaud
Re: Finding the temperature at the end of the interval but can't seem to get the answ
Code:

`ntervals=(0.0/2.0)-3.0;`
0.0 divided by anything except a 0 will always give 0! So intervals is -3 which I don't think is what you want.

How would you do this without writing a program just using pen and paper? When you have the working algorithm then produce a program design and then code the program and then debug the program againt the algorithm/design.
• October 31st, 2013, 11:13 AM
dritail
Re: Finding the temperature at the end of the interval but can't seem to get the answ
well the question gives me the following equations...

Temperature at end of this interval = Temperature at the start of the interval + temperature change due to heat escaping during the this interval + temperature change due to heat generated by the heating system during this interval + temperature change due to heat removed by the cooling system during this interval

Interval = (Time since turning on / 2.0 ) - 3.0

Factor multiplying Temperature change per minute = exp( Interval) / ( 1 + exp(Interval) )

Then i put in the numbers...

Interval = (3.5 / 2.0 ) - 3.0

Temperature change from heat escape w/o cooling or heating = exp( Interval) / ( 1 + exp(Interval) ) *(-0.05)*(3.5)
Temperature change from heat escape w cooling = exp( Interval) / ( 1 + exp(Interval) ) *(0.1)*(3.5)

Ending temp=38.00+ temperature change due to heat escaping during the this interval + temperature change due to heat removed by the cooling system during this interval

i didn't include the heat generated by the heater since it was off.
Can you see what i did wrong?

i have a test case that they provided me.

Code:

```Interval Starting  Ending  Starting      Ending           Time      Time  Temperature Temperature Heating  Cooling The cooling was turned on after 0.00 minutes.       1    0.00    3.50    38.00      37.81      Off      On```
• October 31st, 2013, 12:42 PM
Paul McKenzie
Re: Finding the temperature at the end of the interval but can't seem to get the answ
Quote:

Originally Posted by dritail
the temperature at the end of the interval is suppose to be 37.81 but i can't get the answer. I'm pretty sure this is a logical error from the equations i used but i can't seem to find it. Any hints?

Learn to use the debugger to step through your program to see which one of those calculations winds up with the wrong results.

Your program is just a few lines long. Here is the opportunity to learn how to debug programs using the Visual Studio Debugger. Look at the main menu in VS, and you see a "Debug" option.

Regards,

Paul McKenzie