Prev: List Manipulation: Conditionally changing y value
Next: Surprising behaviour with nested pure functions and
From: John Ertle Jr. on 10 Apr 2010 06:55 In[1]:= J = 367*y + Floor (7*(y + Floor ((m + 9)/12))/4) + Floor (275*m/9) + da + 1721013.5 Out[1]:= 2.44254*10^6 + (2200 Floor)/9 + 7/4 Floor (1966 + (17 Floor)/12) How do you get Mathematica to evaluate "Floor" to give a number?
From: David Park on 11 Apr 2010 04:29 First, it would be helpful to know what y, m and da are. Secondly, do you mean the Mathematica Floor function? Then it should be written with square brackets with the argument inside, Floor[argument]. So, do you mean?: 2.44254*10^6 + 2200 Floor[1/9] + 7/4 Floor[1966 + 17 Floor[1/12]] 2.44598*10^6 You might, perhaps, go over some of the CORE LANGUAGE sections in Help: Language Overview, Expressions, Syntax, Rules & Patterns, Functional Programming. David Park djmpark(a)comcast.net http://home.comcast.net/~djmpark/ From: John Ertle Jr. [mailto:ertlejack(a)sbcglobal.net] In[1]:= J = 367*y + Floor (7*(y + Floor ((m + 9)/12))/4) + Floor (275*m/9) + da + 1721013.5 Out[1]:= 2.44254*10^6 + (2200 Floor)/9 + 7/4 Floor (1966 + (17 Floor)/12) How do you get Mathematica to evaluate "Floor" to give a number?
From: Bill Rowe on 11 Apr 2010 04:30 On 4/10/10 at 6:55 AM, ertlejack(a)sbcglobal.net (John Ertle Jr.) wrote: >In[1]:= J = 367*y + Floor (7*(y + Floor ((m + 9)/12))/4) + Floor >(275*m/9) + da + 1721013.5 >Out[1]:= 2.44254*10^6 + (2200 Floor)/9 + 7/4 Floor (1966 + (17 >Floor)/12) >How do you get Mathematica to evaluate "Floor" to give a number? How about reading the documentation? A fundamental aspect of using Mathematica is to understand the difference between square brackets "[","]" and parenthesis "(",")". You will find it very difficult to get useful results with Mathematica until you understand this very fundamental difference.
From: David Bailey on 12 Apr 2010 06:48
John Ertle Jr. wrote: > In[1]:= J = 367*y + Floor (7*(y + Floor ((m + 9)/12))/4) + Floor (275*m/9) + > da + 1721013.5 > > Out[1]:= 2.44254*10^6 + (2200 Floor)/9 + 7/4 Floor (1966 + (17 Floor)/12) > > How do you get Mathematica to evaluate "Floor" to give a number? > Every Mathematica function - including Floor - uses square brackets to denote the argument list. This is because ordinary algebraic notation is ambiguous: f(a+b) can mean f*a + f*b, or it can refer to the function f. Clearly this ambiguity must be resolved for computer algebra, and in Mathematica, the above expression would mean f*a+f*b, and to refer to a function f, one must write f[a+b]. If you write your expressions that way, AND provide values for the various variables in your expression, you will get a numeric answer. If I have difficulty with a built in function - such as Floor - my first approach is to click on the name of the function, and press F1 to get the help for that function. This will give you examples of actual use, that you can paste into your notebook and change progressively into whatever you require. David Bailey http://www.dbaileyconsultancy.co.uk |