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.


722 posts

Ultimate Geek
+1 received by user: 263


Topic # 191123 24-Jan-2016 17:23
Send private message

Hi folks. The following formula has two frequently changing variables, the '84' and '75' values.

 

Does anyone know of a way I could automate a solution to this equation, so that I don't have to do the whole 9-yard calculation every time?

 


For example, '84' will probably soon become '81' and '75' will go to '76'.

 


Perhaps there's a small app that'll work it?

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


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

Uber Geek
+1 received by user: 310

Lifetime subscriber

  Reply # 1477855 24-Jan-2016 17:25
5 people support this post
Send private message

put it in an excel spreadsheet, with the values that change referencing cells that you edit

 

 


949 posts

Ultimate Geek
+1 received by user: 222

Trusted
Subscriber

  Reply # 1477856 24-Jan-2016 17:27
One person supports this post
Send private message

Can you not just use a spreadsheet? Put the variable values in cells and the calculation in the 3rd cell.




Procrastination eventually pays off.

82 posts

Master Geek
+1 received by user: 13

Subscriber

  Reply # 1477933 24-Jan-2016 21:03
Send private message

A good iOS app to do this is Calcility - Redefine Calculator (Lite) by JIAN FEI XU
https://appsto.re/nz/REKMM.i
It has a history section with folders and you can annotate the individual expression so you can quickly find and reuse the expression.
There is no need for all the brackets
(66.47 + 13.74 x 84 + 5 x 175 - 16.76 x 75) x 1.375 will give the same result.

1508 posts

Uber Geek
+1 received by user: 213


  Reply # 1477942 24-Jan-2016 21:32
Send private message

#Set our variables
$var1 = Read-Host "What is variable 1?"
$var2 = Read-Host "What is variable 2?"
#write the formula out to show the variables are correct
Write-Output "Formula = (66.47 + (13.75 * $var2) + (5 * 175 ) - (6.76 * $var1) * 1.375)"
#calculate answer into $ans variable
$ans = (66.47 + (13.75 * $var2) + (5 * 175 ) - (6.76 * $var1) * 1.375)
#Write the output of the $ans variable into the console.
Write-Output "The answer is $ans"

 

Save that a PowerShell script then when you need it, call it up with .Directory\scriptname.ps1.

 

You would need to have run set-executionpolicy remotesigned at some point, else it won't run the script.

 

Not really serious, just a fun exercise.

 

*Edit* Used tab complete to set case correctly in script





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

 

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


gzt

9819 posts

Uber Geek
+1 received by user: 1469


  Reply # 1477945 24-Jan-2016 21:54
Send private message

And that marks the first time I have seen a powershell script posted on geekzone. : ).


3282 posts

Uber Geek
+1 received by user: 208

Trusted

  Reply # 1477992 25-Jan-2016 02:28
One person supports this post
Send private message

Unless I misunderstand, your equation can be simplified to 18.90625 x [84] - 9.295 x [75] + 1294.52125 = 2185.52125

 

Just change the numbers in square brackets and you're all good. Relies on the distributive property of multiplication.




722 posts

Ultimate Geek
+1 received by user: 263


  Reply # 1478103 25-Jan-2016 10:55
Send private message

 Guys, thanks for your responses, but I'm still stuck here at the bakehouse, duh. (1953 School Cert Maths = 51%)

 

gregmcc and StarBlazer: I'm sure your suggestions were very sensible but I've never been able to get to grips with Excel. I do have it, so if some one could post an .xls (2003) file I'd give it a try. 

 

doug3: As far as I could see, I couldn't get the calculator without signing up for either Apple or Facebook, neither of which I'm interested in. But I think the app might be a little abstruse for me, anyway. Sorry :-(

 

toyonut: Like the calculator, scripting is kinda above my paygrade. Sorry :-(

 

bazzer: Thanks for the simplification (also doug3 for that). I wasn't aware an expression like that could be re-stated like that. If nothing else comes along (like a Cortana-ish robot for Windows 7 that asks me in a polite but seductive voice to state my variables), I'll use that method.

 

 


180 posts

Master Geek
+1 received by user: 26


  Reply # 1478119 25-Jan-2016 11:16
Send private message

gzt: And that marks the first time I have seen a powershell script posted on geekzone. : ).

 

Yay for PowerShell, powerful and versatile. Capable in its own right and with hooks into the dotnet libraries.

 

 


1551 posts

Uber Geek
+1 received by user: 310

Lifetime subscriber

  Reply # 1478177 25-Jan-2016 12:52
Send private message

 

 

 

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"


7664 posts

Uber Geek
+1 received by user: 2519

Subscriber

  Reply # 1478182 25-Jan-2016 12:57
Send private message

throw the formula into cell A1, substitute 84 for B1 and 75 for C1. throw 84 into cell B1 and throw 75 into cell C1. if you need to change it change the numbers in cells B1 and C1

 

 

 

Edit: pretty much what greg said except I went across


180 posts

Master Geek
+1 received by user: 26


  Reply # 1478218 25-Jan-2016 13:08
Send private message

 


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


118 posts

Master Geek
+1 received by user: 41


  Reply # 1478234 25-Jan-2016 13:34
Send private message

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.

 

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.

 

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?




722 posts

Ultimate Geek
+1 received by user: 263


  Reply # 1478346 25-Jan-2016 15:38
Send private message

Uh..does anyone know of a forum called DorkZone? 'Cos I think I should've posted my question there.

 

Think I'll just have a lie-down until my eyeballs stop spinning...

 

Oh, but thanks for all those erudite responses :-)


165 posts

Master Geek
+1 received by user: 48

Subscriber

  Reply # 1478384 25-Jan-2016 16:22
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.

 

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.

 

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?

 

 

If you can state if 2185.52125 or 1399.345 is the correct answer that you need, I have written a small app that gives the answer 1399.345


gzt

9819 posts

Uber Geek
+1 received by user: 1469


  Reply # 1478416 25-Jan-2016 16:39
Send private message

geekIT: Does anyone know of a way I could automate a solution to this equation, so that I don't have to do the whole 9-yard calculation every time?

Do you have a gmail account? This could be set easily by someone here as a form to input data from a web page.

 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 »

N4L helping TAKA Trust bridge the digital divide for Lower Hutt students
Posted 18-Jun-2018 13:08


Winners Announced for 2018 CIO Awards
Posted 18-Jun-2018 13:03


Logitech Rally sets new standard for USB-connected video conference cameras
Posted 18-Jun-2018 09:27


Russell Stanners steps down as Vodafone NZ CEO
Posted 12-Jun-2018 09:13


Intergen recognised as 2018 Microsoft Country Partner of the Year for New Zealand
Posted 12-Jun-2018 08:00


Finalists Announced For Microsoft NZ Partner Awards
Posted 6-Jun-2018 15:12


Vocus Group and Vodafone announce joint venture to accelerate fibre innovation
Posted 5-Jun-2018 10:52


Kogan.com to launch Kogan Mobile in New Zealand
Posted 4-Jun-2018 14:34


Enable doubles fibre broadband speeds for its most popular wholesale service in Christchurch
Posted 2-Jun-2018 20:07


All or Nothing: New Zealand All Blacks arrives on Amazon Prime Video
Posted 2-Jun-2018 16:21


Innovation Grant, High Tech Awards and new USA office for Kiwi tech company SwipedOn
Posted 1-Jun-2018 20:54


Commerce Commission warns Apple for misleading consumers about their rights
Posted 30-May-2018 13:15


IBM leads Call for Code to use cloud, data, AI, blockchain for natural disaster relief
Posted 25-May-2018 14:12


New FUJIFILM X-T100 aims to do better job than smartphones
Posted 24-May-2018 20:17


Stuff takes 100% ownership of Stuff Fibre
Posted 24-May-2018 19:41



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.