# Simple but long proof...

• Jun 1st 2012, 07:24 PM
cwigley
Simple but long proof...
All,

First off I hope this is the right forum, if not let me know and I will gladly move it.

I am a developer and have recently been given the equation and proof below to turn into code. I know it is a lot to ask but if someone could help me solve this step by step I can use this to program from. I have honestly spent hours and have yet been able to come up with the same answer. Any help is greatly appreciated!!

Attachment 24012

Variables:
SI=60, T=1, C1=1.1557, C2=1.0031, C3=-0.0408, AGET=76.4073801204541, C4=0.9807, C5=0.0314, CR=0.475, RHK=1, RHYXS=0.05, RHM=1.1, RHR=13, RHB=-1.6, RELHT=0.806719650456935, RHXS=0

Expected Result:
HG= 0.112113426675006
• Jun 2nd 2012, 12:35 AM
Wilmer
Re: Simple but long proof...
No idea what you mean by "turning into code"; or by "proof".

Noticed that the .75*RHK*? has a right bracket ")" missing.

What are you looking for? Ways to shorten? Ways to "keypunch it in"?
• Jun 2nd 2012, 10:21 AM
cwigley
Re: Simple but long proof...
I am actually just trying to verify that this equation does indeed solve to the expected result. My math is not strong enough for me to tell if there is a something wrong with how I am coding it, or if there is something wrong with the proof. I do see the missing closing bracket. I will follow up on that and verify its location. I really appreciate your help.
• Jun 2nd 2012, 10:59 AM
Wilmer
Re: Simple but long proof...
Also, the |_ _| brackets shown (beginning and end of equation) mean the "floor function"
(as example, if 3.746... then 3 is result), which makes no sense given your expected
results of HG= 0.112113426675006

I assume e = Euler number.

The "powers" are quite difficult to discern; can you show them in a clear way?

Other minor stuff is confusing, like why mutiply by T when T=1 ?!
• Jun 2nd 2012, 01:50 PM
cwigley
Re: Simple but long proof...
Very helpful heads up on the floor function. I had only considered it as a grouping function.

e is Euler number.

T is for a duration variable. The objective of this equation is to calculate the amount a tree has grown for a single cycle and the duration of the cycle is specified by T.
• Jun 2nd 2012, 02:25 PM
Wilmer
Re: Simple but long proof...
OK. You have RHSX = 0. Is that ok? Means RHSX^(1 - RHB) = 0.

Finally, on powers:
the right portion of 2nd line of equation shows e^[-RHR / (1 - RHB)] * (another expression) :
is the "other expression" part of the "power", or is it just a subsequent multiplication?

AND the missing half-bracket?!
• Jun 2nd 2012, 07:27 PM
cwigley
Re: Simple but long proof...
OK the flooring brackets are meant to be parenthesis.
The missing half bracket is supposed to include the rest of the line. .75*RHK*(...(1/1-RHM))
e^[-RHR / (1 - RHB)] * (another expression) - this is part of the power

You have been a tremendous help on this. I really appreciate it, I had no idea there were this many anomalies in this equation.
• Jun 3rd 2012, 08:06 PM
Wilmer
Re: Simple but long proof...
Quote:

Originally Posted by cwigley
T is for a duration variable. The objective of this equation is to calculate the amount a tree has grown for a single cycle and the duration of the cycle is specified by T.

HOKAY!! Now I see why parts of your equation are a bit like Future Value of money formulas...
The using of e^(.....) is obviously for continuous compounding.

Well, I entered your formula along with the values of the variables (I use UBasic programming)
but cannot come anywhere near .112113.... as solution: I get 0.006953....

You got that formula from "WHO"?

Again, I'll tell you that I don't understand what you mean by needing "help in coding".
Let's take something simple:
A = u + v + w^x
u=4, v=5, w=2, x=3
Much smaller/simpler than your problem, but works same way.
To "code" that in UBasic:

u=4, v=5, w=2, x=3
A = u + v + w^x
Print A
output: 17

If it helps, I renamed your variables this way:
u=C1=1.1557, v=C2=1.0031, w=C3=-0.0408, x=C4=0.9807, y=C5=0.0314, z=CR=0.475
p=SI=60, q=RELHT=0.806719650456935, r=AGET=76.4073801204541
f=RHB=-1.6, g=RHK=1, h=RHM=1.1, i=RHR=13, j=RHXS=0, k=RHYXS=0.05

So, as example, the left side of the 1st line of your formula becomes:
u * p^v * (1 - e^(w * (r - 1)))^(x * p^y)
• Jun 3rd 2012, 08:58 PM
cwigley
Re: Simple but long proof...
Man after many rounds with the provider of that #\$@! equation I finally got it worked out. I started off assuming the equation was right and my math was wrong. Turns out there were several errors in there that were a result of him not knowing how to specify his needs in an equation. Below is the working C# code that produces the desired result. You will notice a couple of bounding statements that weren't in the original equation!!

You have no idea how much you helped me man, truely appreciate it. I was losing my mind!

private double getHeightGrowth(){
double condition1 = (100*Math.Pow(CR, 3.0)*Math.Exp(-5.0*CR)) > 1.0 ? 0.99 : (100*Math.Pow(CR, 3.0)*Math.Exp(-5.0*CR));
double condition2 = (RHK)*Math.Pow((1.0+((Math.Pow((RHK/RHYXS), (RHM-1.0)))-1.0)*Math.Exp(((-1.0*RHR)/(1.0-RHB))*((Math.Pow(RelativeHeight, (1.0-RHB)))-(Math.Pow(RHXS, (1.0-RHB)))))),(1.0/(1.0-RHM))) > 1.0
? 0.99
: (RHK)*Math.Pow((1.0+((Math.Pow((RHK/RHYXS), (RHM-1.0)))-1.0)*Math.Exp(((-1.0*RHR)/(1.0-RHB))*((Math.Pow(RelativeHeight, (1.0-RHB)))-(Math.Pow(RHXS, (1.0-RHB)))))),(1.0/(1.0-RHM)));
double result = DurationOfCycle*
(((C1*(Math.Pow(SiteIndex, C2)))*Math.Pow((1.0-Math.Exp(C3*((AGET)+5.0))), (Math.Pow((C4*SiteIndex), C5))))-
((C1*(Math.Pow(SiteIndex, C2)))*Math.Pow((1.0-Math.Exp(C3*(AGET))), (Math.Pow((C4*SiteIndex), C5)))))*(0.25*condition1+0.75*condition2);

return result/5.0;
}
• Jun 4th 2012, 01:11 PM
Wilmer
Re: Simple but long proof...
Quote:

Originally Posted by cwigley
I was losing my mind!

(100*Math.Pow(CR, 3.0)*Math.Exp(-5.0*CR))

Happy fer you, buddy; glad to see you're not playing basketball for Jack Nicholson's team!

Why use that messy C# language...YUK!
Above would be in Basic: (100 * CR^3 * e^(-5*CR))
In case you forgot: exp(x) is same as e^x
• Jun 4th 2012, 03:36 PM
cwigley
Re: Simple but long proof...
In that messy C# stuff ^ is an XOr operator. I am happy to code in about anything, do it long enough its all semantics. C# was just part of the requirement :)