Checking function

Hi,
I am currently writing a function to determine surface soil temperature (SST) defined as : T(t) = Tave + Asin[(w(t-t0)). w is a constant equal to 2π/24. t0 is qual to 8. To check that my function works, I have to plug in t = 7, Tave = 28, A = 5 to get 32.896. However, when I input my code (se below), I get 28.25104. I am suspecting that my t value is not correct since it is equal to the time since something occurred. I figured that would translate to the absolute value, but now I'm not sure.

t <- sum(t + 6)
Tave <- mean(t)
A <- (1/2) * (t)

SST = function(t = sum(t + 6), Tave = mean(t + 6), A = (0.5(t-8))) {
Tave + ((sin(A)) * ((6.283/24) * (t - 8)))
}

SST(t = 7, Tave = 28, A = 5)

I am a bit confused by discrepancies between the text in your post and your code. I will start with the observation that I can get a number very close to your desired answer with this code.

5*sin(6.283/24*(7 + 6 - 8)) + 28

That returns 32.82958. You say you expect 32.896. Is it really 32.8296? My calculation is a translation of

A * sin(w(t + 6 - t0) + Tave

with the values A = 5, w = 2π/24, t = 7, t0 = 8, Tave = 28.
You do not mention adding 6 to t in your text but you do it in your code. Is it what you intend?
Please confirm whether Tave is supposed to be the average of t or an average of T(t). Those are different things.
Is A a constant or is it 0.5 * t?

1 Like

Hi,
The t+6 indicates the time since 6am when lizard eggs were laid into soil. That was my intention to express it. Tave is the average daily temperature (T). My question is based off of an assignment for class where we ultimately run a simulation of this function and three others to produce a heatmap of our results.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Also forgot to add that A is equal 1/2 of t