Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #5973 > unrolled thread

algrabraic equations

Started byRuben Safir <ruben@mrbrklyn.com>
First post2011-06-01 16:17 +0000
Last post2011-06-01 13:25 -0700
Articles 5 — 5 participants

Back to article view | Back to comp.lang.c++


Contents

  algrabraic equations Ruben Safir <ruben@mrbrklyn.com> - 2011-06-01 16:17 +0000
    Re: algrabraic equations Saeed Amrollahi <amrollahi.saeed@gmail.com> - 2011-06-01 09:31 -0700
    Re: algrabraic equations Sherm Pendley <sherm.pendley@gmail.com> - 2011-06-01 12:57 -0400
    Re: algrabraic equations Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-01 12:58 -0400
    Re: algrabraic equations Paul N <gw7rib@aol.com> - 2011-06-01 13:25 -0700

#5973 — algrabraic equations

FromRuben Safir <ruben@mrbrklyn.com>
Date2011-06-01 16:17 +0000
Subjectalgrabraic equations
Message-ID<is5one$m7v$1@reader1.panix.com>
how would someone parse an advanced algrabiac expression that is a string

something like 

(3*x^3 - 2*x^2 - 4)/(x^2 +7)

Ruben

[toc] | [next] | [standalone]


#5975

FromSaeed Amrollahi <amrollahi.saeed@gmail.com>
Date2011-06-01 09:31 -0700
Message-ID<ed3520c5-f720-4f2e-84b4-fcedeb63a7ab@v8g2000yqb.googlegroups.com>
In reply to#5973
On Jun 1, 7:17 pm, Ruben Safir <ru...@mrbrklyn.com> wrote:
> how would someone parse an advanced algrabiac expression that is a string
>
> something like
>
> (3*x^3 - 2*x^2 - 4)/(x^2 +7)
>
> Ruben

Hi

C++ has no 'Power to' operator (^), but if had,
I believe from point of math view, the priority of
^ is higher than * and / so, I think it should be parsed
like this:
  ((3 * (x^3) ) - (2 * (x^2) ) - 4) / ( (x^2) + 7)

HTH,
  -- Saeed Amrollahi

[toc] | [prev] | [next] | [standalone]


#5977

FromSherm Pendley <sherm.pendley@gmail.com>
Date2011-06-01 12:57 -0400
Message-ID<m2k4d5o5ew.fsf@sherm.shermpendley.com>
In reply to#5973
Ruben Safir <ruben@mrbrklyn.com> writes:

> how would someone parse an advanced algrabiac expression that is a string
>
> something like 
>
> (3*x^3 - 2*x^2 - 4)/(x^2 +7)

If you're looking to write an expression parser, Boost.Spirit is a good
place to start:

  <http://www.boost.org>

sherm--

[toc] | [prev] | [next] | [standalone]


#5978

FromVictor Bazarov <v.bazarov@comcast.invalid>
Date2011-06-01 12:58 -0400
Message-ID<is5r4g$a0r$1@dont-email.me>
In reply to#5973
On 6/1/2011 12:17 PM, Ruben Safir wrote:
> how would someone parse an advanced algrabiac expression that is a string
>
> something like
>
> (3*x^3 - 2*x^2 - 4)/(x^2 +7)

What is your C++ language question?  If you have none, post your general 
programming inquiry to 'comp.programming'.

V
-- 
I do not respond to top-posted replies, please don't ask

[toc] | [prev] | [next] | [standalone]


#6006

FromPaul N <gw7rib@aol.com>
Date2011-06-01 13:25 -0700
Message-ID<401e6d20-d481-49ff-bbfc-0756efd89161@r33g2000prh.googlegroups.com>
In reply to#5973
On Jun 1, 5:17 pm, Ruben Safir <ru...@mrbrklyn.com> wrote:
> how would someone parse an advanced algrabiac expression that is a string
>
> something like
>
> (3*x^3 - 2*x^2 - 4)/(x^2 +7)

The FAQ, at http://www.parashift.com/c++-faq-lite/ offers the
following advice:

"Use a stack of operators to convert infix to postfix, then a stack of
operands to evaluate the postfix expression."

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web