freenode/#lisp - IRC Chatlog
Search
18:12:14
jasom
does the lisp standard define what combinations 2-ary multiplies (* A B C D) is equal to, or is any algebraically equivalent calculation valid?
18:14:32
pjb
jasom: the arguments are evaluated from left to right, but the standard doesn't impose an order of association or commutation for the evaluation of the operation per se.
18:15:04
jasom
pjb: that's what I thought; so there is no guarantee e.g. that (= (* A B C D) (* (* (* A B) C) D))
18:15:11
pjb
jasom: so an implementation could do (* (* (* a b) c) d) or (* a (* b (* c d))) or (* (* a d) (* b c)) or anything else.
18:16:01
jasom
at least with log-scaled numbers addition and subtraction are so difficult that you avoid it.
18:16:47
pjb
eg. write (let ((a 42) (b 3.4) (c 5.6) (d 33/2)) (* (* a d) (* b c))) #| --> 13194.721 |#
18:17:20
jasom
interestingly enough, without the IEEE addendum, C permits algebraic rewriting of floating point operations (though most compilers with FP support implement the IEEE addendum).
18:18:08
pjb
That said, I don't know any implementation doing much reordering or sorting the arguments by type. Usually they'll just left associate.
18:18:37
jasom
The nice thing is that good support of ratios allows me to treat FP as an optimization rather than the easiest way to perform fractional calculations.
18:19:18
jasom
hmm, looking in scrollback, devon might be interested in computable-reals which has an arbitrary precision pi.
18:19:51
pjb
Indeed. (let ((a 42) (b 34/10) (c 56/10) (d 33/2)) (* (* a d) (* b c))) #| --> 329868/25 |# (float 329868/25 0.0d0) #| --> 13194.72D0 |#
18:24:55
specbot
Examples of Associativity and Commutativity in Numeric Operations: http://www.lispworks.com/reference/HyperSpec/Body/12_aaaa.htm
18:26:46
jasom
but optimizing across function-call boundaries when the results would differ is disallowed
18:39:15
aeth
pjb, jasom: There is sort of a guarantee... that a quality floating point implementation won't mess with floating point order. I see no reason to use ratios instead of floating point. If an implementation chooses to mess with floating point algorithms, that's on them.
18:40:24
aeth
Bike, jasom: I don't think SBCL does mess with constant for floating point. I remember seeing that they didn't even optimize away multiplication by 0.0f0 in their generated assembly.
18:41:41
aeth
jasom: yes, that's probably why, you can disable floating point traps in most implementations to get the underlying IEEE float with the NANs and INFs
18:41:54
jasom
aeth: the biggest problem with floting point is addition/subtraction are dangerous. That's why I use ratios by default.
18:42:59
aeth
jasom: floating point has many issues, I'd restrict its use in general to implementing known numerical algorithms that other people came up with, if you care about accuracy.
18:44:34
jasom
White_Flame: multiplicative operations will lose at most 1ULP of accuracy, additive operations can leave you with complete garbage.
18:45:27
jasom
White_Flame: e.g. there are multiple FP implementations for the quadradic equation depending on the signedess of the b, 4ac parts.
18:47:16
jasom
sorry, the disciminant (and B, depending on your thoughts of having the sgn function in your equation).
18:48:00
jasom
It's the most well known function that involves catastrophic loss of precision, so it's the canonical example.
18:48:23
jasom
The pythagorean theorum can show some oddities when you are far from the origin as well, which is yet another argument for not using floats for coordinates.
18:49:11
White_Flame
yeah, and I've done some 3d graphics stuff far away from the origin which starts aliasing badly as well
18:49:25
jasom
There are approximately zero cases in which it makes more sense to use a double float than a 64-bit integer for a coordinate system. (doubles made some sense when it was faster to add 2 doubles than 2 64-bit integers).
18:51:14
aeth
If you want performance over accuracy and it's for a game and you're going to be converting to float dozens of times a second...
18:51:41
White_Flame
also, you'll be dealing with fixed point multiplication & reducing from 128-bit results
18:52:29
aeth
jasom: the thing is, in games you want performance, not precision, and in scientific calculations, you can just use a fancier algorithm to get your error small enough since it's inexact anyway
18:53:22
Bike
i think most scientists' engagement with numeric algorithms is ignoring matlab warnings that a matrix is near singular
18:53:32
aeth
(and many of the issues with float are the issues with not using hardware decimal float, which is the fault of hardware makers, not float)
18:54:48
jasom
Bike: more seriously the field is split between those super familiar with the limitations of the computational hardware, and the rest of the field, where the best you can hope is that they use libraries written by the former.
18:54:50
aeth
Bike: well, most of this thought should be moved to a library and not thought about at each use, e.g. a CL implementation of BLAS
18:55:24
Bike
i mean, i've generally been impressed by matlab's treatment. documentation with citations is pretty nice
21:06:27
jasom
Hmm, CLISP's long-float pi value is off by more than one ULP for very large precision values
21:35:33
pjb
Bike: it's different in physics. For example, you will find that the circumference of the Earth is not 2πr, but it's smaller. Because of relativity.
21:57:45
no-defun-allowed
I try to program about 12 hours a week, but I'd say I'm only productive for 4 to 6 hours.
22:00:41
clothespin
are you able to get something good done when you only have an hour or so before you have to go somewhere?
22:02:08
jasom
clothespin: also, keep notes *somewhere* about what needs to be done next before you leave; that means stopping work 5 minutes earlier than you would otherwise, but if it saves you an hour of time to zone-in on the otherside, it's easily worth it.
22:02:30
Oladon_work
It's a fallacy that you have to be "zoned in" in order to be productive — to maximize productivity, perhaps, but if you've scoped out the project (or part of the project) well and appropriately, you can pick up one piece much more easily.
22:03:23
jasom
clothespin: I'm more thinking a brain-dump; I tried X, Y, and Z, they didn't work because Q, so I'm going to change directions and investigate W next.
22:03:42
jasom
enough touchstones to get your brain back to where it was the last time you were working.
22:06:45
jasom
That's partly practice, and partly self-introspection. You will get better at getting in the flow with practice, but you'll also want to analyze why can't you do so without (for example) checking your e-mail?
22:08:45
jasom
IMO that's partly due to them having poor time management skills ;) but also some types of coding are more routine than others. I can speed up a poorly performing program with my brain half-off, and similar for porting code. For debugging something (particularly something hard to reproduce), I need maximum focus.
22:09:37
clothespin
yes, i agree. when i was running test scripts ob builds i could hack for 5 minutes
22:10:16
clothespin
now that i'm doing more architecture and i want elegant solutions i have to slow down
22:11:17
pjb
clothespin: https://www.amazon.fr/Coders-Work-Reflections-Craft-Programming/dp/1430219483/ref=sr_1_1?__mk_fr_FR=ÅMÅŽÕÑ&keywords=coders+at+work&qid=1569363071&s=gateway&sr=8-1
22:12:59
jasom
clothespin: for that, it can help to invert things a bit; collect problems and whenever you learn a new elegant solution, try each problem against it.
22:16:45
clothespin
jasom: what do you mean exactly? I code crap until i see the elegant solution, then i rewrite until the crap goes away and repeat
22:19:51
clothespin
I literally dreamed of a solution to avoid extra destinations for coordinates in generating vertex buffers
22:32:40
clothespin
well thanks for making me feel normal peeps, those guys with the macbooks on the train had me worried i was a less productive hacker
22:35:17
clothespin
I think Andreas Fuchs and Carl Shapiro doe that too but those guys are just exceptional
4:40:48
beach
Wow, the Wikipedia article on CMS is so general that it could work as a description of a text editor too.
4:42:56
p_l
the way my (primitive so far) blog works would be very well a representative of "headless" CMS (I use Emacs + org-mode + custom lisp code to output data that is then compiled into HTML)
4:43:56
no-defun-allowed
The first thing I think of is Coleslaw <https://github.com/coleslaw-org/coleslaw>