# Aeternus

Senior Members

349

1. ## Theory of computation help

I assume your alphabet is $\{1\}$? In this case, you can just proceed by induction on the length $n$ of the string. Take a couple of base cases to make it simple. It makes things much simpler if you first of all reduce it to (111*)* = 111*, since clearly 111* has any string of length 2 or greater, which is the same as (111*)*. In the case $n = 0$, then due to the outer most Kleene Star in both cases, the empty word is in both languages. In case $n = 1$, then as we have no string in either expression of length less than 2, no amount or concatenation or choice will result in a string of length one, so "1" is not in either language. In case $n = 2$, then this is clearly in both languages from the definitions of Kleene star and +. In case $n = 3$, then this is clearly in both languages from the definitions of Kleene star and +. Assume for the induction hypothesis that we have the string $S$ of size $n$ in the language of both, and the string S' of size $n+1$ also in the language, and $n \ge 3$, then consider what happens if we have the string S'' of length $n+2$. Clearly S'' is in the language 111* (as this matches any string of length 2 or greater). In case $n+2$ is odd, then we have that S of length $n$ is in the language (11 + 111)* and by the definition of the Kleene star S11 is also in the language, and the same argument holds if $n+2$ is even. Basically, from 11 and 111, you can make any odd or even sized string of 1s of length greater than 2 by simply adding 11 to either repeatedly (to make all the even or odd sizes.
2. ## From simple to complicated

Why not look at things such as - http://en.wikipedia.org/wiki/Adder_(electronics) ? A nice simple example of computation being done with logic gates.
3. ## Prime Number Generation

Note here that $n\sharp$ is not the same as $P_n\sharp$ and I imagine you should be considering $n\sharp$ if you are looking at all the primes up to $n$, which will be much better for you. However, even with this improvement, this still gives a space complexity of $O(n)$ (from the wiki), which is still worse than Sieve of Atkins. Note here, that whatever your space complexity, your time complexity must be at least that (since you need to write to that many memory locations). You still need to worry about time, since the time to calculate just the final primorial (i.e over the course of the entire algorithm) is too big. Even if your algorithm wasn't already worse time and space complexity (baring in mind, this is just from calculating that one number, I'm not assuming anything other than the calculation of one primorial), there is also the fact that you still need to calculate the GCD for these huge numbers, which in of itself has quite a bad time complexity from what I know, see http://en.wikipedia.org/wiki/Euclidean_algorithm#Running_time . I imagine there are faster algorithms but from what I gather they are not much faster, and they would have to be at least O(log(n)) (afaik) as you'll need to read the numbers (assuming we are considering $n$ as the number and not the size of the number - this is something one should be careful of, as various resources approach this differently, and considering it in the size of the number throughout would probably be more appropriate). If you are genuinely serious about trying to understand this, then I'd honestly suggest you read up on Big O etc, and work through things, rather than hand waving with "one huge number has to be better than lots of smaller numbers", which just doesn't seem to be true. If I've made some mistakes, please point them out.
4. ## Prime Number Generation

If you look at http://en.wikipedia.org/wiki/Factorial#Rate_of_growth , you'll see that for bigger $n$, $n!$ has at least $n (\log(n) -1)$ digits, which means that for a prime with thousands of digits, you are talking of not thousands of digits but of the order of $n\log(n)$ digits where $n$ is thousands of digits itself. I.e, you are talking at least $O(n \log(n))$ space complexity as far as I can see, which is worse than that for Sieve of Atkin given at http://en.wikipedia.org/wiki/Sieve_of_Atkin#Computational_complexity , i.e $O(n^{\frac{1}{2} + O(1)})$ (presumably the constant in the exponent is very small, as it is supposedly better than the Sieve of Eratothenes, although either way, the space complexity can't be worse than the time complexity) although I don't know the constants involved (See http://en.wikipedia.org/wiki/Big_O_notation for a better idea of O notation. If you make another thread of anything you don't understand, people can explain ). Also, you have to look at the time it takes to calculate a factorial, remembering that multiplication is not a constant time operation. If you look at http://en.wikipedia.org/wiki/Factorial#Computation you'll see that to calculate $n!$ is far worse time complexity than that used for Sieve of Atkins (See http://en.wikipedia.org/wiki/Sieve_of_Atkin#Computational_complexity again). If you look at the time and space complexities for Sieve of Eratothenes (one of the most well known and oldest algorithms for calculating all prime numbers up to a number), I believe your algorithm would still be worse. I'm not sure here whether you are suggesting calculating factorials or primorials for each prime test and going through them, but again this is far worse than simply using the sieves or just going through the list of numbers with individual primality tests. If your algorithm only tests whether a single number is prime, and does not find all prime numbers less than that number, then there are MUCH faster algorithms for testing individual primality without calculating all primes - See http://en.wikipedia.org/wiki/Primality_test#Fast_deterministic_tests . I might be misunderstanding what you are suggesting. If so, could you please explain what I'm misunderstanding.
5. ## Big theta notation

Well consider that given a number n, you need $\log_2(n)$ bits to display it, so you have $N = \log_2(n)$ $2^N = 2^{\log_2(n)}$ $2^N = n$ So you are left with $O(2^n)$. Two points to note : a) Big O and Big Theta are two different things. Big O is only an upper bound, whereas Big Theta is much tighter and must be also a lower bound. See http://en.wikipedia.org/wiki/Big_O_notation#The_family_of_Bachmann-Landau_notations . b) You only need to check for factors up to $\sqrt{n}$ rather than $\frac{n}{2}$. Consider a number bigger than the square root, then you'd need to multiply it by a number smaller than the square root to get n, otherwise you'd get a number larger than n.
6. ## Weird Maths Problem

[hide] Or the fact that there is an eldest child, (potentially) implying there aren't 2 eldest children if you only consider integer ages. [/hide]
7. ## Which is better Mac or pc

Given personal experience, experiences of friends and also looking around online, I'd say that, while macs USED to be higher quality than your average PC, they are probably about on par these days.
8. ## Simple set/venn diagram question

Sounds right. Although you could probably get away with $(C \setminus A) \cup (B \setminus C)$ since $C \setminus A$ will contain the bits that you need from C.
9. ## A question from a kid.

I think you have the wrong idea. From what I gather, when one talks of 10 dimensions, one is not talking about different universes or anything like that (you might be thinking of http://en.wikipedia.org/wiki/Many_worlds but that suggests many more than 10 "universes") but is talking about spacial dimension, in the same way that you have 3 dimensions (i.e height, width and breadth). The idea being that you don't have just 3 spacial dimensions but in fact 10 spacial dimensions (this is very difficult to imagine, hence the video and various other resources trying to provide a way to imagine it). From what I remember, the ideas that suggest a greater number of spacial dimensions usually say that the dimensions other than the 3 we normally consider are very small and unnoticable, but that sort of thing is probably a massive oversimplification told to the general public on documentaries etc (I'm not a physicist).
10. ## Linq

The nice thing is that it's not limited to SQL backed systems, you can use LINQ to run through various datastructures that you are using or implement a few interfaces and have your own datastructure usable (through IQueryable etc I believe). Saying that, the underlying idea isn't completely original, as bascule mentioned previously, things like ActiveRecord and ADO.NET have done similar things (not specifically the query part, but bringing the handling of the data and types into the programming language) but it'll be interesting to use. Personally I'm more interested in them bringing various features that they require for LINQ, such as lambda expressions, and more functional concepts (which LINQ seems to be part of) and so on, to languages such as VB.NET. There are many times when you just want to do something in a functional manner because it is the quickest and most readable way to do something, and a nice fusion of imperative and functional ideas in languages certainly benefits developers.
11. ## The Latex Test Thread

You know you can preview your post right ?
12. ## Driving Problem

I don't think that's correct, you are averaging over distance, not time. I believe you can't do it. Take the speed we travel back with to be $x$. We have $\textrm{average speed} = \frac{\textrm{total distance}}{\textrm{total time}}$. We have the total distance as 60, and the time is going to be the 1 hour we have already used, added to the time it will take us to cover the remaining 30 miles, so $\frac{30}{x}$. This gives us $60 = \frac{60}{1 + \frac{30}{x}}$ $1 + \frac{30}{x} = 1$ $\frac{30}{x} = 0$ As you can see, there is no solution. If you could travel for another hour at 90 mph, then it would be fine, but you only have 30 miles left to cover.
13. ## How did Order of Operations Come About?

I think you'll find 2 + (3*4) = 14 .

Well, it's fairly inexpensive, so why not buy it, or get it from the local library or something. If you find it hard to read, it might make a reasonable door stop
15. ## SciFi Lingo - Tach and Tard?

Strangely it seems they are from different roots (one from greek, one from latin) http://en.wikipedia.org/wiki/Greek_and_Latin_roots_in_English
16. ## c++ help

There are code tags ( [ code ] and [/ code] (without the spaces)) which you might find useful. Firstly, you either need to specify the namespaces you are using explicitly on use or overall the namespaces you are using within the file. Your compiler may be ignoring this but you should probably realise it is a problem, as it will come up if you move to others. Secondly, the second version is almost certainly necessary, as otherwise you'll only ever be able to book one class of ticket. Thirdly, given that you didn't actually specify what your problem was or what you expected this thing to do, I assume your problem was something akin to the problem I encountered while running this code, which was an issue whereby cin leaves a newline character on stdin, and that then gets picked up when you call getline a second time (after a previous cin call) and so you have to tell cin to ignore the character before calling getline. If that's not the problem you had, perhaps you could elaborate further. Here is your code, edited and working as far as I can see (given I don't know exactly what you want - #include <string> #include <iostream> using namespace std; int main() { int c, s[10]; int i, j; string name; for (j=0; j<10; j++) { cout << "Welcome to Airline Reservations System!\n"; cout << "Please enter your name: "; cin.ignore(); getline(cin,name); cout << "Choose a class: "; cin >> c; switch(c) { case 1: cout << "First class" << endl; cout << "Seats available are 1,2,3,4,5.\n"; do { cout << "Pick a seat: "; cin >> s[j]; for (i=0; i<j; i++) if (s[j]==s[i]) { cout << "Seat taken. "; break; } } while (i!=j); if(s[j] <= 5) { cout << "\n"; cout << "--------------------------\n"; cout << "Name: " << name << endl; cout << "Class: " << "First class" << endl; cout << "Seat no.: " << s << endl; cout << "--------------------------\n"; } else cout << "Wrong number! No seat for you!\n"; break; case 2: cout << "Economic class\n"; cout << "Seats available are 6,7,8,9,10.\n"; do { cout << "Pick a seat number: "; cin >> s[j]; for (i=0; i<j; i++) if (s[j]==s[i]) { cout << "Seat taken. "; break; } } while (i!=j); if(s[j] >= 6) { cout << "\n"; cout << "--------------------------\n"; cout << "Name: " << name << endl; cout << "Class: " << "Economic class" << endl; cout << "Seat no.: " << s[j] << endl; cout << "--------------------------\n"; } else cout << "Wrong number! No seat for you!\n"; break; } } system("pause"); return 0; } You may also want to look into initialising your array (I'm not entirely sure on the C++ standard but in C, uninitialised content could be anything) and you may want to check that cin etc actually return something properly (remember I can press ctrl+d). Also, you may want to read Things to Avoid in C/C++ -- system("pause"). I'll probably comment more fully after my exams tomorrow.
17. ## OLPC + WinXP = OLPC?

I believe they have spaces in Leopard. Although I'd prefer a decent linux distribution over OS X these days, it's just easier to use most OSS tools and utilities, and I'd rather not support yet another proprietary OS and environment (bit hypacritical as I'm typing this on a macbook but my next laptop won't be a mac).
18. ## a function that gradually increses, and then picks up exp. rate

If you don't mind it being symmetric about the y axis and only want strong growth not assymptotic like Capn's, then you might also consider something similar to what Bignose suggested - $y = e^{(\frac{x}{a})^b} - 1$ Where you can change $a$ to change where it begins growing very quickly and change $b$ to change how quickly it grows at that point and how gradually it grows before that. To generalise what Capn said a bit, if you want assymptotic behaviour, similar to what he said you can do $y = \frac{1}{b \cdot x-b \cdot a}$ Where $a$ and $b$ have similar effects as above.
19. ## a function that gradually increses, and then picks up exp. rate

$x^2$ is not an exponential function or even a function exhibiting exponential growth. See http://en.wikipedia.org/wiki/Exponential_growth . I imagine the answer to your question is really going to depend on what exactly you want and what you mean by "in the beginning" and gradual growth. Can you go into a bit more detail about what it is you want to derive?
20. ## All ciphers are crackable? BULLSPIT!!!

I'd like to point you to http://en.wikipedia.org/wiki/Rubber_hose_cryptanalysis One of the most fun and effective methods If you explain a bit more what you are trying to do, then people can tell you whether your cryptosystem is likely to be any good (this isn't to say that one needs to know what cipher you are using to cryptanalyse it, only that it's much easier to narrow down the field and explain principles without wasting time on a pointless exercise). The fact that you are trying to rely on security through obscurity seems rather ominous of a bad cipher in any case though ( See http://en.wikipedia.org/wiki/Kerckhoffs%27_principle ) .
21. ## Godel's Theorem for Dummies.

Shouldn't it be mentioned that the theorem initially mentioned in the first post refers to Gödel's Second Incompleteness Theorem (which uses the first but isn't the same theorem), while later posts refer to the First Incompleteness Theorem. Also "Gödel's Theorem for Dummies" is a little non-specific as he is known for several other theorems including his Completeness Theorem.
22. ## Archimedes “displacement” eureka.

To clarify, wasn't the issue that the people making the crown could have added some silver into the crown so that it would weigh the same as a gold crown but they could pocket the surplus gold. Therefore Archimedes realised that gold and silver are different densities and so if they weighed the same, the volume would be different but doing this by eyesight, with such a difference, would be rather hard and so the bath trick comes in where he can put a gold bar into some water, and then put the crown in (seperately) and if the water doesn't rise by the same amount, then it's off with the jewellers/goldsmiths head http://en.wikipedia.org/wiki/Archimedes
23. ## Is Boycotting Blackmail?

I disagree that boycotting is blackmail as far as the strictly defined meaning of the word goes and especially not in the spirit of the word as it is used, but I can certainly see where the argument is coming from. Personally, however, I've never seen anything wrong with blackmail, except in the situation where the blackmail revolves around some other illegal act (as then blackmail being illegal makes sense as it makes it less likely the act will be hidden, although I imagine withholding evidence is illegal anyway?). As far as I see it, someone does something questionable, you offer them the chance to keep said questionable act secret by offering some benefit to you. If they say no, then you do what you would have otherwise done and make that questionable act public. Making the questionable act public is not illegal, keeping it a secret without an offer is not illegal, so I do not understand why adding some condition into the mix all of a sudden makes it illegal, although I suppose one could make the same argument about prostitution and sex, but then again, I don't believe that should be illegal either. I guess, it comes down to the "a society where everyone is blackmailing each other tends to be bad and lead to worse acts" but I'm not sure I'm convinced.
24. ## Logic

There's also the issue that as you add more and more variables, basic truth tables become completely infeasible.
25. ## Logic

One thing to remember is that $a \implies b \equiv a \wedge \neg b$, so then you can just apply that, demorgan's law and some of the other basic rules and derive a rather short equivalent formula.
×