Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic
1 | 2 
1476 posts

Uber Geek
+1 received by user: 278

Subscriber

  Reply # 1478445 25-Jan-2016 17:09
Send private message

Ouranos:

 

gregmcc: 1st Variable number 84 2nd Variable number 75 Answer

 

1399.345

 

=SUM(66.47+(13.75*A2)+(5*175)-(6.76*A4)*1.375)

 

This is the formula that goes in the box below "Answer"

 

 

That spreadsheet formula has two, or possibly three, errors:

 

1. The SUM function is unnecessary. Effectively it says =SUM(x) which is just x. I see many people do this and I don't understood why.

 

 

 

 

has no effect on the outcome so it's not an error

 

 

 

 

2. A formula should never contain hard-coded "magic numbers". For example, what does 66.47 mean? Put each of the numbers in a cell and refer to them. Then document what each of the numbers means, where it comes from, etc.

 

 

 again it makes no difference what these "magic" numbers are, they are fixed constants, it's only the 84 and 75 that change, so not an error either

 

 

 

 

 

 

3. The OP stated the equation as "[66.47 + (13.75 x 84) + (5 x 175 ) - (6.76 x 75] x 1.375" which has mismatched parentheses. Looking at the square brackets, I assume it is intended that the whole thing is multiplied by 1.375. If so, then =SUM(66.47+(13.75*A2)+(5*175)-(6.76*A4)*1.375) is wrong (as is the PowerShell script posted earlier). That is, does the original equation equal 2185.52125 or 1399.345?

 

 

maybe an error, but we will never know as the OP has given the equation without any explanation as to what it is calculating, what the fixed values are and what the variable value are.

 

 

 

Maybe the OP could enlighten us with more details and we can then determine where the brackets belong

 

 

 

 


2242 posts

Uber Geek
+1 received by user: 353

Trusted
Subscriber

  Reply # 1478447 25-Jan-2016 17:13
Send private message

Someone throw it up into a google spreadsheet and share it


 
 
 
 




568 posts

Ultimate Geek
+1 received by user: 103


  Reply # 1478454 25-Jan-2016 17:44
Send private message

Sorry guys, I thought I should keep my question short for the sake of clarity.

 

The equation comes from a CSIRO book on Diet, Exercise and Health.

The purpose of the equation is to establish a man's daily maintenance calories, ie, the intake required to keep one's weight static.
(Obviously, any lesser calorie intake should result in weight loss.)

 

[66.47 + (13.75 x 84*) + (5 x 175* ) - (6.76 x 75*] x 1.375* =

 

The variables are:

 

84* - current weight in kilos. As one loses weight, this figure will reduce.

 

175* - height in cms. Shouldn't change radically unless one has an unfortunate encounter with a guillotine.

 

75* - age. This will advance, of course.

 

1.375* - this variable is a qualifier that represents one's level of activity. In this case, sedentary or light activity. This would probably remain static, especially with older people.

 

The women's equation is as follows:

 

[65.1 + (9.56 x 63*) + (1.85 x 155*) - (4.68 x 53*)] x 1.2* =

 

Again, the variables are:

 

63* - weight in kilos
155* - height in cm
53* - age
1.2* - same as the male version - sedentary or light daytime activity.

PS: My round-figure calculations for the above yielded 2186 cals for the man and 1555 cals for the woman.

 

 

 

 


114 posts

Master Geek
+1 received by user: 39


  Reply # 1478460 25-Jan-2016 18:01
Send private message

geekIT:

 

The purpose of the equation is to establish a man's daily maintenance calories, ie, the intake required to keep one's weight static.

 

 

There are many online calculators for that. A random search finds, for example:

 

http://www.weightloss.com.au/weight-loss/weight-loss-tools/energy-needs-calculator.html

 

http://www.freedieting.com/tools/calorie_calculator.htm

 

gregmcc:

 

has no effect on the outcome so it's not an error

 

 

OK, strictly speaking they are "latent faults". "Errors" for short.


1476 posts

Uber Geek
+1 received by user: 278

Subscriber

  Reply # 1478480 25-Jan-2016 18:14
One person supports this post
Send private message
114 posts

Master Geek
+1 received by user: 39


  Reply # 1478488 25-Jan-2016 18:25
Send private message

gregmcc:

 

try this on for size

 

https://docs.google.com/spreadsheets/d/1NA6oOGAjSmlwETxEo-7YmdOCAaltMkUp9_r_RTSu4ag/edit?usp=sharing

 

 

The equation coefficients for male and female need to be different. Therefore, your Google spreadsheet is wrong.

 

(That's why a formula should never have embedded "magic numbers".)


114 posts

Master Geek
+1 received by user: 39


  Reply # 1478491 25-Jan-2016 18:33
Send private message

By the way, what we're taking about here is called the Harris–Benedict equation:

 

https://en.wikipedia.org/wiki/Harris%E2%80%93Benedict_equation

 

It was devised almost 100 years ago and has been revised several times since:

 

https://en.wikipedia.org/wiki/Basal_metabolic_rate


154 posts

Master Geek
+1 received by user: 28


  Reply # 1479516 27-Jan-2016 01:27
Send private message

ObidiahSlope:

 

 


Write-Output "Formula = (66.47 + (13.75 * $var2) + (5 * 175 ) - (6.76 * $var1) * 1.375)"

 

 

 

 

I have reworked the line above using Write-Host and its -NoNewline and -ForegroundColor arguments together with the semicolon command seperator to highlight the variable values.

 

Write-Host -NoNewline "Formula = (66.47 + (13.75 * "; Write-Host -NoNewline -ForegroundColor yellow "$var2"; Write-Host -NoNewline ") + (5 * 175 ) - (6.76 * "; Write-Host -NoNewline -ForegroundColor yellow "$var1"; Write-Host ") * 1.375)"

 

 

 

 

This....

 

http://powershell.com/cs/blogs/donjones/archive/2012/03/06/2012-scripting-games-commentary-stop-using-write-host.aspx

 

 

 

And this...

 

http://www.jsnover.com/blog/2013/12/07/write-host-considered-harmful/

 

 

 

Save the puppies.


1507 posts

Uber Geek
+1 received by user: 213


  Reply # 1479598 27-Jan-2016 08:57
Send private message

Ruphus:

 

ObidiahSlope:

 

 


Write-Output "Formula = (66.47 + (13.75 * $var2) + (5 * 175 ) - (6.76 * $var1) * 1.375)"

 

 

 

 

I have reworked the line above using Write-Host and its -NoNewline and -ForegroundColor arguments together with the semicolon command seperator to highlight the variable values.

 

Write-Host -NoNewline "Formula = (66.47 + (13.75 * "; Write-Host -NoNewline -ForegroundColor yellow "$var2"; Write-Host -NoNewline ") + (5 * 175 ) - (6.76 * "; Write-Host -NoNewline -ForegroundColor yellow "$var1"; Write-Host ") * 1.375)"

 

 

 

 

This....

 

http://powershell.com/cs/blogs/donjones/archive/2012/03/06/2012-scripting-games-commentary-stop-using-write-host.aspx

 

 

 

And this...

 

http://www.jsnover.com/blog/2013/12/07/write-host-considered-harmful/

 

 

 

Save the puppies.

 

 

 

 

Although this is now far out of the scope of the OP, The script output is not going into a pipeline so write-host with colored tags is a nice and viable way to make the output more readable. I had not seen write-verbose before though, I am going to start using that from now on.





Try Vultr using this link and get us both some credit:

 

http://www.vultr.com/?ref=7033587-3B


159 posts

Master Geek
+1 received by user: 19


  Reply # 1479746 27-Jan-2016 11:46
Send private message

Ruphus:

 

Save the puppies.

 

 

 

 

A similar slaughter of innocent puppies takes place in the *nix world;

 

 

 

http://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo


1 | 2 
Filter this topic showing only the reply marked as answer View this topic in a long page with up to 500 replies per page Create new topic



Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

New Zealand hits peak broadband data
Posted 18-Jan-2018 12:21


Amazon Echo devices coming to New Zealand early February 2018
Posted 18-Jan-2018 10:53


$3.74 million for new electric vehicles in New Zealand
Posted 17-Jan-2018 11:27


Nova 2i: Value, not excitement from Huawei
Posted 17-Jan-2018 09:02


Less news in Facebook News Feed revamp
Posted 15-Jan-2018 13:15


Australian Government contract awarded to Datacom Connect
Posted 11-Jan-2018 08:37


Why New Zealand needs a chief technology officer
Posted 6-Jan-2018 13:59


Amazon release Silk Browser and Firefox for Fire TV
Posted 21-Dec-2017 13:42


New Chief Technology Officer role created
Posted 19-Dec-2017 22:18


All I want for Christmas is a new EV
Posted 19-Dec-2017 19:54


How clever is this: AI will create 2.3 million jobs by 2020
Posted 19-Dec-2017 19:52


NOW to deploy SD-WAN to regional councils
Posted 19-Dec-2017 19:46


Mobile market competition issues ComCom should watch
Posted 18-Dec-2017 10:52


New Zealand government to create digital advisory group
Posted 16-Dec-2017 08:47


Australia datum changes means whole country moving 1.8 metres north-east
Posted 16-Dec-2017 08:39



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.