Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.

 Prev 1 | 2

## gregmcc

1716 posts

Uber Geek

Trusted

# 1478445 25-Jan-2016 17:09

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

## insane

2396 posts

Uber Geek

Trusted
Subscriber

# 1478447 25-Jan-2016 17:13

## geekIT

1068 posts

Uber Geek

# 1478454 25-Jan-2016 17:44

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.

Any fool can make money, but it takes a very special person to earn the respect of respectable people.

## Ouranos

118 posts

Master Geek

# 1478460 25-Jan-2016 18:01

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.

## gregmcc

1716 posts

Uber Geek

Trusted

# 1478480 25-Jan-2016 18:14
One person supports this post

## Ouranos

118 posts

Master Geek

# 1478488 25-Jan-2016 18:25

gregmcc:

try this on for size

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".)

## Ouranos

118 posts

Master Geek

# 1478491 25-Jan-2016 18:33

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

## Ruphus

216 posts

Master Geek

# 1479516 27-Jan-2016 01:27

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.

## toyonut

1508 posts

Uber Geek

# 1479598 27-Jan-2016 08:57

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

## ObidiahSlope

235 posts

Master Geek

# 1479746 27-Jan-2016 11:46

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

Obsequious hypocrite

 Prev 1 | 2

News »

Arlo unveils its first video doorbell
Posted 21-Oct-2019 08:27

New Zealand students shortlisted for James Dyson Award
Posted 21-Oct-2019 08:18

Norton LifeLock Launches Norton 360
Posted 21-Oct-2019 08:11

Microsoft New Zealand Partner Awards results
Posted 18-Oct-2019 10:18

Posted 16-Oct-2019 13:36

MATTR launches to accelerate decentralised identity
Posted 16-Oct-2019 10:28

Vodafone X-Squad powers up for customers
Posted 16-Oct-2019 08:15

D Link ANZ launches EXO Smart Mesh Wi Fi Routers with McAfee protection
Posted 15-Oct-2019 11:31

Major Japanese retailer partners with smart New Zealand technology IMAGR
Posted 14-Oct-2019 10:29

Ola pioneers one-time passcode feature to fight rideshare fraud
Posted 14-Oct-2019 10:24

Spark Sport new home of NZC matches from 2020
Posted 10-Oct-2019 09:59

Meet Nola, Noel Leeming's new digital employee
Posted 4-Oct-2019 08:07

Registrations for Sprout Accelerator open for 2020 season
Posted 4-Oct-2019 08:02

Teletrac Navman welcomes AI tech leader Jens Meggers as new President
Posted 4-Oct-2019 07:41

Vodafone makes voice of 4G (VoLTE) official
Posted 4-Oct-2019 07:36

Geekzone Live »

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

Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.