newRPL: symbolic numbers

12232014, 05:22 PM
Post: #6




RE: newRPL: symbolic numbers
(12232014 12:06 PM)Nigel (UK) Wrote: Unless they are deliberately quoted they should stay approximate, even if they appear inside a quoted expression. Thinking about this a little deeper, perhaps it could be implemented the way you describe. Inside symbolics, numbers would have to be flagged as either exact or approximated, effectively moving from a global flag to a flag on each number. Following the idea that an approximated number "turns" an exact number into approximated this would be: '1' '1/2' + > '3/2' '1' 0.5 + > '1.5' (here 1.5 would be an approx. symbolic number) '3/2*X' 3 * > '4.5*X' (here 4.5 is approx) '3/2*X' '3' * > '9/2*X' The other approach would be the opposite: exact numbers turn approximated numbers into exact: 1 '1/2' + > '3/2' '1' 0.5 + > '3/2' '3/2*X' 3 * > '9/2*X' '3*X' 1.5 * > '9/2*X' I can't see any problem with either approach, perhaps a flag "prefer exact" or "prefer approx." could select between these two approaches, but we are back to a systemwide flag, not too different from "exact mode" in the 50g, except if you use only quoted numbers, or only unquoted numbers, the flag won't affect your results (only the mix would present problems). The main difference of doing this vs. the 50g would be that exact and approximated terms can coexist within the same expression: '3.5*X+7/2*Y' (where we'd have to indicate somehow when we type the expression that the 3.5 is approximated, otherwise it's exact even though is not an integer) Adding 'X' to the above expression, would be: '3.5*X+7/2*Y' 'X' + > '4.5*X+7/2*Y' (using prefer approx.) '3.5*X+7/2*Y' 'X' + > '9/2*X+7/2*Y' (using prefer exact) Notice the second term remains unaltered. The above example on the 50g triggers the "Approximate mode on?" question (after pressing EVAL). If accepted, it kills all fractions in the expression, if not accepted it errors and returns the original expression '3.5*X+7/2*Y+X'. One more problem with this: Typing a whole expression from the keyboard, we need to indicate somehow when a number is exact or not. Outside a symbolic we add quotes, but what to do when we are typing inside a symbolic? '3.5*X' typed would make 3.5 an exact number, so: '3.5*X' DUP * would return a fraction (49/4), as we would be multiplying two exact numbers. We'd also need a way to visually distinguish exact vs approx. numbers on screen (bold font?). 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)