
Math General Math Forum  For general math related discussion and news 
 LinkBack  Thread Tools  Display Modes 
April 28th, 2018, 01:36 PM  #1 
Member Joined: Sep 2014 From: Sweden Posts: 80 Thanks: 0  How to describe a programming array mathematically?
Hi! This post is mostly out of curiosity. I have a program that you give a text file with hours and minutes you have worked. Like this: workedHours.txt 09.3014.00 09.3015.00 09.3014.00 08.3018.00 And the program automatically calculates the hours and minutes worked. It does that by putting the hours into one array and minutes into an array. So how do you describe these arrays mathematically? Here is a picture to make it clearer: http://www.mediafire.com/view/oue81l...428_232906.jpg Last edited by greg1313; April 28th, 2018 at 04:00 PM. 
May 3rd, 2018, 03:33 AM  #2 
Math Team Joined: Jan 2015 From: Alabama Posts: 3,244 Thanks: 887 
Does "09.3014.00" mean that a person worked form 9:30 am to 2:00 pm? That is 4 hours and 30 minutes. I "rounded" 9.30 up to 10.00 to get 14.00 10.00= 4 hours. Similarly "9.30 15.00" is 15 10= 5 hours and 30 minutes, "9.3014.00" is again 14 10= 4 hours and 30 minutes, and "8.30 18.00" is 18 9= 9 hours and 30 minutes. You array of hours will be "4, 5, 4, 9" and your array of minutes will be "30, 30, 30, 30". 
May 3rd, 2018, 04:38 AM  #3 
Global Moderator Joined: Dec 2006 Posts: 19,185 Thanks: 1648  Your arrays are lists of integers. Use a letter to name each list and, if necessary, another letter to specify the length of the lists. Your lists should be equally long (because for each number of hours there is an associated number of minutes), so one letter will suffice to specify their length. Your program may need to decide what to do if an odd number of times is found for some day. For example, this could be treated as an error in the data. This type of program typically calculates the totals in hours and minutes, so as to avoid the possibility of rounding errors. 
June 10th, 2018, 12:46 PM  #4  
Member Joined: Sep 2014 From: Sweden Posts: 80 Thanks: 0  Quote:
 
June 10th, 2018, 02:54 PM  #5 
Math Team Joined: Oct 2011 From: Ottawa Ontario, Canada Posts: 12,764 Thanks: 860  
June 10th, 2018, 03:24 PM  #6 
Senior Member Joined: Aug 2012 Posts: 1,958 Thanks: 547  Mathematically, an array is just a function from some set of natural numbers to some set. f(1) = 47, f(2) = 12, f(3) = 87.5, etc. It's just a list of elements. In some programming languages you can index arrays starting from arbitrary values like f(5). The main thing is that you have a finite index set and a mapping that associates some value to each index. Not very useful in practice, it's mostly useful to build up further abstractions.

June 11th, 2018, 01:17 AM  #7  
Senior Member Joined: Apr 2014 From: Glasgow Posts: 2,119 Thanks: 710 Math Focus: Physics, mathematical modelling, numerical and computational solutions  Quote:
Quote:
$\displaystyle \Delta m = 60h_2 + m_2  (60h_1 + m_1)$ If you want, you can divide the result by 60 and take the floor to get the number of hours worked and the remainder to get the left over minutes. Last edited by Benit13; June 11th, 2018 at 01:19 AM.  
June 11th, 2018, 08:50 AM  #8 
Global Moderator Joined: Dec 2006 Posts: 19,185 Thanks: 1648  

Tags 
array, describe, mathematically, programming 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Probability of one array containing all numbers of another array.  LordLoki  Probability and Statistics  2  May 12th, 2016 06:31 AM 
Question regarding python programming, specifically Object Oriented Programming  mitch08  Computer Science  2  November 28th, 2015 05:51 AM 
How to phrase a debt equation mathematically  philblakeman  Economics  0  October 20th, 2015 04:02 AM 
how to support this step mathematically  turtlejohn  Complex Analysis  0  January 20th, 2010 08:49 PM 
mathematically related essay topic  gaussrelatz  New Users  1  December 31st, 1969 04:00 PM 