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 
1795 posts

Uber Geek

Trusted
Lifetime subscriber

  #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

 

 

 

 


2416 posts

Uber Geek

Trusted
Subscriber

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

Someone throw it up into a google spreadsheet and share it


 
 
 
 




1196 posts

Uber Geek


  #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.

 

 

 

 





'Ask not what you can do for your country: ask what you can do for me'. Donald J.Trump. US President 2016 - 2020.

 

 

 

 


118 posts

Master Geek


  #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.


118 posts

Master Geek


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


118 posts

Master Geek


  #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


 
 
 
 


267 posts

Ultimate Geek


  #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.


1508 posts

Uber Geek


  #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


253 posts

Ultimate Geek


  #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





Obsequious hypocrite

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 and LinkedIn »



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 »

Menulog change colours as parent company merges with Dutch food delivery service
Posted 2-Jul-2020 07:53


Techweek2020 goes digital to make it easier for Kiwis to connect and learn
Posted 2-Jul-2020 07:48


Catalyst Cloud launches new Solutions Hub to support their kiwi Partners and Customers
Posted 2-Jul-2020 07:44


Microsoft to help New Zealand job seekers acquire new digital skills needed for the COVID-19 economy
Posted 2-Jul-2020 07:41


Hewlett Packard Enterprise introduces new HPE GreenLake cloud services
Posted 24-Jun-2020 08:07


New cloud data protection services from Hewlett Packard Enterprise
Posted 24-Jun-2020 07:58


Hewlett Packard Enterprise unveils HPE Ezmeral, new software portfolio and brand
Posted 24-Jun-2020 07:10


Apple reveals new developer technologies to foster the next generation of apps
Posted 23-Jun-2020 15:30


Poly introduces solutions for Microsoft Teams Rooms
Posted 23-Jun-2020 15:14


Lenovo launches new ThinkPad P Series mobile workstations
Posted 23-Jun-2020 09:17


Lenovo brings Linux certification to ThinkPad and ThinkStation Workstation portfolio
Posted 23-Jun-2020 08:56


Apple introduces new features for iPhone iOS14 and iPadOS 14
Posted 23-Jun-2020 08:28


Apple announces Mac transition to Apple silicon
Posted 23-Jun-2020 08:18


OPPO A72 a top mid-tier smartphone
Posted 19-Jun-2020 18:02


D-Link A/NZ launches new smart AX1500 Wi-Fi 6 Router
Posted 19-Jun-2020 15:03



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.

Support Geezone on PressPatron



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.