Wikipedia:Reference desk/Archives/Computing/2013 May 2

From Wikipedia, the free encyclopedia
Computing desk
< May 1 << Apr | May | Jun >> May 3 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 2[edit]

Strange audio/video stuttering problems[edit]

Hi all. I've got a strong computer. An Intel i7 CPU and GTX 460M GPU seem pretty strong to me. And they often perform their duties admirably well. But they seem to trip up on really small things much of the time.

If I'm watching a video, the video may pause for a fraction of a second (with the audio still running normally), then skip ahead to where it would be if it hadn't paused at all. The intervening frames are either dropped, or played back very sped up. For example, if the video featured someone walking across the room, they would stop in place and then either teleport to the other side, or scurry over, their legs moving in a flurry. This can happen when watching any video online, and is particularly noticeable when watching videos on iTunes. However, I can't find any sort of common factor between occurrences. Sometimes it works just fine, other times it doesn't. One thing I'll mention is that I almost never see this problem happen with Crunchyroll's online video player, if that helps.

Both video and audio stutter when playing Minecraft, to an unacceptable degree. However, this only happens when the sound is on. For example, let's say I start the game up, and am standing where I last left off. Upon the first step I take, the game will freeze for about a second, and then the player character will slowly move forward, and the sound of walking on the surface I'm on plays. This freezing happens with every "new" sound that the game has to play back. That is to say, if I haven't walked on grass since starting the game, the first time I walk on grass will be rife with stuttering gamplay as each walking-on-grass sound is played for the first time. However, it still has a tendency to happen, to a lesser degree, with any sound. The game still seems to be running when it's frozen; time-sensitive processes will continue. For instance, Creepers are enemies that explode when you stand near them for too long. Several times I've run up to a Creeper and had the game freeze for a moment from either the sound of the Creeper starting to hiss, or me attacking the Creeper, or both. When the game unfreezes, the Creeper explodes, essentially making it instantly detonate when I try to attack it. Turning sound off in Minecraft's options mostly eliminates this problem, but I would like the sound back.

Left 4 Dead 2 has problems as well, but they manifest in a different way. "New" sounds that haven't been played before have a delay for when they should play. For example, if I pick up a shotgun and fire it, the first time I fire it will have the sound of its blast delayed for a second. It works normally for the rest of the game after that. This goes for all guns, grenade sound effects, and possibly others that I can't notice as well. This effect also manifests itself in the menu. When scrolling through menu options, the whole game stutters for a second if I scroll over something that has not been previously accessed. I can't move the cursor during that time, and the audio repeats a very short loop several times. For example, if the menu music had someone speaking in it, saying something like "Please include your system specs" and I scrolled over something in the middle of the sentence, I'd hear "Please include your clude your clude your clude your system specs." This happens to a lesser degree while playing BioShock.

I really don't know what to make of this. This is supposed to be a fairly strong computer, but it feels like its shoelaces have been tied together with these problems. I've tried updating my drivers through NVIDIA's Web site, but I feel like incidence of screen tearing during video playback only increased for a few weeks after doing so. What do you think could be the cause? What can I do to fix this?

Windows 7 Home Premium, Service Pack 1

Intel Core i7-2630QM

NVIDIA GeForce GTX 460M

Thanks for your time.--The Ninth Bright Shiner 02:49, 2 May 2013 (UTC)[reply]

(Oh, and one thing I forgot; timing for things spoken by the survivors in Left 4 Dead 2 can be pretty off. A survivor might make the relieved "ahhh" sound right before they actually take their pain pills. Speech might get cut off: instead of Ellis saying "That man is an American hero," he'll just say "That man is an American" and get cut off.--The Ninth Bright Shiner 02:54, 2 May 2013 (UTC))[reply]

I'm getting the impression that your worst problems are with audio. What sort of audio setup do you have on the system? (See Control Panel->Hardware and Sound->Sound->Manage Audio Devices, in case you have trouble finding it.) Looie496 (talk) 03:09, 2 May 2013 (UTC)[reply]
Conexant SmartAudio HD?--The Ninth Bright Shiner 03:34, 2 May 2013 (UTC)[reply]
Sounds a lot like a hard drive problem to me. Loading new sounds/assets into memory will freeze up the game since if waits on the (irregularly long) read, or the sound will play late and be cut off since it took too long to load. You should run a SMART diagnostic. 198.168.234.223 (talk) 19:28, 3 May 2013 (UTC)[reply]
I used Passmark's disk checkup. How do I interpret the data it gives me? Thanks for your help.--The Ninth Bright Shiner 02:50, 6 May 2013 (UTC)[reply]

Graphics with Java: Applets and Applications[edit]

I am trying to convert a java applet to a java application. I have done all the conversions i needed, including changing the content pane to a JFrame. However, it seems the paint method doesnt work. I'm not sure what im doing wrong, but im guessing applications deal with painting differently. Does anyone know what is wrong? If it is necessary, i am willing to post the source code. The main class still extends JApplet, which i wonder if its part of the problem or not.

Again, let me know if posting some source code is needed.

137.81.118.126 (talk) 05:56, 2 May 2013 (UTC)[reply]

Make sure you're adding children to the JFrame's contentPane, not to the JFrame itself, as shown in the JFrame javadoc page. While you can try to use JApplet inside a JFrame, without someone implementing all the stuff that an AppletContainer provides, all the utility methods in java.applet.Applet (e.g. getImage) don't work. Personally I'd recommend you don't use JApplet like that, and instead change your code to extend a JContainerJPanel instead. If you want to post your code for others' review, I'd recommend you post it at pastebin and only post the URL of that here; but make sure your code compiles with no warnings before you do that. -- Finlay McWalterTalk 07:01, 2 May 2013 (UTC)[reply]

I tried to change to extending JFrame JPanel, with no luck. The program unfortunately has a few classes if you are wanting to have it compile entirely. I will get to working on it. 137.81.118.126 (talk) 07:26, 2 May 2013 (UTC)[reply]

I sounds like you're trying with too complicated an example, and probably people won't be interested in helping you debug a whole application. It's much easier for people to help you if you can reduce your problem to a single class; often the practice of doing this will let you see the problem yourself. -- Finlay McWalterTalk 07:40, 2 May 2013 (UTC)[reply]

The source is all available now. I tried to make pretty decent comments noting the division between files. There are 5 classes, "Application", "Attractor", "Build", "Main", and "MouseListen".

http://pastebin.com/kkSj4zZJ

Edit: The only problem is within the painting of things. It wont involve digging into the "Build" class, for instance, which has nothing to do with the issue.

Edit 2: If the painting of things is fixed, instead of a gray empty area on the left, there should be a purple background with a gray dot you can drag around.

137.81.118.126 (talk) 07:42, 2 May 2013 (UTC)[reply]

You've gotten into a muddle because Application extends JFrame, but then in its init you create a new JFrame. You never display the Application, only the new-ed one, and your paint methods are on the frame you never display. So there's no painting. As a hack, you can see this by changing the line
        Frame frame = new JFrame("Attractors v2.0");
with
  
        JFrame frame = this;
and you get repainting. But really you should change Application.init() to be the constructor of the Application class. -- Finlay McWalterTalk 14:51, 2 May 2013 (UTC)[reply]
Incidentally, painting on the same JFrame that you're hosting widgets on is, while it works, confusing. You'd be much better off created another widget (e.g. AttractorCanvas extends JPanel), adding it to the JFrame (BorderLayout.West) and having all the painting in there). Right now your Application.paint() call applies for the whole Application, which means it can paint over the controls on the left (if the clip is so set). Another incidental thing (I know you didn't ask for a full code review, but since I'm here...) your paint method gets much more readable if you use an iterator:
    @Override
    public void paint(Graphics g) {
	g.setColor(bgCol);
        g.fillRect(0, 0, 500, 500);

        for(Attractor item: attArr){
            int d = item.getR()*2;
            int x = item.getX();
            int y = item.getY();

            g.setColor(Color.LIGHT_GRAY);
            g.fillOval(x, y, d, d);
            g.setColor(Color.DARK_GRAY);
            g.drawOval(x, y, d, d);
        }
    }
-- Finlay McWalterTalk 15:36, 2 May 2013 (UTC)[reply]


Finlay, your analysis of my program has been most helpful! I have made most of your changes, except for having the separate drawing pane, and reorganizing the paint method. I deleted the frame that is unneeded, and anywhere i used to reference "frame" i use "this" now. Ex: this.setSize(960,510); ..........

The images now show properly, but when i use things from the MouseListen class, they dont update the screen appropriately. The MouseListen class takes in Application by reference and calls its "repaint" method. Again perhaps im not familiar enough with applications as opposed to applets, but this appears to do nothing. How could i fix this issue? 137.81.118.126 (talk) 18:52, 2 May 2013 (UTC)[reply]

It's nothing to do with applications vs applets; you're either not receiving the events because you've not listened on the correct control, or you're sending repaints to the wrong control. Your code is overcomplicated and distributes responsibility for control in a weird way. You should refactor it, with a single JPanel responsible for storing the Attractors, rendering them on itself, and handling its own painting and repainting. -- Finlay McWalterTalk 20:16, 2 May 2013 (UTC)[reply]

..a decent point. I will attempt to merge MouseListener class with the Application class.

Edit: I dont think this is possible because MouseListener extends MouseInputAdapter, and my application already extends JFrame. Java cant allow one class to extend two other classes. Not sure what to do but i see your point that power over the application is spread out.

137.81.118.126 (talk) 20:29, 2 May 2013 (UTC)[reply]


I have had a look at debugging and all the paint methods work perfectly, there is just a different bug, and im confident i can fix it. Thank you for your help!

Resolved

137.81.118.126 (talk) 22:31, 2 May 2013 (UTC)[reply]

is there software that can determine a person's race[edit]

from their name? — Preceding unsigned comment added by 119.74.102.57 (talk) 09:14, 2 May 2013 (UTC)[reply]

Obviously not, since anyone can change their name to anything they like. Even if you assume the input is a person's birth name, the most that could be achieved is a probabilistic guess at their parent's ethnic and cultural background (and note that this is not the same as their race) e.g. the parents of Dermot O'Leary are probably Irish. Gandalf61 (talk) 09:28, 2 May 2013 (UTC)[reply]
As just a case in point, compare George Clinton and George Clinton. --Mr.98 (talk) 15:44, 2 May 2013 (UTC)[reply]
Race isn't something that can be 'determined' at all. It is a social construct - an arbitrary subdivision of humanity based on local cultural distinctions, rather than anything more concrete. One only has to look at the almighty tangles that apartheid-era South Africa got into trying determine who was 'what' to see that it is impossible to define objectively. It is also worth noting that those who have attempted to justify the subdivision of humanity into 'scientifically defined' races have singularly failed to even agree amongst themselves as to how many there are, never mind how you determine membership. AndyTheGrump (talk) 16:06, 2 May 2013 (UTC)[reply]
Just because something can't be neatly categorized doesn't mean it's arbitrary or meaningless. You might as well say languages are arbitrary social constructs (why are Swedish and Danish separate but not High German and Vorarlbergerisch???). We certainly can't agree on how many languages there are either. That doesn't make the concept any less meaningful or useful. That being said - yes, the original poster's question is certainly impossible. -Elmer Clark (talk) 22:45, 2 May 2013 (UTC)[reply]
You misunderstand. Genetically, you cannot group humanity into more than one subspecies (race). All humans are the same race -- Homo sapiens sapiens. Homo is the genus; sapiens is the species, and sapiens is the race. We try to group humans into races using skin color and facial characteristics, but this method fails when you realize that people with the same skin color vary more genetically among themselves than between any other grouping. Humans are remarkably similar to each other genetically compared to other animal species. The other human races died out tens of thousands of years ago.—Best Dog Ever (talk) 05:49, 4 May 2013 (UTC)[reply]
I once met an Asian man named Laquisha Brown and asked him how he got that name. He explained that he was waiting in line at immigration, the immigration officer asked the woman in front of him her name, she said "Laquisha Brown", and the immigration official wrote it down on her papers. When it was his turn and they asked his name, he said Sam Ting, so they wrote down Laquisha Brown on his forms too. :-) StuRat (talk) 18:18, 2 May 2013 (UTC) [reply]
Two can play at that game, my friend!
I once met a German man named Sean Ferguson and asked him how he got that name. He explained that he had been advised to give the immigration officer a good American name, like John Smith, so he patiently stood in line repeating "John Smith, John Smith", but when he got to the front of the line he was so nervous it slipped his mind, and he said "Ach! Ich habe schon vergessen!" and Sean Ferguson he became.Gzuckier (talk) 21:22, 3 May 2013 (UTC)[reply]
Bonus: You ever wonder if Ang Lee got his name because he became irritated waiting in line at immigration and told the officer he was angry? Gzuckier (talk) 21:24, 3 May 2013 (UTC)[reply]
Perhaps to give a more useful answer to this, the study of where names come from is a serious one. It has its own name, but I can't recall it right now. (Google isn't helping me much.) While, as pointed out above, some names are no help at all in determining someone's ancestry, many still are. Mine happens to be. It's a name typical of where my predecessors came from. Books have been written on this topic. Part of determining this is a fairly mechanical process. I can imagine the contents of such books being turned into software that could at least act as a potential guide to discovering someone's ancestry, but I've never heard of any. (I won't use the word race here. Again, for many reasons including some outlined above, it's inappropriate.) HiLo48 (talk) 03:50, 4 May 2013 (UTC)[reply]
Onomastics? Asmrulz (talk) 21:59, 6 May 2013 (UTC)[reply]
Friend of mine tells of having an Asian-American roommate in college, who often spoke of "Grandmother Wong" who ruled the family with an iron fist. Anyway, eventually came a visit to roommate's home over vacation, and Grandmother Wong turned out to be an Italian woman who had married Grandfather-to-be Wong many years ago. Gzuckier (talk) 04:37, 5 May 2013 (UTC)[reply]
Maybe the OPs question has a simpler answer. If the name is a unique key into a database (or there is secondary information), and that database stores a race attribute (no matter how scientifically valid or invalid that assignment) for each data set, then yes, there is such software. --Stephan Schulz (talk) 22:39, 7 May 2013 (UTC)[reply]

Making a single page of a section landscape in Word[edit]

I'm using Microsoft word for a document with a set of drawings at the end, which are numbered separately from the main pages (in the form X/Y, {Page}/{SectionPages} ). I want to make a single page of the drawings landscape, but the only way I know how to do that is by making a new section for the landscape page, so {sectionpages} doesn't work any more. Is there any way to either:

  • Change {sectionpages} so that it shows the total of the last (n) sections (i.e. to include the portrait and landscape sections)
  • make a single page landscape without changing section?

Unfortunately, the landscape part has to be in the middle of the drawings, and I'm likely to be editing either side of it, so I can't even just fudge it for all but the last section, and then use ={sectionpages}+Z for the final section. many thanks MChesterMC (talk) 14:50, 2 May 2013 (UTC)[reply]

Follow up on this, I've worked around it my using {= {NUMPAGES} - {PAGEREF Bookmark}}, with the bookmark set at the last page of the previous section. It only works because I have only two sections total (the main document and the drawings), but it's good enough! A better solution would still be appreciated, since if this document gets amended and I have to insert more pages (which will go in as e.g. 5, 5a, 5b, 6) it will break the formatting again MChesterMC (talk) 09:32, 3 May 2013 (UTC)[reply]

"SecuROM" in The Sims 2/3[edit]

I recently bought The Sims 2 Deluxe the The Sims 3 Deluxe, after a long time with only The Sims 1 (Complete Collection). Only about purchasing the games, but not installing them yet, I read about the games and learned that they included something called "SecuROM" which a lot of people find horrible. In my research, SecuROM could cause problems to your PC in some cases. Why would Maxis/Electronic Arts knowingly release a game with such technology, and should I be worried about installing it? Thanks! -- 143.85.199.242 (talk) 16:58, 2 May 2013 (UTC)[reply]

Reading our SecuROM article will probably give you more information than any answer here could. Looie496 (talk) 17:05, 2 May 2013 (UTC)[reply]
I actually did read Wikipedia's article; apparently there are multiple versions, some with differing bad characteristics. I'm looking for advice on what the SecuROM included with Sims 2 Deluxe and Sims 3 Deluxe would do to my PC, if anything. -- 143.85.199.242 (talk) 22:58, 2 May 2013 (UTC)[reply]
I've installed the Sims 3 before and I didn't notice any kind of DRM (other than needing the DVD to play) but it's been a while, and I didn't look very hard to see what it did to the cpu. Shadowjams (talk) 22:44, 3 May 2013 (UTC)[reply]
I've used the electronic SOED, which install SecuROM (presumably v7.1, because it creates files names securom_v7_01.* - which may be quite old; the disk was published in 2007),and I've not had any problems with it on either 32-bit Windows XP Pro or 64-bit Windows 7. There is no online authentication or registration. The DVD needs to be inserted the first time the program is run per-user on any given PC. Naturally I've only ever had it installed on one PC at a time :-) Mitch Ames (talk) 12:41, 6 May 2013 (UTC)[reply]

Pokemon, 3rd gen. celibi[edit]

Hello. So I've heard that the only way to obtain Celibi without cheating is to transfer it from the Japanese Pokemon Colosseum pre-order bonus disk. Can you load this Japanese monster to the American Ruby, Sapphire, FR, LG or Emerald? And as a bonus, how rare are these disks and about how much do they go for? --JadeGuardian (talk) 19:29, 2 May 2013 (UTC)[reply]

Uhh, hello? --JadeGuardian (talk) 21:10, 2 May 2013 (UTC)[reply]
You allowed two minutes between when you asked your question and when you posted about your impatience. There aren't Pokemon experts manning this desk 24/7. If anyone can supply the answer, they may in fact do that but getting pissy with the readers here will not really encourage them to assist you. That said, you may be able to get an answer more quickly on a specialized Pokemon forum or message board. To me, your question seems rather obscure and specific, so a specialized forum may be your best bet. Dismas|(talk) 21:18, 2 May 2013 (UTC)[reply]
Actually, I posted this much earlier, but came back because I forgot to add the signature. --JadeGuardian (talk) 21:22, 2 May 2013 (UTC)[reply]
Unfortunately, you can't. The Japanese disk only works with Japanese game carts (according to Bulbapedia; I haven't done it myself - I've been an AR user since the beginning! :) ) As for the price, eBay states a price window of $25-$75 but that is for both versions together (English and Japanese) - if you are interested in a Jirachi or are willing to purchase a Japanese version of one of the games, that is! --Yellow1996 (talk) 23:56, 2 May 2013 (UTC)[reply]

Checking my mac's memory usage[edit]

 Model Name:	             iMac
 Model Identifier:	        iMac11,3
 Processor Name:	        Intel Core i5
 Processor Speed:	        2.8 GHz
 Number Of Processors:	        1
 Total Number Of Cores:         4
 L2 Cache (per core):	        256 KB
 L3 Cache:	                8 MB
 Memory:	                8 GB
 Processor Interconnect Speed:	4.8 GT/s
 Boot ROM Version:	        IM112.0057.B00
 SMC Version (system):	        1.59f2

Is there a way to check what percentage of my computer's memory is filled up? I have tried system profile but it just tells me how much memory I have in total, per above, 8 GB. Also, can anyone tell me how much memory I can use up without it significantly affecting my performance?--108.54.26.164 (talk) 22:48, 2 May 2013 (UTC)[reply]

Try the "Activity Monitor" (Applications > Utilities). The "system memory" tab shows you lots of RAM information. Green is totally free, blue is "recently used" which means it is technically free but sometimes the OS doesn't free it up in a timely way (you can run the "purge" command in the Terminal to manually force it to free that up, if you're into that kind of thing), red is "used by really important processes" and yellow is "used by regular programs." More or less.
As for performance issues... basically if you drop down to levels where your machine needs RAM you don't have available, it will use virtual memory, aka hard drive space. This slows things down a lot because hard drive reads and writes are slow compared to RAM. Under the aforementioned "System memory" tab, look for the "swap used" item. If it is more than just a tiny amount, then you're running into performance issues based on not enough RAM free. Otherwise, your performance issues are probably not RAM related. --Mr.98 (talk) 00:23, 3 May 2013 (UTC)[reply]
Thanks Mr.98. It says "Swap used: 261.7 MB" Does that ring any alarm bells for you? I know you said if it's more than just a tiny amount..., but when we're talking about 8GB, is 261 a lot? Most of my memory is taken up with video storage btw. Maybe I should put a lot of it on an external drive (they're fairly cheap) and off the computer's hard drive?--108.54.26.164 (talk) 01:16, 3 May 2013 (UTC)[reply]
Blue is actually better described as "a good candidate for swapping out to disk": it's memory that a program has indicated it's using, but hasn't actually touched in a while. --Carnildo (talk) 02:55, 3 May 2013 (UTC)[reply]
Mmm, that's not really what Apple says about it. "This information is in RAM but it is not actively being used, it was recently used. For example, if you've been using Mail and then quit it, the RAM that Mail was using is marked as Inactive memory. Inactive memory is available for use by another application, just like Free memory. However, if you open Mail before its Inactive memory is used by a different application, Mail will open quicker because its Inactive memory is converted to Active memory, instead of loading it from the slower drive."
As for swap... how much do you have in the "Page outs" category? My feeling is that a quarter of a gig of swap is kind of a lot. Not a ridiculous amount, but it indicates you are hitting your memory limits more often than one would expect to with that much RAM. As for your use of the hard drive space, it doesn't really matter to this question. Whether your hard drive is empty or full isn't what is at issue here. --Mr.98 (talk) 13:01, 3 May 2013 (UTC)[reply]
Page outs is listed as 1.79 GB. Maybe I have this happening because I sometimes download many videos at once, and that puts a strain on the system?--108.54.26.164 (talk) 12:54, 5 May 2013 (UTC)[reply]

On the accuracy of floating point[edit]

I have a program that must complete the operation 18abcd - 4b3d + b2c2 - 4ac3 - 27a2d2, where a = 10.648, b = 638.88, c = 12777.6, and d = 85184. Both Wolfram Alpha and Google's calculator confirm that the answer is 0, but the program returns 0.00390625, which skews all its other results. Why is this and/or how can I fix it? I've checked the syntax very thoroughly, and it isn't the problem. Pokajanje|Talk 23:01, 2 May 2013 (UTC)[reply]

see Floating point#Accuracy problems. If you know the answer is zero, why do you need to calculate it? AndyTheGrump (talk) 23:06, 2 May 2013 (UTC)[reply]
It's part of a function with the four arguments a, b, c, and d. I was testing it and discovered the flaw with those numbers, and I can't possibly make an exception for every case like this. Pokajanje|Talk 23:24, 2 May 2013 (UTC)[reply]
If you want exact results every time, you can't use floating point numbers. AndyTheGrump (talk) 23:33, 2 May 2013 (UTC)[reply]
If I can't use floating point numbers that will render the whole program useless. Pokajanje|Talk 23:37, 2 May 2013 (UTC)[reply]
Is it essential that you always get exact results? AndyTheGrump (talk) 23:42, 2 May 2013 (UTC)[reply]
Yes. Pokajanje|Talk 01:47, 3 May 2013 (UTC)[reply]
Then, as has been pointed out correctly, you cannot depend on floating point. Floating point math can introduce numerical error. You can learn very advanced theoretical mathematical techniques that reduce that error in general; and you can learn advanced practical techniques that reduce the error for common applications (for example, by reading Numerical Recipes, most of which is available for no cost online at nr.com). You can increase the bit-depth of your floating point (to 64-bits, and in some computers, to 128 bits), but that doesn't guarantee you wont have floating-point error or other algorithmic error. You can learn about arbitrary-precision arithmetic; fixed precision calculations, and symbolic algebra systems. But ultimately, if you must prove that a computation has exactly zero error (... because almost exactly zero error isn't good enough! - mathematics is very pedantic!)... then you need to really really really deep dive into the theory of solving equations. Nimur (talk) 03:02, 3 May 2013 (UTC)[reply]
It sounds like you'll want to look into using an arbitrary-precision arithmetic library: it'll be much slower than native floating point, but it will avoid rounding issues. You should probably also re-consider your requirements and/or talk to someone with experience in numerical analysis, because having problems with rounding errors is usually a sign you're doing something wrong. --Carnildo (talk) 03:02, 3 May 2013 (UTC)[reply]

And, it's very easy to do something wrong without even realizing it. You don't need a complicated algorithm or invalid syntax! Consider the obvious approach to accumulating (adding one) to a floating-point variable:

Naive accumulator algorithm to demonstrate floating point error
#include <stdio.h>
#include <limits.h>
int main() 
{

  float x = 0;
  int i;
  const int max = 100000000;
  for (i = 0; i < max; i++)
     x += 1;
  
  printf("x=%f   max=%d \n", x, max);
  
  return (x == max);
}

The naive approach works on my computer - as long as max is less than something like 16.7 million! And the problem isn't with the syntax; that is perfectly legal C code instructing a computer to increment a value by one a lot of times. Hm... what's special about 16.7 million... might it be almost exactly equal to 224, where 24 is the bit-length of the mantissa of an IEEE 794 32-bit float? Take a look at the Kahan summation algorithm for the most straightforward error-reduction algorithm for floating-point accumulators. The original post was a request for a sort of polynomial solver - which is a lot more mathematical operations than an increment! It's just a direct computation, but it will suffer from the same numerical problems that a root-finder suffers. You'll want to read and learn all about those, and some of the numerous methods for solving those equations. If you study numerical methods, you'll independently discover that these methods don't work on all your favorite polynomials (... if you have no favorites, your professor will find some new ones for you). Nimur (talk) 03:26, 3 May 2013 (UTC)[reply]

In [1] Kahan spends twenty pages on various problems with the usual formula for the roots of a quadratic equation and various ways of fixing them so you don't lose too much precision. This type problem is the impetus for Interval arithmetic so one could get some sort of error bound easily.. Dmcq (talk) 11:32, 3 May 2013 (UTC)[reply]

Each of your terms evaluates as something of the order of 1e+13 to 1e+14. With standard (32 bit) floating point arithmetic you get roughly 16 digits of accurracy. If you take the difference between two numbers of order 1e14, you therefore have to expect error of the size 1e-2. That is exactly what you are getting. If the correct result of your calculation is also of the order of 1e+13 (as it will be for most similar choices of a, b, c, d) the error of 1e-2 is acceptable. Just when the result is close to 0, you have a problem. So: either use more than 32bit floats (quadruple precision, arbitrary precision), or rearrange your equation, so that you don't take differences of such large numbers. Not easy in your case, but for example evaluating as a(18bcd-4c^3-27ad^2) - 4b^3d+b^2c^2 on octave returns 0, whereas your original formula gave 0.00390625. Note that this rearrangement still takes differences of number of order 1e+13 (rather than 1e+14), so its success is probably due to luck. Generally you will have a very hard time to reduce the calculation error below 1e-2 when terms of the order 1e+14 are involved. 86.136.42.169 (talk) 23:07, 3 May 2013 (UTC)[reply]

Rearranging it as 18abcd + b2c2 - (4b3d + 4ac3 + 27a2d2) and using double precision works for me. However, if some of a, b, c, and d are the right negative numbers, you will probably still have the problem. (This sounds like a homework problem for a numerical analysis course.) Bubba73 You talkin' to me? 05:31, 5 May 2013 (UTC)[reply]
The requirement to get exact results when the numbers put in are approximate is a bit odd, after all is it really true the number 10.648 is an exact measurement in decimal? If that is really the requirement then the easiest way is to use an arbitrary precision decimal math package. Otherwise one really needs to figure out exactly how precise the results need to be. One can't in general depend on results being better than single precision after doing a lot of double precision maths and it can turn out worse. Here you need to have 20 decimal digits or more to hold the intermediates if anything straightforward is done and as said above normal double precision only holds about 16 digits and then in binary. Dmcq (talk) 13:18, 5 May 2013 (UTC)[reply]