Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 17th, 2004, 1:37 PM   #1
dnathe4th
Programmer
 
Join Date: Oct 2004
Posts: 32
Rep Power: 0 dnathe4th is on a distinguished road
What would the easiest way to go about scripting, or writing a program, that output all the (positive) solutions to a 5dimensional problem?
for instance:
(1/2)A + (1/4)B + (1/8)C + (1/16)D + (1/32)E = 1/2
__________________
&lt;CENTER&gt;<span style='font-size:17pt;line-height:100%'>My Homepage</span>&lt;/CENTER&gt;
dnathe4th is offline   Reply With Quote
Old Oct 17th, 2004, 3:13 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
I take it you mean (1/2)x + (1/4)x + (1/8)x + (1/16)x + (1/32)x = 1/2. The solution is to parse it into some sort of array or something that holds all the info, and then rearrange the equation I know this doesn't really help, but there's more . Apparently Perl is brilliant for this sort of thing - look it up.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Oct 17th, 2004, 3:36 PM   #3
dnathe4th
Programmer
 
Join Date: Oct 2004
Posts: 32
Rep Power: 0 dnathe4th is on a distinguished road
I used different letters rather than "X" because each variable needs to be different based on the coefficient. I'll get back to this post once i work it out
__________________
&lt;CENTER&gt;<span style='font-size:17pt;line-height:100%'>My Homepage</span>&lt;/CENTER&gt;
dnathe4th is offline   Reply With Quote
Old Oct 17th, 2004, 5:36 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Ah... you mean ax^5 + bx^4 + cx^3 + dx^2 + ex = 0? I see... sounds complicated...
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Oct 17th, 2004, 5:44 PM   #5
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
may i ask why you need this?
__________________
Don't wound what you can't kill
Ade is offline   Reply With Quote
Old Oct 17th, 2004, 9:24 PM   #6
dnathe4th
Programmer
 
Join Date: Oct 2004
Posts: 32
Rep Power: 0 dnathe4th is on a distinguished road
Ooble, i mean as in :
(1/2)A + (1/4)B + (1/8)C + (1/16)D + (1/32)E = 1/2
as stated in my first post

Ade: It was a homework assignment for my brother (he's 12, i think they were just supposed to guess the answer), and being the programming dood i am, i wanted to figure out if it could be done by a program, since most things can, but i didn't know where to start, so i came here
__________________
&lt;CENTER&gt;<span style='font-size:17pt;line-height:100%'>My Homepage</span>&lt;/CENTER&gt;
dnathe4th is offline   Reply With Quote
Old Oct 18th, 2004, 12:02 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Heh... sorry. That's my mind twisting things until they bear no resemblance to the original for ya.... be glad I'm not malicious
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Oct 18th, 2004, 5:39 PM   #8
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
What Class? Pre-Calc? Or Calc?
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Oct 18th, 2004, 5:56 PM   #9
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I'm guessing you mean all integers for values A, B, C, D, E. I just limited this to a 10 due to time constraints. I'm not sure this is what you want, but run this and tell me:

#include <stdio.h>
                                                        
int main(void)
{
    int a, b, c, d, e;
    FILE *fp;
    fp=fopen("answers.dat", "w+");
    for(a = 0; a<10; a++)
    {
        for(b=0; b<10; b++)
        {
            for(c=0; c<10; c++)
            {
                for(d=0;d<10;d++)
                {
                    for(e=0;e<10;e++)
                    {
                        if(((.5*a) + (.25 * b) + (.125 * c) + (.0625 * d) + (.03125 * e)) == .5)
                        {
                            fprintf(fp, "a=%d\nb=%d\nc=%d\nd=%d\ne=%d\n\n", a, b, c, d, e);
                        }
                    }
                }
            }
        }
    }
                                                        
    return 0;
}
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Oct 19th, 2004, 5:05 PM   #10
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
This all brings back painful memoriesof A-level math
__________________
Don't wound what you can't kill
Ade is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:11 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC