« first day (2203 days earlier)      last day (2761 days later) » 

2:02 PM
Hey @AndrasDeak Here's a simple Numpy question, if you're interested. stackoverflow.com/questions/40286180/…
 
The story of Bronzemurder is a very nicely illustrated example of the kind of shenanigans you can get up to in the game if you know what you're doing (unlike me)
 
Partly inspired by a SE.Mathematics question, this afternoon I came up with a slightly odd way to compute pi using tan(x) ~= x for small x, and the identity tan(2x) = 2tan(x)/(1-tan²(x)). Here's a quick implementation.
n = 30
d = 2 ** -32
x = 3
while True:
    y = d * x
    for i in range(n):
        y = 2 * y / (1 - y * y)
    dx = 4 * (1 - y) / (1 + y * y)
    x += dx
    print(x, dx)
    if abs(dx) < 1E-15:
        break
 
Neat.
 
Thanks. It converges fairly quickly, but (of course) it's slower than the Salamin / Brent / Gauss Arithmetic-Geometric Mean formula. OTOH, it doesn't use square root.
 
All methods of approximating pi are fairly magical to me... I tried to do it myself in high school by integrating a half-circle but I couldn't find the proper integration rule for f(x) = sqrt(1 - y^2)
Nor could I derive anything useful from the fundamental theorem of calculus
 
2:21 PM
Here's a condensed description of my algorithm. Hopefully, it's not too cryptic. :)
Let x = pi, m = 2**n (for sufficiently large n). By applying the double angle formula n times to tan((x/4) / m) we get tan(pi/4) = 1. So we let x be an approximation to pi and use Newton's method to improve the approximation. The for loop calculates y = tan(x/4), so the derivative is dy = sec²(x/4)/4 = (1+tan²(x/4))/4.
 
Best I can do is
from random import random
rand = lambda: random() *2 - 1
in_circle = 0
total = 0
while True:
    total += 1
    if rand()**2 + rand()**2 <= 1:
        in_circle += 1
    print(4 * in_circle / total)
 
Cabbage
 
2:24 PM
@Kevin It's a nice way to get a few digits, but you'd be waiting a while to get 12 digits out of it. :)
 
No kidding.
 
@PM2Ring thanks for the tip, I'm too late it seems:)
I was afk printing pamphlets meeting the missus
 
It's not too hard to replicate Archimedes' method. Start with a pair of squares, one circumscribing the unit circle, the other inscribed in the circle. Then you can use simple Pythagoras' theorem stuff to subdivide the square sides to get the sides of the enclosing & enclosed octagons. Etc. Unfortunately, this method suffers from accumulated errors.
def archipi(n):
    d = i = 2
    u = 1
    for j in range(n):
        i = 2 - (4 - i) ** 0.5
        u = ((u * u + 1) ** 0.5 - 1) / u
        d *= 2
        ipi = d * i ** 0.5
        opi = 2 * d * u
        mpi = (ipi + opi) / 2
        print('%2d: %.15f %.15f %.15f' % (j, ipi, opi, mpi))

archipi(12)
 
I like to think of PM as somebody so close to Archimedes that he simply calls him Archi. Fits in with my overall picture of him.
 
Archie
 
2:38 PM
:) When I was in high school, I read through a translation of Archimedes' proof for the formula of the volume of a sphere. I tell you, that was pretty heavy going! I think I understood everything in that proof, but I don't guarantee it. :) And I certainly couldn't reproduce it now (using proper calculus to do it is just so much easier).
 
PM2Ring is so famous that there's a tag in his honor.
 
I'm sure he just put some spheres in a tub and measured the displacement in units of pi (I'm sure he had a pi-based ruler)
 
When I was in high school, I derived the formula for the curvature of a curve (what's the correct term, damnit), that is how many radians per unit travelled it is. I thought it was quite an ingenuous formula, and that no one wouldn't have thought about that exactly like that. Then the following day I found that formula in the standard Finnish high-school book of tables that everyone is allowed to use in exams.
 
that's why you shouldn't strive for excellence, it's all in vain
I think curvature is the correct term
 
Just spent forty minutes graphing the taylor series for sin(x) before deciding no, this doesn't help me find the value of pi.
 
2:45 PM
yup
I think sin(x) itself assumes the knowledge of pi...
 
With the taylor series, all you need is exponents and factorials of whole numbers :-)
 
I could get pi by finding the zero of x\ -\ \frac{x^3}{3!}\ +\ \frac{x^5}{5!}\ -\ \frac{x^7}{7!}\ +\ \frac{x^9}{9!}..., but then there's two sources of imprecision
 
@AndrasDeak it is just that that doesn't converge fast
 
First, how far are you willing to calculate the series? Second, how many iterations of the zero-finding algorithm to use?
 
2:47 PM
@Kevin sum(1/n^2)=pi^2/6 if that helps. Well, square root......
so I guess "not much"
 
there was a formula for calculating any single hex digit of pi
 
cool
 
I don't mind doing square roots, but I can't use that identity unless I derive it myself
 
The Bailey–Borwein–Plouffe formula (BBP formula) is a spigot algorithm for computing the nth binary digit of pi (symbol: π) using base 16 math. The formula can directly calculate the value of any given digit of π without calculating the preceding digits. The BBP is a summation-style formula that was discovered in 1995 by Simon Plouffe and was named after the authors of the paper in which the formula was published, David H. Bailey, Peter Borwein, and Simon Plouffe. Before that paper, it had been published by Plouffe on his own site. The formula is π = ...
 
(no, I didn't derive the taylor series formula. I contain multitudes.)
 
2:48 PM
@Kevin you need to compute the Fourier series of x^2 or something over [-pi,pi] or something
 
@AnttiHaapala That's no mean feat. It took the world's best mathematicians a couple of centuries of analytic geometry before that formula was discovered.
 
it's pretty easy
@AnttiHaapala spigots
 
Fourier transforms have resisted all my attempts to learn it after no fewer than four separate attempts
 
@PM2Ring naturally, but the fact that the formula was in the book that I was using daily...
 
@Kevin they didn't teach you right
 
2:49 PM
fourier rules
 
@AndrasDeak He's doing this to compute pi, so using pi is kinda cheating. :) Unless you use approximations of pi that get refined as you go.
 
@PM2Ring yeah, I know. But I'm not sure that [-pi,pi] was the domain...
but anyway, Fourier series themselves involve pi
the only ab initio approach should be the circle
And no, I don't intend to back up this claim with facts:P
 
slow news day
 
Maybe if I knew how to differentiate asin(x) over a reasonable domain...
 
this with title "water painted the map of Finland on street in Tampere"
 
2:53 PM
56
Q: Trick or Treat polyglot

BrainStoneSince Halloween is coming up I though I might start a fun little code golf challenge! The challenge is quite simple. You have to write a program that outputs either trick or treat. "The twist?" you may ask. Well let me explain: You program has to do the following: Be compilable / runnable in ...

 
@Kevin d/dx finv(x) = 1/(d/dy f(y)|y=finv(x)) :P
I think
 
Ok but what is finv
 
the inverse of f, of course
so asin(x)' = 1/cos(y)|y=asin(x) = 1/cos(asin(x))
then you need to write cos y as sqrt(cos^2 y)=sqrt(1-sin^2 y), probably
so the result is something like 1/sqrt(1-x^2)
 
 
@AndrasDeak I think approaches using the Zeta function, like your sum(1/n^2)=pi^2/6 are ok too. On a similar note, sum(1/n^4)=pi^4/90, which converges a bit faster.
 
2:56 PM
@PM2Ring the reason I didn't want to back up my claim with facts is because I was unsure about its validity;)
if there's a pure way of computing those values of zeta, then by all means (I'm sceptic, still)
 
Is there a key combo that inserts a tab character in PyCharm when "tabs to spaces" is enabled?
(or any other editor, maybe it's the same in pycharm)
 
I don't know, but I have longed for that exact feature for Notepad++
Typically when I'm writing underhanded Python that takes advantage of mixed indentation trickery
 
I assume ^I gets converted to spaces.
 
@AnttiHaapala The fact that digits of pi can be calculated in parallel is seriously blowing my mind.
 
Native base for the universe's processing architecture confirmed to be 16
 
3:01 PM
@QuestionC Sort of. The spigot algorithms still need to get some info about preceding digits, they just don't need all of them.
 
Eat it, Euler's Number
 
hereby ln shall mean log_16
heretoforth?
 
2.71828... Wishes it was as popular and beautiful as 2 and its exponents
 
Only if the USA continues to use e.
 
 2 4 8 16 32 64 128...
 ^
(don't talk to me or my power series ever again)
 
3:05 PM
Lots of digits of e are easy to compute. Using Jensen's algorithm, you can easily do it without any form of bignum support. Here's an example in Python, but it can easily be done in plain C.
 
"Though the BBP formula can directly calculate the value of any given digit of π with less computational effort than formulas that must calculate all intervening digits, BBP remains linearithmic (O(n*log(n))) whereby successively larger values of n require increasingly more time to calculate; that is, the "further out" a digit is, the longer it takes BBP to calculate it, just like the standard π-computing algorithms.[5]"
@QuestionC ^
 
Just take e^(i*pi) + 1 = 0 and solve for e, easy.
 
I wonder if we ever meet another advanced civilization will they find our planet's obsession with pi silly?
 
@QuestionC I am pretty sure they would
... they'd be using tau
 
I imagine every member species of the Coalition of Worlds will have at least one deep fascination with something that everyone else is totally baffled by.
Humans won't be exceptional in that regard. The only thing interesting about us is our kickass homeworld whose moon just happens to almost perfectly occlude the sun during eclipses.
 
DSM
3:18 PM
pi~3 cabbage for all!
 
mmmmmm pi
cbg @DSM
 
I've had plenty of spinach pie, but I've never had cabbage pie. Unless you class spring rolls as a kind of pie...
 
@PM2Ring I'm sure pirogi can qualify as cabbage pie
 
cabbage pie looks really tasty. I think I need to try this.
 
3:29 PM
@AndrasDeak I guess so. I've never been a huge fan of boiled dumpling type things. But I guess the advantage is that you can eat more of them than fried ones. :)
 
I can get behind boiled dumplings if they taste similar to steamed dumplings
 
Yay! Blues Radio UK is back online. The server's been down for the last week or so.
 
3:45 PM
rbrb
 
@KevinMGranger Ah ha, got one. javascript and Python: eval(["console.log('trick')","","print('treat')"][(-1%2+1)])
3
Takes advantage of the fact that js modulus can be negative but Python modulus can't
 
@Kevin I think you mean the rules for modulus differs, python modulus is negative when the divisor... the second argument is negative
>>> 5%-2
-1
 
Ok, yeah.
 
Onion pie is also rather more delicious than it sounds. I was surprised that a regular sized pie will require about three pounds (1.5kg) of onions
 
floor division vs truncated division, either way the expression (a//b)*b + a%b == a always holds true ;)
 
3:51 PM
Makes sense.
 
onion pie, steak and kidney pie, anything savoury pie
love 'em all
 
Yes, notice that. You are probably right ...
 
4:07 PM
OTOH, maybe it's just that the teacher is rushing through the material and this student got left behind. But I'm not hopeful.
I finally finished my Discworld marathon today. I've read all the novels & the short stories, but I didn't bother re-reading the Science of Discworld books. Maybe next time...
 
user559633
cbg
 
user559633
4:24 PM
@davidism are name conflicts == typo for purposes of closing?
 
user559633
e.g. if i had a variable d in my code and was asking why pdb wouldn't show me its value, would that be a CV typo? (no tone meant; earnestly asking)
 
@tristan cbg
 
I just wish people indented things properly.
Also, cbg!
 
That's how I see it. The only special case is the module shadowing issue, which is legitimately not a typo but a subtle path problem.
 
The meat of this close reason is really: "this [question] was resolved in a manner unlikely to help future readers." This applies to mistakes of any nature. Not all cases of PEBKAC are unlikely to help future readers. — BoltClock ♦ Jan 3 at 14:19
 
4:35 PM
but most of them are
 
DSM
So basically they removed Too Localized, and the SO community rerouted around the problem by choosing the closest remaining reason and making that Too Localized..
 
but yeah, debugging questions are on topic if posed properly, so it's not trivial that the bug boils down to a typo, it's no longer on topic
 
The general consensus on Meta seems to be that if the nature of the problem is such that it would be very unlikely for a future reader with virtually the same problem and excellent Google-fu to find the question, then it probably should be closed under the "typo" reason.
 
@DSM see also: reinterpreting "too broad" to mean "so narrow that we must have to start at absolute zero to explain it to you" in order to close homework and read the docs questions.
 
I suspect that most "not-highly-unlikely-to-be-of-use typo" questions have good canonical dupes of the underlying brain fart...
such as shadowing built-ins
 
4:39 PM
Sigh, decent question turns out to be chameleon: stackoverflow.com/questions/40149743/…
Why can't I just have good questions? I'm going to go lie down and try not to cry.
 
@AndrasDeak Sure, but how likely is some newbie OP going to find that dupe? Unless it comes up as part of some homework assignment and a bunch of people doing the assignment make the same mistake. If the new question is well-written, and it can be hammered to a good dupe target, I'm happy to hammer it. Otherwise, I'd prefer to close it as a typo so it can get Roomba'd.
 
@PM2Ring sure, but you only need as many good signpost dupes...
anyway, those are pretty rare in nature, in my experience
 
True, but sometimes you can clean up a half-way decent signpost question that gets closed a dupe. And it doesn't really matter if it gets edited before or after hammering, since the OP is unlikely to want it reopened if the dupe target's good. On that note, I got yet another "thankyou" comment from an OP whose question I hammered a day or 2 ago.
 
Well, my point is that I'm not blindly against hammering off-topic questions:) Only generally:P
 
ok im doing gross stuff and i need help with design pattern for this
 
4:47 PM
latex gloves
 
I have a django.TimeField table ... that has times associated to given users... the first time the user uses the software after any of the times it needs to do an action
someone else wrote some code... and its so painful its causing a mental block
i feel like there is an easy solution that is being overlooked
I'll post the yuck if you want.. but it may break the way you think of the problem
 
user559633
5:07 PM
@davidism If you want, I can pull stories off my trello board and have you "answer" them
 
user559633
Sorry, was afk. Yeah, sounds like we need "too localized" and "question shows minimal effort" back (yes, i know SO corp is optimizing for bad questions (and specifically not answerers) to get more users)
 
Speaking of processing architecture, @tristan I'm reading the RISC-V spec for that game I'm totally eventually going to make (the TIS-100 alternative where you learn real assembly)
 
user559633
@KevinMGranger I'd be into it. I did some analytics on my sleep/productivity patterns, and decided that I'm going to spend one day a week doing something that I find interesting and/or not in the aim of shipping software, so I can make time to play/try it out.
 
@tristan Let's not forget the good old "Lacks minimal understanding"
 
user559633
@PM2Ring Oooh. I like those vintage CV reasons
 
5:16 PM
Today I'm trying to figure out how modern computers prevent poorly-constructed programs from going wild and overwriting their boot sector with all zeroes. I have opened six tabs so far. All I have learned for sure is that movl $1, %eax is the linux kernel command number (system call) for exiting a program.
Four tabs ago they mentioned "paging" which seems promising but first I have to learn assembly.
 
user559633
I thought paging was pre-allocating a chunk of disk space, then copying contents of registers to a block device on disk
 
@tristan There was one the other day (now deleted):
I have this code but do not understand what it does:

view_sphere = []
 
user559633
@PM2Ring Awww
 
I remember that. Seems like only yesterday
 
user559633
I think I'm going to just take today off from programming and read a book (on programming)
 
5:18 PM
Yeah but pages can have metadata(?) which you can use to mark some sections(?) as read-only(?)
 
The addresses you have in your programs aren't "real", they're mapped to real memory by the kernel and MMU
And yes, pages can be marked read-only among other things
If you want to learn assembly conceptually more than you care about learning more practical assembly (read: the painful x86) I highly recommend starting with MIPS.
 
user559633
Have a good day everyone
 
DSM
Good day to you, sir.
 
I'm currently very slowly reading "Programming from the Ground Up" which is the only link I could easily find in the Assembly chat room.
 
Is that the hard way?
 
5:23 PM
If you've already got a book, then that's fine. x86 has some strange complexities to it that just don't exist in other ISAs.
 
@AndrasDeak All ways are hard ways when it comes to assembly.
 
Learning assembly via x86 is like learning programming by learning Perl. It's practical, it'll probably get you a job, but jeez there are simpler alternatives
 
DSM
I haven't done assembly since the 88000. Except for a bit of inlining for high-performance numerical code during the narrow window after people realized you could do inverse-sqrts fast on graphics cards but before libraries for it became ubiquitous.
 
MIPS isn't hard, really! I miss it so.
 
I did have a semester of MIPS like eight years ago and I assume the basics are still kicking around up here somewhere. taps on head
 
5:25 PM
The only criticism was there were two instructions that were easy to mix up and maybe should have been named the opposite way. I can't remember what, though. Something with la?
 
(int) val hehe, very C
 
Ugh, you're giving me flashbacks to the 5(?) different ways to cast in C++.
 
I bet his list of integers is empty. Voted.
It's the only explanation that I can come up with that produces the error he describes while not making listOfIntegers a string or a list of chars or something.
 
DSM
Bah, casting is for people who don't work directly with void pointers.
 
5:36 PM
Hmm, "all of the items in [] are integers" is true, but is "[] is a list of integers" true?
 
DSM
It's a list, and there are no non-integers in it..
But yeah, natural language has different implications than formal logic. :-)
 
@DSM Spoken like a true mathematician. :)
Which reminds me of the conversation we had about this:
>>> all([]),any([])
(True, False)
 
Apparently my boss has been interviewing people and one question they've been asking is "what's the difference between Python and Java?" and they assume anyone that doesn't use the word "scripting" in their answer is a fraud. This upsets me.
 
"They're both turing complete, what more do you want?"
Java has a scripting component, too! It's called JavaScript. Haven't they been on the web?
 
We don't use either of those languages here, why is this even something we're asking applicants ;_;
 
DSM
5:43 PM
Wow, that brings back memories:
May 13 '14 at 17:57, by DSM
A friend's wife once dismissed Python in a conversation with me as merely a scripting language. She's a Java programmer. For the sake of a friendship which lasted since we were kids, I let the matter rest.
 
I was trying to get another java developer here to join this room because his name is also Kevin. He seemed hesitant to express interest in Python.
 
DSM
What, like he's keeping it on the DL?
 
I think he thought I was trying to prank him or set up some elaborate pun. Can't blame him. I already tried stealing his desk by putting a sticky note over the last name on the name plate.
He's also been infected with Java. rip.
 
if your grave doesnt say "rest in peace" on it you are automatically drafted into the skeleton war
3
Especially at this time of year.
 
DSM
At first I thought you meant Remembrance Day, then I realized he meant Halloween. #holidaymashup
 
5:53 PM
Remember, remember the first of November.
 
Writing prompt: humanity is just now recovering from the zombie apocalypse. A volunteer group roams around the Virginia-DC area looking for zeds dressed in formal military uniforms, and capture them so they can be re-interred in the Arlington National Cemetery.
 
i = next((
    i if dt == start else i - 1
    for i, (dt, id) in enumerate(plan_dates) if dt >= start
), None)

if i is not None:
    plan_dates = [] if i < 0 else plan_dates[i:]
I've created another monster. I can't stop.
 
wim
Please don't encourage Java devs to change to python
 
As long as the volunteer group doesn't have to bring them there via the blue line at peak hours, how bad could it be?
 
Obviously this needs to be in a "dead rise from their graves" zombie apocalypse universe rather than a "mysterious plague revives the recently dead" zombie apocalypse universe, but the rest of the details are free to vary.
 
wim
5:58 PM
They put everything in a class, they have one class per module, they litter CONSTANTS everywhere.. and sooner or later, I have to clean up their shit !
oh yeah, and they camelCase everything
 
@wim Clearly we need a mentor system where veteran ex-java users teach the fresh converts the correct idioms. Keeps us from having to do the dirty work.
 
No, just hang out in here. Not switch to python. We're consultants, we write in what we're told to write.
 
wim
@Kevin This guy would be the best mentor
 
OP said the code worked previously, so I doubt this will help. — John Gordon 10 mins ago
That worked.. thank you. Why am I requiring flask-restful when I never asked for it in my packages? Also, why did I not need this before? — micyukcha 9 mins ago
:-|
stackoverflow.com/q/40290897 opinion / recommendation
;_;
 
Nice tag you have there, @davidism. It would be a shame if something were to... happen to it
 
6:06 PM
"Oh, there's some new Flask questions!" ... "Oh"
stackoverflow.com/q/29517907 never clarified, basic either way
I should never have answered that, but for some reason no one likes using Counter to count things.
 
done
FWIW the accept probably answers your question
 
Yeah, I know, it was just an awful question.
 
yup
 
wim
Why was that deleted?
It's a super-n00b question, but it has an answer and it's clear what the question wanted
 
it won't help future readers, and as such doesn't hold any value for the site
it was also written in an ancient, obsolete language
@wim I'm starting to be bugged by the fact that the device is off-center in the gif, yet the blue ball of light shines up in the center
 
6:24 PM
Why did you have to point that out gah
 
I know it's partly to indicate that the viewer is being knocked out, but still...
@KevinMGranger OK, solution: it's actually the face of Will Smith generating the flash, and the device is only a distraction
 
Or we could just keep commenting until it's off-screen
 
that would never work
 
Not until.... this message. Ah, there we go.
 
The missus is looking for scarf patterns to crochet. Came across this one
 
wim
6:42 PM
you guys have small screens
it's still in the middle of mine
oh come on apple.com , you really couldn't get video streaming working on chrome / firefox / ie / linux / windows ?
bastards !
 
@kevin does interpretted vs compiled work as an answer? I feel like this is certainly a concept developers should understand ... and what the "pros" and "cons" of either might be
(or rather tradeoffs)
 
wim
new macbook pro -> apple.com/macbook-pro
 
touchbar wtf
it's breaking the ground like...a lot
 
@JoranBeasley There are lots of answers and that's one of them. I'm just worried that my boss is looking for exactly the answer they already have in mind
 
6:48 PM
Except for all the catching up it's doing for most of the specs.
 
"You compared this apple and orange and said the textures were different. The correct answer is: the colors are different. Zero points."
 
@Kevin show them google's phone interview...
 
lol
googles phone interviews are not good imho ... they really suck
on a few of the questions i answered "I would use google"
aparently thats not the right answer :P
 
I meant specifically this one
 
Aaand it took four questions to trigger my impostor syndrome.
> Thought: Typical Computer Science University (1st year) lectures.
Thought: my university never ever taught me anything remotely like this.
 
6:57 PM
yeah screw that touchbar nonsense. Was this another "courageous" decision?
 
that feels like an arbitrary bit of information to teach
 
It has no frackin' ports...thunderbolt ports, that's it???
 
I'm a fan of the touchbar. It's cool.
 
@AndrasDeak lol oh ok :P
 
They're completely right-- function keys aren't "discoverable" aside from whatever laptop manufacturers decide they also do unless you use their additional modifier key which might replace where Ctrl should be damn it lenovo
Sorry, got stream of consciousness-y there.
 
6:59 PM
my dells and their fn keys and ubuntu are getting along happily
 
@idjaw usb3c / thunderbolt apparently
 

« first day (2203 days earlier)      last day (2761 days later) »