![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2004
Posts: 32
Rep Power: 0
![]() |
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
__________________
<CENTER><span style='font-size:17pt;line-height:100%'>My Homepage</span></CENTER> |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
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. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Oct 2004
Posts: 32
Rep Power: 0
![]() |
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
__________________
<CENTER><span style='font-size:17pt;line-height:100%'>My Homepage</span></CENTER> |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
Ah... you mean ax^5 + bx^4 + cx^3 + dx^2 + ex = 0? I see... sounds complicated...
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0
![]() |
may i ask why you need this?
__________________
Don't wound what you can't kill |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Oct 2004
Posts: 32
Rep Power: 0
![]() |
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
__________________
<CENTER><span style='font-size:17pt;line-height:100%'>My Homepage</span></CENTER> |
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
Heh... sorry. That's my mind twisting things until they bear no resemblance to the original for ya.... be glad I'm not malicious
![]() |
|
|
|
|
|
#8 |
|
Programming Guru
![]() ![]() |
What Class? Pre-Calc? Or Calc?
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#9 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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;
}
__________________
"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." - Dwight D. Eisenhower |
|
|
|
|
|
#10 |
|
Hobbyist Programmer
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0
![]() |
This all brings back painful memoriesof A-level math
__________________
Don't wound what you can't kill |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|