How fast would a computer do this?

  • Thread starter Thread starter disregardthat
  • Start date Start date
  • Tags Tags
    Computer
Click For Summary

Discussion Overview

The discussion revolves around the computational speed and capabilities of computers in performing complex calculations and graphing multiple mathematical expressions simultaneously. Participants explore the feasibility of using computers for real-time calculations related to collision detection and graphical representation of functions, particularly in the context of programming and algorithm efficiency.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about the speed of computers in graphing multiple expressions, specifically 40 complex mathematical functions involving constants and trigonometric components.
  • Another participant notes that the speed of calculations depends on program optimization, processor speed, and available RAM.
  • A participant shares a personal test result, indicating that plotting 40 functions simultaneously took about 5 seconds, suggesting that well-optimized programs can significantly outperform calculators.
  • Discussion includes the use of vector functions to model the positions of rectangles and their interactions, with a focus on collision detection algorithms that require numerous calculations.
  • Some participants mention the potential for using graphics cards to enhance performance in collision detection tasks, as these algorithms are commonly utilized in gaming.
  • Several participants suggest software options like Mathematica and Matlab for performing the required calculations, while also discussing the learning curve associated with programming.
  • One participant provides detailed estimates of the computational cycles required for evaluating the functions, suggesting that a 1 GHz processor could achieve a significant number of refreshes per second depending on the complexity of the calculations.

Areas of Agreement / Disagreement

Participants generally agree that computers are capable of handling complex calculations much faster than calculators. However, there is no consensus on the specific software or programming approach that would be best suited for the tasks discussed, and varying opinions exist regarding the efficiency of different algorithms and programming languages.

Contextual Notes

Limitations include the dependence on the specific programming language and software used, as well as the assumptions made about processor capabilities and optimization techniques. The discussion does not resolve the best approach for implementing the proposed algorithms or the exact performance metrics of different systems.

Who May Find This Useful

This discussion may be useful for students and enthusiasts in computer programming, mathematics, physics, and game development, particularly those interested in collision detection algorithms and real-time graphical computations.

disregardthat
Science Advisor
Messages
1,864
Reaction score
34
Hi, I have little experience with computer and programming (just a little on my calc) and I wonder how fast a computer really is. Would it be a problem for a computer to "graph", that will say calculate several expression frequently for different inputs at once?

I have about 40 expressions kind of like this:

[tex]f(x)=([A_1x+B_1+C_1sin(D_1(x-E_1)]^2+[A_2x+B_2+C_2sin(D_2(x-E_2)]^2)^{\frac{1}{2}}[/tex]

[tex]A_k,B_k,C_k[/tex] and [tex]D_k[/tex] are constants.

And if a computer were to graph these at all times, how well would it handle it?

I know of course that the speed depends on the frequency of the calculations, but I want it fairly high, much higher than the calculator graph the curves.
 
Technology news on Phys.org
Depends on the optimization of the program, processor speed, background processes, amount of RAM...
 
Probably the speed of a well written computer program will make your calculator look like a snail compared to it :smile: To get more specific information, you should be more clear about where the data come from, how you want to plot it, which program you have in mind, etc.

PS I just did a little test: in a very ugly hack-like first approximation, it takes me about 5 seconds to plot 40 of them with random [itex]A_k, B_k, C_k, D_k[/itex] simultaneously (and plotting consecutively makes it about 5x faster).
 
Thanks for the replies.

I have as previously said very little experience with programming.

But I am trying to make this:

We specify coordinates to two rectangles, and the speed of rotation and the speed and direction of the centre.

Now, I have made out purely by vectors and their properties an algorithm of knowing when the rectangels hit each other, and how they shall bounce off each other.

I have:

Four vectorfunctions which describe the positions for each corner in each rectangle which is in this form:

[tex]\vec{r}(x)=[A_1x+B_1+C_1sin(D_1(x-E_1)),A_2x+B_2+C_2sin(D_2(x-E_2))][/tex]

That makes eight functions to graph at all times.

Now I have defined the radius of the rotation circle of each rectangle to be R and R'. Now I have also made a similar vectorfunction for the positions of the centres S and S' in each rectangle, and when |\vec{SS'}| <= R+R', (the distance between the centers is less than the radius of each rotation circle) then I want several calculations to be made:

I want to calculate several distance formulas from each corner in one rectangle to every other point in the other rectangle. I use a method by using vector dot-product to see when a corner of one rectangle is on the edge of the other rectangle, basically when they touch each other. But this requires many functions to calculate at all times, e.g. the distance functions from the points. When I sum they up, there are about 40-80 of these functions that I want to be calculated at all times, and when a specific value appears, I want the "collision" stage start. Which will make several differences in the path and rotation speed of the rectangles.

Perhaps a bit babbly, but I hope you see what I mean. As you obviously can see, this won't work on a calculator, I need a computer, but first I want to know if this is possible.

Thanks
 
Last edited:
Remember computers are fast. If it takes a couple of 1000 calculations to find a hit then you can still do 1million/sec! Especially since the amount of memory used if very small and so will fit in cache.
There are a lot of tricks to speed-up collision algorithms - they are very heavily used in games. For more complicated shapes your graphics card probably has hardware to do it for you.
 
Just eyeballing it it doesn't look too bad at all. You would want to use something like http://www.wolfram.com/products/mathematica/index.html" for this.

If there's a university or college with a Mathematics or Physics department near you they may have computer labs with one of these programs available that you can just walk in and use.
 
Last edited by a moderator:
CaptainQuasar: Can you use Matlab to create such a program? I have heard good things about it.

mgb_phys: I am interested in these methods to speed up collision algorithms, do you have a source of information?
 
This site is generally good for games develeopment tutorials http://www.gamedev.net/reference/list.asp?categoryid=199 the link is to list of collision detection articles.

For general geometry algorithms (intersections of lines etc) this site has the clearest descriptions and most readable code http://local.wasp.uwa.edu.au/~pbourke/geometry/

For using graphics cards to do this start with the links on the wikipedia page about physics_engine
 
Last edited by a moderator:
Hey, thanks for the links. I wonder though, could you take a look at the ideas I have if I wrote them down in lucid form and tell me if there's something worth trying? You seem to know this stuff. I have never done anything like this, or read anything about it. It will only be a few pages.
 
Last edited:
  • #10
Jarle said:
CaptainQuasar: Can you use Matlab to create such a program? I have heard good things about it.

Matlab etc. wouldn't create a program. Those programs are themselves like graphing and symbolic calculators.
 
  • #11
Do you know of a program which is much like the calculator Texas's way of programming? It's the only programming language I know of. I have made a sketch on how the program should be now, so I really just need something to program it into.
 
  • #12
Jarle said:
Do you know of a program which is much like the calculator Texas's way of programming? It's the only programming language I know of. I have made a sketch on how the program should be now, so I really just need something to program it into.

No, you would probably have to learn to program / write commands for whatever software you're using. But if you're going to continue with math in school it's well worth it to spend the time learning, these programs can do amazing things. My favorite is Mathematica. When I was in school I always dreamed about buying a palmtop computer like the http://www.oqo.com/products/index.html" and running Mathematica on it, rather than using a graphing calculator.

Here's an open source one called http://www.gnuplot.info/" . It's probably more difficult to use and less versatile than the commercial ones I mention above but it's free so you can download it and try it out right now. But also, if you're willing to spend some money and you're a student you probably can qualify for a student discount of one of the commercial ones, which would probably put it between US$100-US$200.
 
Last edited by a moderator:
  • #13
CaptainQuasar said:
you're a student you probably can qualify for a student discount of one of the commercial ones
If you're a student, first check with your local computing department if they don't have it available for you. At my university, we can just go and get a Mathematica installation CD and we are allowed to you the program for free (of course, the license is only valid while you are actually registered as a student).
 
  • #14
Each evaluation requires getting 4 constants from memory and doing maybe 10 bit operations (6 additions, 2 subtractions, 2 for some kind of shuffling around with registers), 8 multiplications, a square root, and two sines. If the sines and roots take 60 cycles and the multiplications take 10, and the floating point ops can run side-by-side with the integer ops, then you're talking at least 180 cycles, and possibly as many as 300 if everything is blocking and there's a lot of shuffling needed.

If you're varying the x coordinates and keeping the constants, um, constant, then each graph takes 8 * (180 to 300) * number of x points total cycles. For a thousand points that would be 1.4 to 2.4 million cycles; for ten thousand that would be 14 to 24 million. If you do nothing else, a 1 GHz processor core could do 416 to 714 (thousand) or 41 to 72 (ten thousand) refreshes per second. With a fast lookup table for sines and such this could be lower.

If you use the packed SSE instructions you could probably get a factor of 2 speedup as well.
 
  • #15
Hey, thanks for the information. Now I think I can lower the equations to about 16 of these:

f(x)=Asin[B(x-D)]+E+Fx

I found a much better idea to find when each collision occur. Instead of calculating each step to see if a point is touching a side, I can rather calculate WHEN it will occur, and at that t, the collision stage begin. So it's basically just those mentioned above, plus 32 equations which will only be calculated once. I think I could do it on my graphics calculator too (kind of slow though), if I only had two more spots for parameterised curves :\ I only have 6 spots, and I need 8.

I wonder, is there any way to get more variables than A to Z and theta? And I'd appreciate if someone told me how to get more spots on parameterised curves. I have a TI-84 Texas.
 
Last edited:

Similar threads

  • · Replies 30 ·
2
Replies
30
Views
8K
  • · Replies 26 ·
Replies
26
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
2K
Replies
19
Views
3K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K