Looking for Equation Solver

Discussion in 'Perl Misc' started by Chris, Sep 3, 2005.

  1. Chris

    Chris Guest

    Hi,

    does anybody know a Perl program or script that is able to solve
    mathematical equations. So, if I input a string, say, $e = "2x+1=5";
    the output would be "x=2".

    If anybody knows about a program that can do something like this, please
    let me know.

    Thank you,
    Chris
     
    Chris, Sep 3, 2005
    #1
    1. Advertising

  2. I wrote one

    http://www.algebra.com/services/rendering/simplifier.mpl

    Besides simplifying, it shows work and plots math formulas. It is not
    available publicly though. There is a Math::Symbolic module, but I
    found it extremely lacking.

    i

    On Sat, 03 Sep 2005 19:49:43 +0200, Chris <no@spam> wrote:
    > Hi,
    >
    > does anybody know a Perl program or script that is able to solve
    > mathematical equations. So, if I input a string, say, $e = "2x+1=5";
    > the output would be "x=2".
    >
    > If anybody knows about a program that can do something like this, please
    > let me know.
    >
    > Thank you,
    > Chris



    --
     
    Ignoramus14363, Sep 3, 2005
    #2
    1. Advertising

  3. Chris

    Guest

    Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    > I wrote one
    >
    > http://www.algebra.com/services/rendering/simplifier.mpl
    >
    > Besides simplifying, it shows work and plots math formulas. It is not
    > available publicly though.


    Also, it doesn't give the right answer.

    "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15)) simplifies to
    (x-3)/(x+2)"

    No, it doesn't.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Sep 3, 2005
    #3
  4. On 03 Sep 2005 22:51:13 GMT, <> wrote:
    > Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    >> I wrote one
    >>
    >> http://www.algebra.com/services/rendering/simplifier.mpl
    >>
    >> Besides simplifying, it shows work and plots math formulas. It is not
    >> available publicly though.

    >
    > Also, it doesn't give the right answer.
    >
    > "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15)) simplifies to
    > (x-3)/(x+2)"
    >
    > No, it doesn't.


    I will appreciate corrections and suggestions. What's the right answer
    there?

    i
     
    Ignoramus14363, Sep 4, 2005
    #4
  5. Chris

    Keith Keller Guest

    On 2005-09-03, Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    >
    > On 03 Sep 2005 22:51:13 GMT, <> wrote:
    >>
    >> Also, it doesn't give the right answer.
    >>
    >> "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15)) simplifies to
    >> (x-3)/(x+2)"
    >>
    >> No, it doesn't.

    >
    > I will appreciate corrections and suggestions. What's the right answer
    > there?


    If you can't figure it out on paper, why are you writing a program to do
    it? Sheesh, I might as well go write an OS! :-\

    --keith

    --
    -francisco.ca.us
    (try just my userid to email me)
    AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
    see X- headers for PGP signature information
     
    Keith Keller, Sep 4, 2005
    #5
  6. On Sat, 3 Sep 2005 22:47:50 -0700, Keith Keller <-francisco.ca.us> wrote:
    > On 2005-09-03, Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    >>
    >> On 03 Sep 2005 22:51:13 GMT, <> wrote:
    >>>
    >>> Also, it doesn't give the right answer.
    >>>
    >>> "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15)) simplifies to
    >>> (x-3)/(x+2)"
    >>>
    >>> No, it doesn't.

    >>
    >> I will appreciate corrections and suggestions. What's the right answer
    >> there?

    >
    > If you can't figure it out on paper, why are you writing a program to do
    > it? Sheesh, I might as well go write an OS! :-\


    Let me know when you have something useful and substantial to say,
    okay?

    (hint, I did solve it on paper)

    If you can explain why the above simplification is incorrect, I would
    appreciate hearing that.

    i
     
    Ignoramus14363, Sep 4, 2005
    #6
  7. Chris

    BZ Guest

    Ignoramus14363 wrote in comp.lang.perl.misc:
    > > "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15)) simplifies to
    > > (x-3)/(x+2)"
    > > No, it doesn't.

    >
    > I will appreciate corrections and suggestions. What's the right answer
    > there?


    (x-3)^2/(x-4)^2

    --
    BZ
     
    BZ, Sep 4, 2005
    #7
  8. Chris

    Paul Lalli Guest

    OT: Math Simplification (WAS: Looking for Equation Solver)

    Ignoramus14363 wrote:
    > Keith Keller wrote:
    > > Ignoramus14363 wrote:
    > >> wrote:
    > >>>
    > >>> Also, it doesn't give the right answer.
    > >>>
    > >>> "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15)) simplifies to
    > >>> (x-3)/(x+2)"
    > >>>
    > >>> No, it doesn't.
    > >>


    > If you can explain why the above simplification is incorrect, I would
    > appreciate hearing that.
    >


    Uhm. Because it's not mathematically valid? Try any value of X. The
    original does not produce the same result as the simplification. (Hint
    - the easiest value to plug in would be 0, which gives -3/2 for the
    simplification, but
    (-9/10) / (6/15) = (-9/10) * (15/6) = (-3/2) * (3/2) = -9/4 for the
    original).

    fwiw, when I do it on paper I get:
    (x^2 - 6x - 9) / (x^2 -4)

    (Granted, it has been about 5 years since I last took a math class...)

    Paul Lalli
     
    Paul Lalli, Sep 4, 2005
    #8
  9. Chris

    Dave Guest

    "BZ" <> wrote in message
    news:...
    > Ignoramus14363 wrote in comp.lang.perl.misc:
    >> > "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))
    >> > simplifies to
    >> > (x-3)/(x+2)"
    >> > No, it doesn't.

    >>
    >> I will appreciate corrections and suggestions. What's the right answer
    >> there?

    >
    > (x-3)^2/(x-4)^2
    >
    > --
    > BZ


    No, Paul is right. It can also be written:
    ((x-3)^2)/((x+2)(x-2))
    or
    (x-3)^2/(x^2-4)
    the latter of which is perhaps what BZ meant to type.
     
    Dave, Sep 4, 2005
    #9
  10. Chris

    Dave Guest

    OT: Re: Looking for Equation Solver

    "Ignoramus14363" <ignoramus14363@NOSPAM.14363.invalid> wrote in message
    news:bdwSe.98947$...
    > On Sat, 3 Sep 2005 22:47:50 -0700, Keith Keller
    > <-francisco.ca.us> wrote:
    >> On 2005-09-03, Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid>
    >> wrote:
    >>>
    >>> On 03 Sep 2005 22:51:13 GMT, <>
    >>> wrote:
    >>>>
    >>>> Also, it doesn't give the right answer.
    >>>>
    >>>> "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))
    >>>> simplifies to
    >>>> (x-3)/(x+2)"
    >>>>
    >>>> No, it doesn't.
    >>>
    >>> I will appreciate corrections and suggestions. What's the right answer
    >>> there?

    >>
    >> If you can't figure it out on paper, why are you writing a program to do
    >> it? Sheesh, I might as well go write an OS! :-\

    >
    > Let me know when you have something useful and substantial to say,
    > okay?
    >
    > (hint, I did solve it on paper)
    >
    > If you can explain why the above simplification is incorrect, I would
    > appreciate hearing that.
    >
    > i
    >


    The error in the explanation this example is at the line:
    'Canceled out common factors (x-(3)),(x-(3))'

    Where (1) is left in each case instead of (x-3) and (x-2) in numerator and
    denominator respectively.

    The explantion would be clearer if you showed the factorisation before the
    cancellation, and this error would have been more obvious too.

    Hope this helps

    Dave
     
    Dave, Sep 4, 2005
    #10
  11. Chris

    Guest

    Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    > On 03 Sep 2005 22:51:13 GMT, <> wrote:
    > > Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    > >> I wrote one
    > >>
    > >> http://www.algebra.com/services/rendering/simplifier.mpl
    > >>
    > >> Besides simplifying, it shows work and plots math formulas. It is not
    > >> available publicly though.

    > >
    > > Also, it doesn't give the right answer.
    > >
    > > "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))
    > > simplifies to (x-3)/(x+2)"
    > >
    > > No, it doesn't.

    >
    > I will appreciate corrections and suggestions. What's the right answer
    > there?


    I didn't solve it fully; I just set x to zero which was enough to show the
    simplification was wrong.

    It appears that the correct answer is (x-3)^2/(x-2)/(x+2). It seem like
    your program realizes that (x-3) is a common factor in two of the quadratic
    groups, but then "cancels out" both of those groups in their entirety,
    rather than just the factor of x-3.

    Xho



    >
    > i


    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Sep 5, 2005
    #11
  12. Re: OT: Re: Looking for Equation Solver

    Thanks guys (all of you). You got it. I corrected the solver, it was a
    programming mistake. Thank you!

    i

    On Sun, 4 Sep 2005 21:29:30 +0200, Dave <> wrote:
    >
    > "Ignoramus14363" <ignoramus14363@NOSPAM.14363.invalid> wrote in message
    > news:bdwSe.98947$...
    >> On Sat, 3 Sep 2005 22:47:50 -0700, Keith Keller
    >> <-francisco.ca.us> wrote:
    >>> On 2005-09-03, Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid>
    >>> wrote:
    >>>>
    >>>> On 03 Sep 2005 22:51:13 GMT, <>
    >>>> wrote:
    >>>>>
    >>>>> Also, it doesn't give the right answer.
    >>>>>
    >>>>> "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))
    >>>>> simplifies to
    >>>>> (x-3)/(x+2)"
    >>>>>
    >>>>> No, it doesn't.
    >>>>
    >>>> I will appreciate corrections and suggestions. What's the right answer
    >>>> there?
    >>>
    >>> If you can't figure it out on paper, why are you writing a program to do
    >>> it? Sheesh, I might as well go write an OS! :-\

    >>
    >> Let me know when you have something useful and substantial to say,
    >> okay?
    >>
    >> (hint, I did solve it on paper)
    >>
    >> If you can explain why the above simplification is incorrect, I would
    >> appreciate hearing that.
    >>
    >> i
    >>

    >
    > The error in the explanation this example is at the line:
    > 'Canceled out common factors (x-(3)),(x-(3))'
    >
    > Where (1) is left in each case instead of (x-3) and (x-2) in numerator and
    > denominator respectively.
    >
    > The explantion would be clearer if you showed the factorisation before the
    > cancellation, and this error would have been more obvious too.
    >
    > Hope this helps
    >
    > Dave
    >
    >



    --
     
    Ignoramus25850, Sep 7, 2005
    #12
  13. Chris

    Peyton Bland Guest

    Hi,

    I'm coming to the party a bit late, but you guys are scaring me, so I
    had to reply (!)...

    In article <20050904211634.239$>, <>
    wrote:

    > Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    > > On 03 Sep 2005 22:51:13 GMT, <> wrote:
    > > > Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    > > >> I wrote one
    > > >>
    > > >> http://www.algebra.com/services/rendering/simplifier.mpl
    > > >>
    > > >> Besides simplifying, it shows work and plots math formulas. It is not
    > > >> available publicly though.
    > > >
    > > > Also, it doesn't give the right answer.
    > > >
    > > > "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))
    > > > simplifies to (x-3)/(x+2)"
    > > >
    > > > No, it doesn't.

    > >
    > > I will appreciate corrections and suggestions. What's the right answer
    > > there?

    >
    > I didn't solve it fully; I just set x to zero which was enough to show the
    > simplification was wrong.


    I did this, too, and got -1 when x = 0. What did you get, Xho?

    > It appears that the correct answer is (x-3)^2/(x-2)/(x+2). It seem like
    > your program realizes that (x-3) is a common factor in two of the quadratic
    > groups, but then "cancels out" both of those groups in their entirety,
    > rather than just the factor of x-3.


    Have another look... I get (x+2)/(x-2) . Hopefully, no one coerced
    the software in question to yield any of these other answers given
    earlier.

    Cheers,
    Peyton Bland
     
    Peyton Bland, Nov 14, 2005
    #13
  14. Chris

    Paul Lalli Guest

    Peyton Bland wrote:
    > I'm coming to the party a bit late, but you guys are scaring me, so I
    > had to reply (!)...


    It may have been wise to figure out what you're talking about before
    reviving a 3 month old thread.

    > In article <20050904211634.239$>, <>
    > wrote:
    >
    > > Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    > > > On 03 Sep 2005 22:51:13 GMT, <> wrote:
    > > > >
    > > > > Also, it doesn't give the right answer.
    > > > >
    > > > > "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))
    > > > > simplifies to (x-3)/(x+2)"
    > > > >
    > > > > No, it doesn't.
    > > >
    > > > I will appreciate corrections and suggestions. What's the right answer
    > > > there?

    > >
    > > I didn't solve it fully; I just set x to zero which was enough to show the
    > > simplification was wrong.

    >
    > I did this, too, and got -1 when x = 0. What did you get, Xho?


    My guess would be the correct answer that we all gave three months ago.
    -9/4

    ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))


    (0^2-6*0+9)/(0^2-3*0-10)
    ------------------------
    (0^2-5*0+6)/(0^2-8*0+15)

    9 / -10
    ------
    6 / 15

    9 15
    - -- * --
    10 6

    135 27 9
    - --- = - -- = - -
    60 12 4


    (make sure you view the above in a fixed-width font)

    > > It appears that the correct answer is (x-3)^2/(x-2)/(x+2). It seem like
    > > your program realizes that (x-3) is a common factor in two of the quadratic
    > > groups, but then "cancels out" both of those groups in their entirety,
    > > rather than just the factor of x-3.

    >
    > Have another look... I get (x+2)/(x-2) .


    Yes, well, you're wrong. See previous responses for how and why.

    > Hopefully, no one coerced
    > the software in question to yield any of these other answers given
    > earlier.


    Yes, improving the buggy software would certainly be worse than using a
    working one to begin with.

    Paul Lalli
     
    Paul Lalli, Nov 14, 2005
    #14
  15. Chris

    Guest

    Peyton Bland <> wrote:
    > Hi,
    >
    > I'm coming to the party a bit late, but you guys are scaring me, so I
    > had to reply (!)...


    That being the case, you might want to spend some more time explaining
    what it is you are trying to say. It is hard to just pick up a thread
    after 3 months.

    > In article <20050904211634.239$>, <>
    > wrote:
    >
    > > Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    > > > On 03 Sep 2005 22:51:13 GMT, <>
    > > > wrote:
    > > > > Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    > > > >> I wrote one
    > > > >>
    > > > >> http://www.algebra.com/services/rendering/simplifier.mpl
    > > > >>
    > > > >> Besides simplifying, it shows work and plots math formulas. It is
    > > > >> not available publicly though.
    > > > >
    > > > > Also, it doesn't give the right answer.
    > > > >
    > > > > "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))
    > > > > simplifies to (x-3)/(x+2)"
    > > > >
    > > > > No, it doesn't.
    > > >
    > > > I will appreciate corrections and suggestions. What's the right
    > > > answer there?

    > >
    > > I didn't solve it fully; I just set x to zero which was enough to show
    > > the simplification was wrong.

    >
    > I did this, too, and got -1 when x = 0. What did you get, Xho?


    Well, for the original full form, I got -9/4. For the original incorrect
    simplification I got -3/2. For the correct simplification I got
    (obviously) -9/4. For your new incorrect simplification I got -1.


    >
    > > It appears that the correct answer is (x-3)^2/(x-2)/(x+2). It seem
    > > like your program realizes that (x-3) is a common factor in two of the
    > > quadratic groups, but then "cancels out" both of those groups in their
    > > entirety, rather than just the factor of x-3.

    >
    > Have another look...


    Are you trying to tell me to double check my work, or are you telling me
    that the bug has been fixed and I should go look at the original web page
    again?


    > I get (x+2)/(x-2) .


    Which is obiously wrong, as (setting x=0) -9/4 != -1.

    > Hopefully, no one coerced
    > the software in question to yield any of these other answers given
    > earlier.


    I have no idea what that means.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Nov 14, 2005
    #15
  16. Chris

    Peyton Bland Guest

    In article <>, Paul
    Lalli <> wrote:

    > Peyton Bland wrote:
    > > I'm coming to the party a bit late, but you guys are scaring me, so I
    > > had to reply (!)...

    >
    > It may have been wise to figure out what you're talking about before
    > reviving a 3 month old thread.


    My sincere apologies to the group. I carelessly mis-read the
    expression (the ratio of polynomials).

    > > In article <20050904211634.239$>, <>
    > > wrote:
    > >
    > > > Ignoramus14363 <ignoramus14363@NOSPAM.14363.invalid> wrote:
    > > > > On 03 Sep 2005 22:51:13 GMT, <>
    > > > > wrote:
    > > > > >
    > > > > > Also, it doesn't give the right answer.
    > > > > >
    > > > > > "Text form: ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))
    > > > > > simplifies to (x-3)/(x+2)"
    > > > > >
    > > > > > No, it doesn't.
    > > > >
    > > > > I will appreciate corrections and suggestions. What's the right answer
    > > > > there?
    > > >
    > > > I didn't solve it fully; I just set x to zero which was enough to show the
    > > > simplification was wrong.

    > >
    > > I did this, too, and got -1 when x = 0. What did you get, Xho?

    >
    > My guess would be the correct answer that we all gave three months ago.
    > -9/4
    >
    > ((x^2-6x+9)/(x^2-3x-10))/((x^2-5x+6)/(x^2-8x+15))
    >
    >
    > (0^2-6*0+9)/(0^2-3*0-10)
    > ------------------------
    > (0^2-5*0+6)/(0^2-8*0+15)
    >
    > 9 / -10
    > ------
    > 6 / 15
    >
    > 9 15
    > - -- * --
    > 10 6
    >
    > 135 27 9
    > - --- = - -- = - -
    > 60 12 4
    >
    >
    > (make sure you view the above in a fixed-width font)
    >
    > > > It appears that the correct answer is (x-3)^2/(x-2)/(x+2). It seem like
    > > > your program realizes that (x-3) is a common factor in two of the
    > > > quadratic
    > > > groups, but then "cancels out" both of those groups in their entirety,
    > > > rather than just the factor of x-3.

    > >
    > > Have another look... I get (x+2)/(x-2) .

    >
    > Yes, well, you're wrong. See previous responses for how and why.
    >
    > > Hopefully, no one coerced
    > > the software in question to yield any of these other answers given
    > > earlier.

    >
    > Yes, improving the buggy software would certainly be worse than using a
    > working one to begin with.
    >
    > Paul Lalli


    Peyton Bland
     
    Peyton Bland, Nov 15, 2005
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lothar Leidner

    quartic polynomial solver

    Lothar Leidner, Dec 22, 2003, in forum: Java
    Replies:
    2
    Views:
    3,700
    Roedy Green
    Dec 22, 2003
  2. eggie2486

    peg triangle puzzle solver

    eggie2486, May 20, 2004, in forum: C++
    Replies:
    4
    Views:
    2,369
    Bruce
    May 21, 2004
  3. Aaron
    Replies:
    1
    Views:
    945
    Aaron
    Sep 19, 2004
  4. Guenther Sohler

    Linear Equation solver

    Guenther Sohler, Sep 19, 2005, in forum: C Programming
    Replies:
    1
    Views:
    376
    Alexei A. Frounze
    Sep 19, 2005
  5. Takeshi NISHIMATSU

    Pell's equation solver in Ruby

    Takeshi NISHIMATSU, Dec 1, 2009, in forum: Ruby
    Replies:
    0
    Views:
    149
    Takeshi NISHIMATSU
    Dec 1, 2009
Loading...

Share This Page