Jump to content

Shadow

Senior Members
  • Posts

    615
  • Joined

  • Last visited

Everything posted by Shadow

  1. Well, you sort of half understood and half misunderstood, but before I get into that, let me thank you for your thorough answer. It's much appreciated. Yes, while the factorial has that growth of digits, don't forget we're talking about the primorial, which, if I understood correctly, grows according to [math]exp([1 + o(1)] n \log(n))[/math] Unfortunately, while I have a very vague idea of what o() is regarding functions (it's basically supposed to mean that one function grows much faster than the other, or that the limit of the two functions as they approach infinity is 0), I have no idea what o(1) means...which means I don't know what 1 + o(1) is So, I don't know if it's more or less, however logically it must be less than the factorial. As for comparing it with the Sieve of Atkin, I have absolutely no idea whether or not [math]exp([1 + o(1)] n \log(n))[/math] is bigger than whatever the Sieve of Atking uses. However, don't forget we only have to remember one single number, not a series. Just one huge number, and that's where I hope the strength of this algorithm (if there is any) lies. As for the time to calculate the Primorial, this is where you get me wrong. I don't intend this to be a method to prove primality, I intend it to be a way of generating primes. And since you generate the primorial on the run, you don't have to worry about time. Let me explain this on an example: Let us declare a variable [math]p[/math] that will hold the primorial, and a variable [math]x[/math] that will be the current numbers tested. You start out with two (let's just hard code it to make things simpler). So now we have [math]p = 2[/math] and [math]x = 3[/math]. [math]GCD(2, 3) = 1[/math] which means x is a prime. We update the primorial, that is [math] p = px = 6[/math]. And we move on. [math]x = 4, GCD(4, 6) = 2[/math] x is NOT prime. [math]x = 5, GCD(5, 6) = 1[/math] x is prime, [math] p = px = 30[/math]. [math]x = 6, GCD(30, 6) = 6[/math] x is NOT prime. [math]x = 7, GCD(30, 7) = 1[/math] x is prime, [math] p = px = 210[/math]. And on and on and on. I don't know if this changes anything, but at least you now have a fuller understanding of what I mean (I hope ). Cheers, Gabe
  2. I'm aware of that fact. What I'm sort of counting on is the fact that I read that the memory requirements of the Sieve of Atkins (which is, I believe, the fastest known algorithm) are also enormous...and if the supercomputers of this age can store that many numbers, one humongous number shouldn't be a problem...but that's just me and my theories
  3. Hey all, I just wanted to ask, I was thinking the other day and a though struck me. Given a number [math]x \in N[/math], then [math]x[/math] will be prime if [math]GCD(x\#,[/math] [math]x) = 1[/math], where [math] GCD(a,b)[/math] is the greatest common divisor of [math]a,[/math] [math]b[/math], and [math]x\#[/math] is the Primorial. In other words, [math]x[/math] is prime if [math]x[/math] and the product of all primes smaller than x are coprime, or relatively prime. While this could be used to prove a numbers primality, I think it'd be inefficient, if only because one would have to know all the primes smaller than x. It is possible to use a normal factorial in place of the primorial, however, regardless of the vast increase in the size of the resulting number, there are much faster methods out there. What I was think however is if one used this to generate primes. While the number that one would deal with would be huge, and get bigger and bigger with each new prime, it's only one number. The algorithm is I think pretty fast (I could only write an implementation in C++ using built in datatypes, which means I didn't get farther than 33 before I encountered overflows), because we only have to find the GCD of two numbers, and since we would only have to remember one number (that being the primorial) the memory requirements wouldn't be that horrible...yes, it's a big number, but I'm hoping it still requires less memory than standard approaches do. However, I'm only 16, and so have no idea how to find out this method's computation complexity, nor do I have any idea about the amount memory that's required. Wikipedia states something regarding the latter when you look at the primorial page, but that really doesn't tell me anything, if only because I still don't understand little-o notation (or big-O for that matter). I know I'm missing something here, since if it'd be as simple as I put it, this algorithm would already be in use...which is why I ask, can someone explain what I'm missing (and dumb it down so a 16 year old can understand)? Thanks in advance, Gabe
  4. Wow. Thanks for the feedback ) Real apreciated
  5. Hey all, first, apologies for the non-descriptive title, but I really couldn't come up with anything better. That said, I'll get straight to the point; we have the following numbers: [math]N_{1}=1[/math] [math]N_{2}=3[/math] [math]N_{3}=6[/math] [math]N_{4}=10[/math] [math]N_{5}=15[/math] [math]N_{6}=21[/math] [math]...[/math] [math]N_{n}=N_{n-1}+n[/math] Let me just give those numbers a name, for the sake of simplicity I'll call them Strange numbers (note, I wouldn't be surprised at all if this was a long discovered and frequently used series, such as the Fibonacci Numbers...so if it is, please correct me, since I am not aware of it's existence). Now, my question; given the number [math]x[/math], could anyone tell me if there is any way to find out if the number [math]x[/math] is a "Strange number"? Some mathematical formula or some such rule for me to check against...ideally, although I'm pretty sure it's not going to be that easy, I'm looking for something along the lines of "A number is a square only if it's square root is an integer". I know that's not a formal definition, but it would probably be the easiest way to check in say a program, which is what I need this for in the first place. My thanks to anyone willing to help, Shadow
  6. The code is pretty long, and also pretty incomplete I think it'd be more productive if I post the code after it's finished and...well...presentable :D but thanks, I'll be waiting for your address
  7. Hey mike, I've long since found out that the calculations I posted above are rubbish While I didn't know half the things you wrote about in your previous post, I did manage to make the program work, I did it I guess half my way half your way. You mentioned, in the other post, that you'd give me some constructive feedback on my source. That'd be brilliant !! If you could send me you're ICQ/Skype or something by PM, I'd love to go over the source with you. It's exactly this kind of help that I need the most and that I have none of ) Let me know and thank you again, Shadow
  8. Well, before that I wanted to try and expand the radius of collisions....one pixel was enough. It's finally working, or at least I'm not having the problem I did before. I'd like to thank all of you, especially Klaynos, for all the help you gave me. I'm not sure I could make it without you, but even if I could, it would've taken a LONG time Thanks again ;-) I'll post the working version of the program here once I've dealt with some other minor bugs, and found out which files I need to include with the program itself for it to work )
  9. True...but I only use pixels as a means to display it...in the actual source, I deal with coordinates that are represented by real numbers, ie. x=5.3523, y=6.32262....even if they don't intersect on the screen, they should, theoretically, intersect in the "number" part of the program.... I'll try changing their coordinates to the same value and see if the program registers that as a collision...if not, then the problem is obvious. If it does, we're back where we started, but a little further along the road. Thanks again for all the help, I'll let you know as soon as I try this out
  10. I can't imagine how that last part could be possible in C...after all, as far as the computer is concerned, zeros and ones don't bounce unless there's a function there that makes them. as for the passing close by, that also occurred to me, and I've been wanting to check for say 2 pixels around each star and count that as collision, but haven't gotten around to actually doing it....and it's still strange, since if they start out with 0 velocity, and only gravity is affecting them, and their mass is the same, they should collide, not miss, even by a tiny bit...?
  11. I got collision as looking at the X and Y coordinates, and if they match I set a collide flag, which means that all the functions ignore the given objects... as for the vectors, yes, but I use X and Y vectors, since I have no other means of expressing direction... good luck with the finals
  12. They're never going that fast....and yes, I do have a code for the event if they collide...if you, or anyone else, is interested and can program in C, I can post the source... If it only applies to speeds above three quarters c, I guess it won't help me much in my situation...any alternatives? But thanks anyway )
  13. Okay, then that's what I need ) Any ideas? I know about the law (to my great embarrassment I must admit that I don't know it's name) that says the faster you go, the more energy you need...unfortunately, I don't know enough about it to know how to implement it....could anyone suggest something ? ) Oh and also, shouldn't they collide?
  14. I don't know...when I changed the program to use this equation, it...well, see for yourself. Attached is a video I made of the output of my program. The velocities of the objects (represented by the pixels obviously) at time 0 equal zero (or, as Bignose put it, "they start out as stationary and then gravity is turned on") and their masses are the same. star.zip
  15. I'll try But thanks anyway ;-) you've been a great help
  16. oh...well, I was thinking about GR, but unfortunately I have absolutely no Idea on how to implement it...I'm in my first year in High School, and I only understand the most basic concept of GR....but if you could tell me how, or at least point me in the right direction with a couple of examples, I'd be more than grateful
  17. Erm...what's GR? and what do you mean by "some midpoint stationary to both stars..."? Forgive the confusion
  18. I admit I am interchanging velocity, acceleration and force a lot....so I guess I'll ask directly; as I explained more thoroughly in the post I link to, I'm writing, or trying to write to be exact, a program that would simulate the movement of "stars", or objects with a given location and mass. These objects start out with zero velocity. They only gain velocity through gravitational acceleration. How would I go about calculating the displacement of one object due to the gravitational force of another object acting upon it in one time unit? PS.: Yes, you interpreted my post correctly
  19. I forgot to say I knew the distance, sorry. And there is no other force. The objects are stationary relative to one another. The mass of every object and the distance between them is known. Which of the two above equations should I use?
  20. Hello all, I have a question. Further information on why I'm asking can be found at this yet unanswered post.My question is; If I have a stationary object one of mass x, and a stationary object two of mass y, do I calculate their displacement using [math]F_g = G \frac{m_1m_2}{r^2}[/math] or using [math]a_1 = G \frac{m_2}{r^2}[/math] and [math]a_2 = G \frac{m_1}{r^2}[/math] ?? I thank anyone willing to shed some light on this confusing matter. Shadow
  21. Hello all, I'll get straight to the point. I've been trying to write a program that would simulate the movement of stars, and I've been having slight problems in thinking up the most fundamental part of this idea: the way gravitation interacts with those stars. Here's some basic info on what I need, how I need it, and how I've been trying to solve the problem. Every star (I'll be calling them objects) has it's given mass, position, and velocity. We are in Cartesian space. Since I'm using C as a programing language, I have no choice but to represent the velocities and their directions as X and Y speeds. You probably have no idea what I mean, so let me explain on an example. Here we have and object situated at the coordinates [math] x = 4[/math] and [math] y = -3[/math]. As you can see, the blue line is the velocity vector of that object. In plain language, it say "In one unit of time, this object will be displaced by this much in this direction". However, I had to be able to represent BOTH the size and the direction of the vector using nothing but dimensions. I can't use angles, or anything like that. The only way I could think of doing that was...well... the way I did it, since I can't find the right words to describe it. But that's the point of an image, though, isn't it? The direction of the X and Y vector can be expressed by it's positivity or negativity. So, the vector [math]\vec{v}[/math] can be represented as [math]\vec{v} = \sqrt{x^2 + y^2} \hspace {2mm} where \hspace {2mm} \vec{x} = 3, \hspace {2mm} \vec{y} = -2[/math] However, the squaring of X and Y would destroy our sense of direction, since squared numbers are always positive. This would mean that we'd have to store the direction [math](\pm 1)[/math] in a separate variable, and multiply the result by this variable in the end. But there is no need for that, since I am automatically representing everything in the "X and Y" way, so there is really nothing to be squared. To sum it up, in plain speak I am saying "This object will move by this much in the X direction (left, right, left is negative, right is positive) and by this much in the Y direction (up, down, up is positive, down is negative) in one unit of time". Now that you know this part, I can go on to explain the actual problem I'm encountering. Say we have two objects, a and b, with the following definitions: object[a].coordX = 2 object[a].coordY = 1 object[a].velX = 2 object[a].velY = 3 object[a].mass = 5 kg object.coordX = 3 object.coordY = 3 object.velX = -2 object.velY = 1 object.mass = 7 kg Here is an image representing the objects and their velocities. Now, here is my problem; I need to calculate the change in the X/Y velocities of both object due to gravity. Here is how I TRY do it. The effects of gravity on object A diffX = object.coordX - object[a].coordX = 1 -> The distance gravity has to "travel" on the X plane diffY = object.coordY - object[a].coordY = 2 -> The distance gravity has to "travel" on the Y plane velX = object[a].velX = 2 -> The X velocity of the object velY = object[a].velY = 3 -> The Y velocity of the object r -> distance between the two objects [math]F_g[/math] -> gravitational force x -> a temporary variable gravX -> The X value of gravity gravY -> The Y value of gravity finVelX -> The final amount of units by which the object will be displaced on the X plane finVelY -> The final amount of units by which the object will be displaced on the Y plane [math]r = \sqrt{diffX^2 + diffY^2}[/math] [math]r = \sqrt{5}[/math] [math]F_g = G \frac{m_1m_2}{r^2}[/math] [math]F_g = 46.69 \cdot 10^{-11}[/math] [math]x = \frac{F_g}{\sqrt{diffX^2+diffY^2}}[/math] [math]x = 9.2 \cdot 10^{-11} \cdot \sqrt{5}[/math] [math]gravX = diffX \cdot x = 9.2 \cdot 10^{-11} \cdot \sqrt{5} [/math] [math]gravY = diffY \cdot x = 18.4 \cdot 10^{-11} \cdot \sqrt{5}[/math] [math]finVelX = gravX + velX = 2 + (9.2 \cdot 10^{-11} \cdot \sqrt{5})[/math] [math]finVelY = gravY + velY = 3 + (18.4 \cdot 10^{-11} \cdot \sqrt{5})[/math] The effects of gravity on object B diffX = object[a].coordX - object.coordX = -1 -> The distance gravity has to "travel" on the X plane diffY = object[a].coordY - object.coordY = -2 -> The distance gravity has to "travel" on the Y plane velX = object.velX = -2 -> The X velocity of the object velY = object.velY = 1 -> The Y velocity of the object r -> distance between the two objects [math]F_g[/math] -> gravitational force x -> a temporary variable gravX -> The X value of gravity gravY -> The Y value of gravity finVelX -> The final amount of units by which the object will be displaced on the X plane finVelY -> The final amount of units by which the object will be displaced on the Y plane [math]r = \sqrt{diffX^2 + diffY^2}[/math] [math]r = \sqrt{5}[/math] [math]F_g = G \frac{m_1m_2}{r^2}[/math] [math]F_g = 46.69 \cdot 10^{-11}[/math] [math]x = \frac{F_g}{\sqrt{diffX^2+diffY^2}}[/math] [math]x = 9.2 \cdot 10^{-11} \cdot \sqrt{5}[/math] [math]gravX = diffX \cdot x = -9.2 \cdot 10^{-11} \cdot \sqrt{5} [/math] [math]gravY = diffY \cdot x = -18.4 \cdot 10^{-11} \cdot \sqrt{5}[/math] [math]finVelX = gravX + velX = -2 + (-9.2 \cdot 10^{-11} \cdot \sqrt{5})[/math] [math]finVelY = gravY + velY = 1 + (-18.4 \cdot 10^{-11} \cdot \sqrt{5})[/math] This would mean that in the time between [math]t_0[/math] and [math]t_1[/math], object[a] will be displaced by [math]2 + (9.2 \cdot 10^{-11} \cdot \sqrt{5})[/math] to the right, and by [math]3 + (18.4 \cdot 10^{-11} \cdot \sqrt{5})[/math] up, while object will be displaced by [math]2 + (9.2 \cdot 10^{-11} \cdot \sqrt{5})[/math] to the left, and by [math]1 - (18.4 \cdot 10^{-11} \cdot \sqrt{5})[/math] up. To calculate the amount object[a/b] will be displaced between [math]t_1[/math] and [math]t_2[/math] I would have to redo all these calculations using the exact same values except for r. Could someone please verify this and tell me if it works, and, if not, propose a better (working ) solution? I thank anyone who even bothers to read this in advance, and may God bless those who actually understand it Shadow
  22. Ok, thanks. Any links for the modules, while I'm at it?
  23. Well, here I am with another C oriented question. To put it simply, what if an unsigned long long int data type just isn't enough? If you want a specific example of why I need this; I made a program that generates Fibonacci Numbers. You can input how many numbers you want generated. Unfortunately, I can't generate more than 94 of them, because then the numbers are just too big for the data type to remember. How can I get around that? I know it must be possible, otherwise how could we know for example that the biggest prime number (yet found I mean) is [math]2^{32,582,657}-1[/math]? Thanks in advance for any help
  24. Okay, I've got some exercises here that I need some help with. I tried to do them, but I always get to a point where I just don't know what to do... 1) A train is sitting (idle) in front of a tunnel of the length [math]d=320m[/math] so that the trains front is placed exactly at the beginning of the tunnel. When a signal was given, the train started to move. In this instant a person standing at the very end of the train started counting the time. He noted that he entered the tunnel when his watch showed the time [math]t_1=30 s[/math] and exited the tunnel when his watch showed the time [math]t_3=50 s[/math]. The motion of the train was evenly accelerated the whole time. What is the length [math]l[/math] of the train, and the time [math]t_2[/math] of the exit of the front of the train from the tunnel? I think I could calculate both on my own, the problem is I don't know how to figure out the acceleration... 2) A pilots destination lied northward of his current position. He pointed his airplane north, but didn't take into consideration that a southwest wind was blowing. In [math]t_1=60 minutes[/math] he realized that his course had changed due to the wind. So he pointed the planes direct axis to the west and in [math]t_2= 15 minutes[/math] reached his destination. The velocity of the plane in windless conditions is [math]v_1=180 km/h[/math]. What is the distance [math]d[/math] between the starting point and the destination, and the velocity [math]v_2[/math] of the wind? This I could solve if, again, I knew his velocity. But I don't know how to get to that. It's not that I'm lazy, I've tried... I'd like to thank anyone and everyone for their help in advance. Please note that both the exercises are translated from Czech, so please excuse any grammatical errors that might appear. Also note that this isn't really homework. It's work that will decide my grade at the end of this semester....
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.