PlaneShift

Fan Area => The Hydlaa Plaza => Topic started by: RussianVodka on December 10, 2004, 03:58:00 am

Title: I R0XX0RZ T3H \/\/0rLd 'o PrOgRaMiNg!!!!11!!!one!oen!!!11!!
Post by: RussianVodka on December 10, 2004, 03:58:00 am
Sorry for the leet... I got over excited...

Ahem!

Last week, after about 2 hrs of work i created a program that solves quadratic equations... It was crude, and crashed in MANY cases, but it was just a test to see if i can get the basic code to work.

Over the past two days, i have been working for a grueling 4-5hrs and have created the second and probably final version of the program \"Quadratic Solver v2.0\".

I need to get it out on the web and excersize my braging rights, but i dont know of any websites that would sponser my download...

I\'m thinking of editing the code a bit, so it gives away my email instead of my name, and trying to submit it to www.downloads.com.

If any of you know of any other websites that might host it? Or just a website like photobucket where i can dump my code?
Title:
Post by: Efflixi Aduro on December 10, 2004, 05:53:19 am
*looks up*
Haa le Loo ya! Haa le Loo ya!
*sky gets brighter*

In like two chapters im gonna be doing quadratic functions in my algebra 2 class! Somone up there loves me :)
Tell me once the program is ready. I could \"test\" it for you :)

Wow these past two weeks luck has been on my side...

EDIT there not hard but its good to have a helper right next to you :)
Title:
Post by: Ghostslayer on December 10, 2004, 06:36:54 am
You could just zip the file and throw it up here (http://upl.silentwhisper.net/)

Just kind of curious, is it just the basic command prompt type program?  Since you said it crashed in many cases before, did you fix it up to do all cases of (imaginary/real numbers)?

Which language did you program it in by the way?

I remember doing one of those programs back when I took a C++ class... good practice.
Title:
Post by: ArcaneFalcon on December 10, 2004, 08:26:16 am
Heh, I remember making a quadratic solver with the (crappy version of) basic language that comes on TI calculators.  If I remember correctly it could even do \"i\" stuff (root of negative numbers) but that was built into the calculator and wasn\'t a result of my (inefficient) programming skills.

:emerald:
Title:
Post by: RussianVodka on December 10, 2004, 05:06:08 pm
The program does real numbers, and it sorta does imaginary numbers.
Here is what the answers are like:

Real rational: Gives two values.
Real irational: gives two somewhat simplyfied formulas.

Imaginary rational: gives two formaulas as \'(a+bi)/x\' also simplyfies if both \'a\' and \'b\' are devisible by \'x\'.
Imaginary irational: Gives the formula with the \'i\' value.


I\'m using this formula as the basis for the program-

-b +- (b^2 - 4ac)
------------------        = X
           2a


\'+-\' = plus minus (as in the there are two answers, one with the formula having a plus, the other with the formula having a minus.)

EDIT: I\'ll upload when i get home.
Title:
Post by: Harkin on December 10, 2004, 09:37:05 pm
the  quadratic equations sucks... right behind proofs and completing the square... but in general I hate any long math problem.... stupid math... and its numbers... and who decided to add letters anyway? stupid number/letter thingy...
Title:
Post by: Ghostslayer on December 10, 2004, 11:31:10 pm
Quote
Originally posted by Harkin
the  quadratic equations sucks... right behind proofs and completing the square... but in general I hate any long math problem.... stupid math... and its numbers... and who decided to add letters anyway? stupid number/letter thingy...


Quadratic... long?!? um yea.  I should show you some real equations sometime :P

Anyway, math is useful and so are variables, but I doubt you\'ll believe me about that.

RussianVodka: Just post when you have it loaded somewhere and I\'ll test it out for ya.
Title:
Post by: Harkin on December 11, 2004, 12:17:39 am
i meant long as 4-6 lines on notebook paper... i can do moderate to hard problems of the sort in anywhere from 1-2 minutes

for a note: just because I hate math doesnt mean I\'m not good at it... actually I excell in math
Title:
Post by: Icefalcon on December 11, 2004, 01:10:20 am
Quote
Originally posted by Ghostslayer
Quadratic... long?!? um yea.  I should show you some real equations sometime :P

Er... no kidding. Thats basic algebra...

I tried to create a program on my TI-83 Plus... it didn\'t turn out so well... The only way I can make a program on my calculator is with a step by step instruction in my book.

Klyaksa, can\'t wait to see how it works.  8)
Title:
Post by: faldrok on December 11, 2004, 04:06:33 am
Icefalcon: I can\'t believe you wasted $100 on a friggin\' calculator!! And, that is the type of calculator that can do everything for you...what a shame. In America, you don\'t need to know how to do anything in Math...the calculator can do it for you!!

I stick by my $1 calculator. I just use it when I don\'t have the time to work out 237*543. Other than that, I do it myself...pfft, super calculators.
Title:
Post by: Icefalcon on December 11, 2004, 04:19:05 am
Quote
Originally posted by faldrok
Icefalcon: I can\'t believe you wasted $100 on a friggin\' calculator!! And, that is the type of calculator that can do everything for you...what a shame. In America, you don\'t need to know how to do anything in Math...the calculator can do it for you!!

It was required for my classes. There are things that you need it for, believe me...
Title:
Post by: RussianVodka on December 11, 2004, 05:00:35 am
*drum roll*


Ta da! Here it is:

http://upl.silentwhisper.net/uplfolders/upload9/X_finder.exe

Just click on the link to download.
Title:
Post by: ArcaneFalcon on December 11, 2004, 05:04:42 am
Faldrok:  You couldn\'t be more wrong.  When you\'re doing things like finding points of inflection you don\'t want to be wasting your time doing the graph of the first and second derivative.  The things we use those calculators for are the simple yet time consuming things that simply slow us up.  It turns a 20 minute problem into a 10 minute problem (which comes in handy when you have 10 of those problems).  Not only that, but I can program it to do things like empirical formulas, trig stuff (law of cosines, etc.) and other monotanous stuff that I could easily do on my own but simply don\'t want to waste my time with.  Not only that, but often times teachers will require them for upper level math courses.

:emerald:
Title:
Post by: DepthBlade on December 11, 2004, 06:06:18 am
Wow I could have used this about a year and a half ago! *jumps in his time machine*
Title:
Post by: Ghostslayer on December 11, 2004, 07:55:05 am
Looks good RussianVodka, only thing I found that crashes it is if you input any sort of illegal character (ie letters/symbols).  It looks like it sends it into an infinate loop.
Other than that, looks pretty good, well done :)

Faldrok: Just like ArcaneFalcon said, they are necessary sometimes.  I purchased one of those in high school when it was required.  There is was pretty pointless, but I need it more and more now.  For some of the things I do, I either need a calculator like that or some sort of math software (Maple / Matlab / Polymath or whatever) in order to get a solution I need.
Title:
Post by: Efflixi Aduro on December 11, 2004, 08:29:35 am
It doesnt work with variables. Is it supposed to?
Title:
Post by: RussianVodka on December 11, 2004, 02:45:46 pm
It crashes if you put in characters, it also crashes if you put in numbers like \"3.4\". I could fix that very easily, but i would rather have you find the least common multiple, and put them in like that. Technicaly thats the way you are suposed to to quadratic funcions.

If the above makes no sence... Its cuz i just woke up.
Title:
Post by: Keknehv on December 11, 2004, 06:19:49 pm
RussianVodka: If you post up the source, we could pretty easily clean it up/give advice,etc.

And you know what the funny thing is? I made a program almost like this on a really stupid $10 calculator.

The only reason that I could do it was because the calculator has \"history\". So I would enter each variable by hand, then I would go up on the history to the two bits for the quadratic formula (one for the -b/2a, another for the sqrt(b^2-4ac)/2a)... Yah... it\'s a pain.

Also, consider putting a WxWindows framework around your program. If there\'s anything that people really love in a program, it\'s certainly UI.

Maybe you could even have your program show the two roots, eh? (instead of just the formulas--most of usually can get that anyways)
Title:
Post by: RussianVodka on December 11, 2004, 06:55:46 pm
If there are two [rational] roots, it will show them. But most equations dont have those...

try-
A=1
B=-5
C=6
Title:
Post by: Keknehv on December 11, 2004, 07:36:53 pm
Oh... ok RussianVodka.

I just tried some random numbers to test it out :D

So... could you post up the source?
Title:
Post by: RussianVodka on December 12, 2004, 01:34:48 am
Code: [Select]

//Quadratic Functions v2.0

#include
#include
#include
#include
using namespace std;

//////////////////////////////////
#define RADICAL radical(a,b,c)
#define INSIDE_RADICAL ((b*b)-(4*a*c))
#define REMAINDER remainder(a, b, c, d, e)


/////////////////////////////////

float r;
float d;
float e;
////////////////////////////////
float radical(int a, int b, int c)
{
    if (INSIDE_RADICAL >= 0)
    {
       r = sqrt(INSIDE_RADICAL);
   }
   else
    {
       r = sqrt((-1)*INSIDE_RADICAL);
  }

   return r;
}
/////////////////////////////////
 float remainder(int a, int b, int c, float d, float e)
  {
   for (d = INSIDE_RADICAL; e = RADICAL;)
  {
       d = d - e;
      if (e>d)
        {
           break;
      }
       else
        {}
  }
   return d;
   }
////////////////////////////////

int main()
{
    int a;
  int b;
  int c;
  float d = 0;
    float e = 0;
    int z = 1;
  string szQuit = \" \";

  cout << \"***The \'X finder\' will find the value of X in a quadratic function***\\n\";
   cout << \"**************************By Egor Poblaguev**************************\\n\";
 cout << \"*** Email: [EMAIL]RussianVodka@mail.ru[/EMAIL] ************* AIM: RussianVodka667***\\n\\n\";

 
    while (z>0)
 {
       for (a=0; a==0;)
        {
       cout << \"Enter value of A: \";
     cin >> a;                           // Ask for value of A.
      }
       cout << \"Enter value of B: \";
     cin >> b;                           // Ask for value of B.

      cout << \"Enter value of C: \";
     cin >> c;                           // Ask for value of C.
      cout << \"\\n\\n\";
////////////////////////////////////////////////////////////////////////////////////////////

     if (INSIDE_RADICAL >= 0)                                        // If \'INSIDE_RADICAL\' is greater than zero.
      {
           if (REMAINDER == 0)                             // If \'INSIDE_RADICAL\' is a perfect square.
           {
               cout << \"One value of X is: \" << ((-b) + RADICAL) / (2 * a) << \".\\n\";
                cout << \"The other value of X is: \" << ((-b) - RADICAL) / (2 * a) << \".\\n\\n\";
         }
           else                                                        // If \'INSIDE_RADICAL\' is not a perfect square.
           {
               cout << \"One formula for X is: (\" << (-b) << \" + sqrt(\" << INSIDE_RADICAL << \")) / \" << (2 * a) << \".\\n\";
                cout << \"The other formula for X is: (\" << (-b) << \" - sqrt(\" << INSIDE_RADICAL << \")) / \" << (2 * a) << \".\\n\\n\";
         }
       }
       else                                                // If \'INSIDE_RADICAL\' is less than zero.
     {
           if (REMAINDER == 0)                             // If \'INSIDE_RADICAL\' is a perfect square.
           {
               if (((b % (2*a)) == 0) && (INSIDE_RADICAL % (2*a) == 0))    // If simplifying is posible.
               {  
                    cout << \"One formula for X is: \" << (-b)/(2*a) << \" + \" << RADICAL / (2 * a) << \"i.\\n\";
                    cout << \"The other formula for X is: \" << (-b)/(2*a) << \" - \" << RADICAL / (2 * a) << \"i.\\n\\n\";
             }
               else                                                    // If simplifying is not possible.
              {
                   cout << \"One formula for X is: (\" << (-b) << \" + \" << RADICAL << \"i ) / \" << (2 * a) << \".\\n\";
                   cout << \"The other formula for X is: (\" << (-b) << \" - \" << RADICAL << \"i ) / \" << (2 * a) << \".\\n\\n\";
                }
           }
           else                                                        // If \'INSIDE_RADICAL is not a perfect square.
           {
               cout << \"One formula for X is: (\" << (-b) << \" + sqrt(\" << -INSIDE_RADICAL << \")i ) / \" << (2 * a) << \".\\n\";
             cout << \"The other formula for X is: (\" << (-b) << \" - sqrt(\" << -INSIDE_RADICAL << \")i ) / \" << (2 * a) << \".\\n\\n\";
          }
       }
       
///////////////////////////////////////////////////////////////////////////////////




//////////////////////////////////////////////////////////////////////////////
       cout << \"Enter \'q\' to quit, or anything else to restart.\";          //
      cin >> szQuit;                                                      //
      cout << \"\\n\";                                                      //
                                                                          //
      if ((szQuit == \"q\") || (szQuit == \"Q\"))                             //
      {                                                                   //  
           cout << \"Quiting...\\n\";                                            //   Quiting Question (While Loop Break).
           Sleep(500);                                                     //
         break;                                                          //
      }                                                                   //
      else                                                                //
      {                                                                   //
          cout << \"Restarting...\\n\\n\";                                    //
      }                                                                   //
//////////////////////////////////////////////////////////////////////////////
    }
   return 0;
}


Um.... It looks a lot less slopy in Visual C++.....
Title:
Post by: Chestar on December 12, 2004, 04:31:01 am
Quote
Originally posted by faldrok
Icefalcon: I can\'t believe you wasted $100 on a friggin\' calculator!! And, that is the type of calculator that can do everything for you...what a shame. In America, you don\'t need to know how to do anything in Math...the calculator can do it for you!!

I stick by my $1 calculator. I just use it when I don\'t have the time to work out 237*543. Other than that, I do it myself...pfft, super calculators.


Yeah, my class required me to buy one also as IceFalcon said, except I got the TI84 Silver Edition, and actually it runs programs well... of course I usually play games on it.
Title:
Post by: faldrok on December 12, 2004, 04:42:25 am
Laziness is all it is. There isn\'t anything that the calculator does that you can\'t work out. Well, besides the creating programs that work, etc. etc.

Quote
Originally posted by ArcaneFalcon
and other monotanous stuff that I could easily do on my own but simply don\'t want to waste my time with.


That\'s...laziness. You don\'t NEED the calculator to do stuff like that; you just WANT it to. The people that everyone views as \"The Great Mathematicians\" didn\'t use TI-83s and other \"super calculators.\" If they can derive formulas and change the way people think about Math, as a whole, without this calculator, then you can solve the problems that are from their studies without one. All it is is Human Laziness. Like, do people use the remote, or change the channels on the TV? They use the remote. Why? Human Laziness. So, don\'t give me this shit that you need the crap. Yeah, it might make life easier, but do you need it to survive? Hell no.
Title:
Post by: faldrok on December 12, 2004, 04:42:55 am
Blah...I think I lagged or something, because I hit \"Post Reply\" and got two...delete this please.
Title:
Post by: ArcaneFalcon on December 12, 2004, 05:10:35 am
You\'re right, great mathemeticians don\'t use calculators.  They use supercomputers with specially designed software that takes hours, days, weeks, etc. to even attempt to solve their problems.

:emerald:
Title:
Post by: faldrok on December 12, 2004, 05:30:36 am
Bleh, I was talking in the past, so I, obviously, didn\'t mean the mathematicians of today. I was referring to the people like Isaac Newton, and others way back then. Now, they used no form of computers; they might have had tricks to speed things up a bit, but there is no way that they used a supercomputer or calculator.
Title:
Post by: ArcaneFalcon on December 12, 2004, 05:58:08 am
Ah, I see now.  Boy, I sure am lazy for wanting and using a nice calculator.  You\'re right.  In fact, now that you mention it, why on earth do I need a car?  I\'m not lazy, I can walk.  Also, who the heck needs a stove?  I\'ll just make a fire.  Electric lights?  Nah, that\'s what candles are for.  Meh, I may just become amish.  Yeah, that sounds good.

My point is, just because someone takes advantage of modern technology doesn\'t mean they\'re lazy.  It means that even though they can do things the old fashioned way (which may require more effort) they would rather do it the modern way and save time that can be better spent somewhere else.  And btw, the stuff those great (and old) mathemeticians discovered are, by today\'s standards, very simple.  Today we have things like stream theory (two steps above quantum theory, or three steps above what you learn in physics) that only a handful of people on earth can grasp.

:emerald:
Title:
Post by: faldrok on December 12, 2004, 07:18:04 am
Well, I might have went too far with saying \"lazy\", but you guys went too far with saying that you \"need\" this calculator. I\'m not saying that everyone should throw away their calculator, but using it all the time might seem a *bit* lazy. So, yea I exaggerated a bit, but nobody \"needs\" this calculator; it just makes life easier. ;)
Title:
Post by: Ghostslayer on December 12, 2004, 08:39:52 am
Quote
Originally posted by faldrok
Well, I might have went too far with saying \"lazy\", but you guys went too far with saying that you \"need\" this calculator. I\'m not saying that everyone should throw away their calculator, but using it all the time might seem a *bit* lazy. So, yea I exaggerated a bit, but nobody \"needs\" this calculator; it just makes life easier. ;)


I\'ll agree with you that some people have become too reliant on their calculators (ie trying to figure out their mark on a test when it is out of 50 or something, or use it for addition of small numbers :P), but there are good uses for it.  
I still think you are underestimating the need for computers and math problems though, especially when things cannot be solved mathematically (there are equations like this: high order differential equations come to mind), and computers/calculators should be the only things to waste their time doing thousands of iterations :D

So in the end, I need :P my calculator, but perhaps not as much as I use it ;)
Title:
Post by: Icefalcon on December 12, 2004, 06:02:43 pm
Yeah, Faldrok, what kind of math class are you in? (assuming you are still in school). My calculator was required for Algebra 2, but you can make it through Algebra 2 without it. But once you get into Calc and Trig, you are going to need it, yes need, not want.
Title:
Post by: Keknehv on December 12, 2004, 06:52:51 pm
I disagree. You don?t need a special graphing TI calculator. My math teacher made it through calculus four with only a cheap scientific calculator. Of course, he also figured out how to solve a Rubik?s cube on his own in fourth grade, but?.