Parsing and solving algebraic equation from string

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Parsing and solving algebraic equation from string

Mansour Al Akeel
I am new to commons-math. I need to solve simple equations in the form
"x + 3 = 10"
The closest thing I was able to find is
http://commons.apache.org/proper/commons-math/userguide/linear.html#a3.4_Solving_linear_systems


However, this needs a square matrix, and can not build the
coefficients and constants from the string.
Is there a matrix builder that I can use to create the 2 dimensional
arrays to solve this equation ?

Thank you.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Luc Maisonobe-2
Hi Mansour,

Le 15/07/2014 15:02, Mansour Al Akeel a écrit :
> I am new to commons-math. I need to solve simple equations in the form
> "x + 3 = 10"
> The closest thing I was able to find is
> http://commons.apache.org/proper/commons-math/userguide/linear.html#a3.4_Solving_linear_systems

If you have only one free variable (x in this case), then you should
rather user one of the UnivariateSolver implementations from the
org.apache.commons.math3.analysis.solver package. In the general case, I
would recommend the BracketingNthOrderBrentSolver, but if you only have
linear systems, there are not much differences betwen solvers.

>
>
> However, this needs a square matrix, and can not build the
> coefficients and constants from the string.
> Is there a matrix builder that I can use to create the 2 dimensional
> arrays to solve this equation ?

This problem is not 2-dimensional, it is really one dimension only (one
equation for solving one unknown). It would be 2-dimensional if you had
two equations for two unknowns. In this case (2-dimensional), you should
have somathing like:

  a1 x + b1 y + c1 = d1
  a2 x + b2 y + c2 = d2

where a1, b1, c1, d1, a2, b2, c2 and d2 are constants and x and y are
the two unknowns you want to find.

You should start by grouping the additive constants c1 and d1 as well as
c2 and d2 to have your system in a canonical form. You can do this by
subgtracting c1 from both sides of equation 1 and c2 from both sides of
equation 2 so they disappear from the left hand side, you then get:

  a1 x + b1 y = d1 - c1
  a2 x + b2 y = d2 - c2

This is rewritten in matrix form:

  [ a1   b1 ]   [ x ]        [d1 - c1]
  [         ] * [   ]    =   [       ]
  [ a2   b2 ]   [ y ]        [d2 - c2]

So the system you would provide to Apache Commons Math would be solved
as follows:

  double a1 = ...;
  double b1 = ...;
  double c1 = ...;
  double d1 = ...;
  double a2 = ...;
  double b2 = ...;
  double c2 = ...;
  double d2 = ...;

  RealMatrix m = MatrixUtils.createRealMatrix(new double[][] {
                                               { a1, b1 },
                                               { a2, b2}
                                              });
  RealVector v = MatrixUtils.createRealVector(new double[] {
                                                d1 - c1,
                                                d2 - c2
                                              });

  // find vector u solution of m * u = v
  double singularityThreshold = 1.0e-10; // or some other small number
  DecompositionSolver solver =
    new LUDecomposition(m, singularityThreshold).getSolver();
  RealVector u = solver.solve(v);


There are no parser in Apache Commons Math to build such systems
directly from string representations. We already discussed about this
and decided not to implement parsers, as they are already big projects
by themselves and depend on the syntax you want to parse. Parsers are
therefore considered to be out of Apache Commons Math scope. They belong
to higher level projects that could implement them for their own
specific syntax, and rely on Apache Commons Math to sovle the problem
once it has been translated from strings to structured numbered.

Hope this helps
Luc

>
> Thank you.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Ted Dunning
On Sun, Jul 20, 2014 at 12:01 AM, Luc Maisonobe <[hidden email]> wrote:

> There are no parser in Apache Commons Math to build such systems
> directly from string representations. We already discussed about this
> and decided not to implement parsers, as they are already big projects
> by themselves and depend on the syntax you want to parse. Parsers are
> therefore considered to be out of Apache Commons Math scope. They belong
> to higher level projects that could implement them for their own
> specific syntax, and rely on Apache Commons Math to sovle the problem
> once it has been translated from strings to structured numbered.
>

Also, there are excellent parser construction systems out there to help
with parsing.
Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Mansour Al Akeel
Luc and Ted, thank you for your help and support.
I understand the dimensionality part. Indeed most of the equations I
need to solve have one unknown.

I am looking to parse the equation from String to matrix form. I was
not lucky enough to find any parser that can do this out-of-the-box.
As Luc said, it will big project to write a parser that takes any
equation as a string, and generate the matrix (2-dimensional array) to
feed it into Commons Math.

Thank you.




On Sun, Jul 20, 2014 at 1:30 PM, Ted Dunning <[hidden email]> wrote:

> On Sun, Jul 20, 2014 at 12:01 AM, Luc Maisonobe <[hidden email]> wrote:
>
>> There are no parser in Apache Commons Math to build such systems
>> directly from string representations. We already discussed about this
>> and decided not to implement parsers, as they are already big projects
>> by themselves and depend on the syntax you want to parse. Parsers are
>> therefore considered to be out of Apache Commons Math scope. They belong
>> to higher level projects that could implement them for their own
>> specific syntax, and rely on Apache Commons Math to sovle the problem
>> once it has been translated from strings to structured numbered.
>>
>
> Also, there are excellent parser construction systems out there to help
> with parsing.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Paul Libbrecht-4
Mansour,

aren't you looking for a computer-algebra system?
There's a broad amount out there, but not many in Java.
Also, parsers for formulæ exist in numerous fashions.
You may want to look at the content-mathml-oriented processors listed in the MathML software list.
It's full of old things too, but parsing formula is not really a new topic.

I believe ASCIIMath could do a bit of that.
I know JOME can do that too (I have an open-source version somewhere).
Many others. They often differ by purposes (e.g. what kind of term you aim at) and ease of use (e.g. quality of the feedback in case of errors or tolerance for faulty content).
I know WebEQ, for example, has a very complete support to convert presentation to content too but that is not open-source!

Once with a parse-tree, it is not too hard to come to a matrix.
I'd do that with a content-mathml-tree encoded in JDOM, but I am surely biassed towards XML!

paul

On 21 juil. 2014, at 06:18, Mansour Al Akeel <[hidden email]> wrote:

> Luc and Ted, thank you for your help and support.
> I understand the dimensionality part. Indeed most of the equations I
> need to solve have one unknown.
>
> I am looking to parse the equation from String to matrix form. I was
> not lucky enough to find any parser that can do this out-of-the-box.
> As Luc said, it will big project to write a parser that takes any
> equation as a string, and generate the matrix (2-dimensional array) to
> feed it into Commons Math.
>
> Thank you.
>
>
>
>
> On Sun, Jul 20, 2014 at 1:30 PM, Ted Dunning <[hidden email]> wrote:
>> On Sun, Jul 20, 2014 at 12:01 AM, Luc Maisonobe <[hidden email]> wrote:
>>
>>> There are no parser in Apache Commons Math to build such systems
>>> directly from string representations. We already discussed about this
>>> and decided not to implement parsers, as they are already big projects
>>> by themselves and depend on the syntax you want to parse. Parsers are
>>> therefore considered to be out of Apache Commons Math scope. They belong
>>> to higher level projects that could implement them for their own
>>> specific syntax, and rely on Apache Commons Math to sovle the problem
>>> once it has been translated from strings to structured numbered.
>>>
>>
>> Also, there are excellent parser construction systems out there to help
>> with parsing.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Ted Dunning
In reply to this post by Mansour Al Akeel
On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <[hidden email]
> wrote:

> As Luc said, it will big project to write a parser that takes any
> equation as a string, and generate the matrix (2-dimensional array) to
> feed it into Commons Math.
>


It actually isn't a big project.

See http://www.antlr.org/

The simplest example they give there is this one:

*grammar Expr;*
*prog: (expr NEWLINE)* ; *
*expr: expr ('*'|'/') expr *
*    | expr ('+'|'-') expr *
*    | INT | '(' expr ')' ; *
*NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*

This will compile into a java program that parses expressions very much
like what you want.
Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

William Speirs
It's certainly incomplete, but I started working on a CAS (Computer Algebra
System: http://en.wikipedia.org/wiki/Computer_algebra_system) that was
"backed" by commons-math: https://github.com/wspeirs/math

The JJT (parser file for JavaCC) file can be found here, and is fairly
complete if I remember correctly:
https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt

I'd be happy to help you with it further and/or accept pull requests to
improve it :-)

Bill-


On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <[hidden email]> wrote:

> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
> [hidden email]
> > wrote:
>
> > As Luc said, it will big project to write a parser that takes any
> > equation as a string, and generate the matrix (2-dimensional array) to
> > feed it into Commons Math.
> >
>
>
> It actually isn't a big project.
>
> See http://www.antlr.org/
>
> The simplest example they give there is this one:
>
> *grammar Expr;*
> *prog: (expr NEWLINE)* ; *
> *expr: expr ('*'|'/') expr *
> *    | expr ('+'|'-') expr *
> *    | INT | '(' expr ')' ; *
> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
>
> This will compile into a java program that parses expressions very much
> like what you want.
>
Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Paul Libbrecht-4
Coool. License?

paul


On 21 juil. 2014, at 14:26, William Speirs <[hidden email]> wrote:

> It's certainly incomplete, but I started working on a CAS (Computer Algebra
> System: http://en.wikipedia.org/wiki/Computer_algebra_system) that was
> "backed" by commons-math: https://github.com/wspeirs/math
>
> The JJT (parser file for JavaCC) file can be found here, and is fairly
> complete if I remember correctly:
> https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt
>
> I'd be happy to help you with it further and/or accept pull requests to
> improve it :-)
>
> Bill-
>
>
> On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <[hidden email]> wrote:
>
>> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
>> [hidden email]
>>> wrote:
>>
>>> As Luc said, it will big project to write a parser that takes any
>>> equation as a string, and generate the matrix (2-dimensional array) to
>>> feed it into Commons Math.
>>>
>>
>>
>> It actually isn't a big project.
>>
>> See http://www.antlr.org/
>>
>> The simplest example they give there is this one:
>>
>> *grammar Expr;*
>> *prog: (expr NEWLINE)* ; *
>> *expr: expr ('*'|'/') expr *
>> *    | expr ('+'|'-') expr *
>> *    | INT | '(' expr ')' ; *
>> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
>>
>> This will compile into a java program that parses expressions very much
>> like what you want.
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

William Speirs
Errr... nothing at the moment, but I'll make it Apache2 :-)

Bill-


On Mon, Jul 21, 2014 at 8:29 AM, Paul Libbrecht <[hidden email]> wrote:

> Coool. License?
>
> paul
>
>
> On 21 juil. 2014, at 14:26, William Speirs <[hidden email]> wrote:
>
> > It's certainly incomplete, but I started working on a CAS (Computer
> Algebra
> > System: http://en.wikipedia.org/wiki/Computer_algebra_system) that was
> > "backed" by commons-math: https://github.com/wspeirs/math
> >
> > The JJT (parser file for JavaCC) file can be found here, and is fairly
> > complete if I remember correctly:
> >
> https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt
> >
> > I'd be happy to help you with it further and/or accept pull requests to
> > improve it :-)
> >
> > Bill-
> >
> >
> > On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <[hidden email]>
> wrote:
> >
> >> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
> >> [hidden email]
> >>> wrote:
> >>
> >>> As Luc said, it will big project to write a parser that takes any
> >>> equation as a string, and generate the matrix (2-dimensional array) to
> >>> feed it into Commons Math.
> >>>
> >>
> >>
> >> It actually isn't a big project.
> >>
> >> See http://www.antlr.org/
> >>
> >> The simplest example they give there is this one:
> >>
> >> *grammar Expr;*
> >> *prog: (expr NEWLINE)* ; *
> >> *expr: expr ('*'|'/') expr *
> >> *    | expr ('+'|'-') expr *
> >> *    | INT | '(' expr ')' ; *
> >> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
> >>
> >> This will compile into a java program that parses expressions very much
> >> like what you want.
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Mansour Al Akeel
William,
Thank you a lot.

Is there building instructions ?

Are there any interest in creating/adding these efforts as
commons-math subproject.
I understand and agree with the point that a parser is outside of the
scope of commons-math, but may be we can create a subproject
"commons-math-sandbox" or "commons-math-ext" or
"commons-math-optional", that will host efforts and project related
but does not fit the scope. This will separate the concerns and allow
those who need this functionality to find it easily, at the same time
it will give the project a home, and make it available for wider
users.

Is this a valid suggestion ?




On Mon, Jul 21, 2014 at 8:39 AM, William Speirs <[hidden email]> wrote:

> Errr... nothing at the moment, but I'll make it Apache2 :-)
>
> Bill-
>
>
> On Mon, Jul 21, 2014 at 8:29 AM, Paul Libbrecht <[hidden email]> wrote:
>
>> Coool. License?
>>
>> paul
>>
>>
>> On 21 juil. 2014, at 14:26, William Speirs <[hidden email]> wrote:
>>
>> > It's certainly incomplete, but I started working on a CAS (Computer
>> Algebra
>> > System: http://en.wikipedia.org/wiki/Computer_algebra_system) that was
>> > "backed" by commons-math: https://github.com/wspeirs/math
>> >
>> > The JJT (parser file for JavaCC) file can be found here, and is fairly
>> > complete if I remember correctly:
>> >
>> https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt
>> >
>> > I'd be happy to help you with it further and/or accept pull requests to
>> > improve it :-)
>> >
>> > Bill-
>> >
>> >
>> > On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <[hidden email]>
>> wrote:
>> >
>> >> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
>> >> [hidden email]
>> >>> wrote:
>> >>
>> >>> As Luc said, it will big project to write a parser that takes any
>> >>> equation as a string, and generate the matrix (2-dimensional array) to
>> >>> feed it into Commons Math.
>> >>>
>> >>
>> >>
>> >> It actually isn't a big project.
>> >>
>> >> See http://www.antlr.org/
>> >>
>> >> The simplest example they give there is this one:
>> >>
>> >> *grammar Expr;*
>> >> *prog: (expr NEWLINE)* ; *
>> >> *expr: expr ('*'|'/') expr *
>> >> *    | expr ('+'|'-') expr *
>> >> *    | INT | '(' expr ')' ; *
>> >> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
>> >>
>> >> This will compile into a java program that parses expressions very much
>> >> like what you want.
>> >>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

William Speirs
I think the better idea would be to promote commons-math to it's own
top-level project. It's a very impressive math library, and more active
than some of the other commons projects.

If made a top-level project then we could make subprojects like a parser,
GUI, etc.

Thoughts?

Bill-
On Jul 27, 2014 7:34 PM, "Mansour Al Akeel" <[hidden email]>
wrote:

> William,
> Thank you a lot.
>
> Is there building instructions ?
>
> Are there any interest in creating/adding these efforts as
> commons-math subproject.
> I understand and agree with the point that a parser is outside of the
> scope of commons-math, but may be we can create a subproject
> "commons-math-sandbox" or "commons-math-ext" or
> "commons-math-optional", that will host efforts and project related
> but does not fit the scope. This will separate the concerns and allow
> those who need this functionality to find it easily, at the same time
> it will give the project a home, and make it available for wider
> users.
>
> Is this a valid suggestion ?
>
>
>
>
> On Mon, Jul 21, 2014 at 8:39 AM, William Speirs <[hidden email]>
> wrote:
> > Errr... nothing at the moment, but I'll make it Apache2 :-)
> >
> > Bill-
> >
> >
> > On Mon, Jul 21, 2014 at 8:29 AM, Paul Libbrecht <[hidden email]>
> wrote:
> >
> >> Coool. License?
> >>
> >> paul
> >>
> >>
> >> On 21 juil. 2014, at 14:26, William Speirs <[hidden email]> wrote:
> >>
> >> > It's certainly incomplete, but I started working on a CAS (Computer
> >> Algebra
> >> > System: http://en.wikipedia.org/wiki/Computer_algebra_system) that
> was
> >> > "backed" by commons-math: https://github.com/wspeirs/math
> >> >
> >> > The JJT (parser file for JavaCC) file can be found here, and is fairly
> >> > complete if I remember correctly:
> >> >
> >>
> https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt
> >> >
> >> > I'd be happy to help you with it further and/or accept pull requests
> to
> >> > improve it :-)
> >> >
> >> > Bill-
> >> >
> >> >
> >> > On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <[hidden email]>
> >> wrote:
> >> >
> >> >> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
> >> >> [hidden email]
> >> >>> wrote:
> >> >>
> >> >>> As Luc said, it will big project to write a parser that takes any
> >> >>> equation as a string, and generate the matrix (2-dimensional array)
> to
> >> >>> feed it into Commons Math.
> >> >>>
> >> >>
> >> >>
> >> >> It actually isn't a big project.
> >> >>
> >> >> See http://www.antlr.org/
> >> >>
> >> >> The simplest example they give there is this one:
> >> >>
> >> >> *grammar Expr;*
> >> >> *prog: (expr NEWLINE)* ; *
> >> >> *expr: expr ('*'|'/') expr *
> >> >> *    | expr ('+'|'-') expr *
> >> >> *    | INT | '(' expr ')' ; *
> >> >> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
> >> >>
> >> >> This will compile into a java program that parses expressions very
> much
> >> >> like what you want.
> >> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Mansour Al Akeel
William,
I agree with you about the maturity and active community associated
with commons math.
I noticed other commons project are not as active.

Moving to a top level project, in my own opinion is valid, since the
math topic covers a big area, unlike other projects in commons where
they solve an focus on specific problem.

So beside the visibility (which is enough for me), what other
advantages do we get ??

By the way, even staying as we are under commons, does not really
prevent us from building these subprojects. We may get more
contributors if we go higher level, but not too early to consider
these subprojects under commons.





On Sun, Jul 27, 2014 at 7:42 PM, William Speirs <[hidden email]> wrote:

> I think the better idea would be to promote commons-math to it's own
> top-level project. It's a very impressive math library, and more active
> than some of the other commons projects.
>
> If made a top-level project then we could make subprojects like a parser,
> GUI, etc.
>
> Thoughts?
>
> Bill-
> On Jul 27, 2014 7:34 PM, "Mansour Al Akeel" <[hidden email]>
> wrote:
>
>> William,
>> Thank you a lot.
>>
>> Is there building instructions ?
>>
>> Are there any interest in creating/adding these efforts as
>> commons-math subproject.
>> I understand and agree with the point that a parser is outside of the
>> scope of commons-math, but may be we can create a subproject
>> "commons-math-sandbox" or "commons-math-ext" or
>> "commons-math-optional", that will host efforts and project related
>> but does not fit the scope. This will separate the concerns and allow
>> those who need this functionality to find it easily, at the same time
>> it will give the project a home, and make it available for wider
>> users.
>>
>> Is this a valid suggestion ?
>>
>>
>>
>>
>> On Mon, Jul 21, 2014 at 8:39 AM, William Speirs <[hidden email]>
>> wrote:
>> > Errr... nothing at the moment, but I'll make it Apache2 :-)
>> >
>> > Bill-
>> >
>> >
>> > On Mon, Jul 21, 2014 at 8:29 AM, Paul Libbrecht <[hidden email]>
>> wrote:
>> >
>> >> Coool. License?
>> >>
>> >> paul
>> >>
>> >>
>> >> On 21 juil. 2014, at 14:26, William Speirs <[hidden email]> wrote:
>> >>
>> >> > It's certainly incomplete, but I started working on a CAS (Computer
>> >> Algebra
>> >> > System: http://en.wikipedia.org/wiki/Computer_algebra_system) that
>> was
>> >> > "backed" by commons-math: https://github.com/wspeirs/math
>> >> >
>> >> > The JJT (parser file for JavaCC) file can be found here, and is fairly
>> >> > complete if I remember correctly:
>> >> >
>> >>
>> https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt
>> >> >
>> >> > I'd be happy to help you with it further and/or accept pull requests
>> to
>> >> > improve it :-)
>> >> >
>> >> > Bill-
>> >> >
>> >> >
>> >> > On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <[hidden email]>
>> >> wrote:
>> >> >
>> >> >> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
>> >> >> [hidden email]
>> >> >>> wrote:
>> >> >>
>> >> >>> As Luc said, it will big project to write a parser that takes any
>> >> >>> equation as a string, and generate the matrix (2-dimensional array)
>> to
>> >> >>> feed it into Commons Math.
>> >> >>>
>> >> >>
>> >> >>
>> >> >> It actually isn't a big project.
>> >> >>
>> >> >> See http://www.antlr.org/
>> >> >>
>> >> >> The simplest example they give there is this one:
>> >> >>
>> >> >> *grammar Expr;*
>> >> >> *prog: (expr NEWLINE)* ; *
>> >> >> *expr: expr ('*'|'/') expr *
>> >> >> *    | expr ('+'|'-') expr *
>> >> >> *    | INT | '(' expr ')' ; *
>> >> >> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
>> >> >>
>> >> >> This will compile into a java program that parses expressions very
>> much
>> >> >> like what you want.
>> >> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [hidden email]
>> >> For additional commands, e-mail: [hidden email]
>> >>
>> >>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Paul Libbrecht-4
I am definitely in favor of an independent component such as "formula-parser".

paul


On 28 juil. 2014, at 02:34, Mansour Al Akeel <[hidden email]> wrote:

> William,
> I agree with you about the maturity and active community associated
> with commons math.
> I noticed other commons project are not as active.
>
> Moving to a top level project, in my own opinion is valid, since the
> math topic covers a big area, unlike other projects in commons where
> they solve an focus on specific problem.
>
> So beside the visibility (which is enough for me), what other
> advantages do we get ??
>
> By the way, even staying as we are under commons, does not really
> prevent us from building these subprojects. We may get more
> contributors if we go higher level, but not too early to consider
> these subprojects under commons.
>
>
>
>
>
> On Sun, Jul 27, 2014 at 7:42 PM, William Speirs <[hidden email]> wrote:
>> I think the better idea would be to promote commons-math to it's own
>> top-level project. It's a very impressive math library, and more active
>> than some of the other commons projects.
>>
>> If made a top-level project then we could make subprojects like a parser,
>> GUI, etc.
>>
>> Thoughts?
>>
>> Bill-
>> On Jul 27, 2014 7:34 PM, "Mansour Al Akeel" <[hidden email]>
>> wrote:
>>
>>> William,
>>> Thank you a lot.
>>>
>>> Is there building instructions ?
>>>
>>> Are there any interest in creating/adding these efforts as
>>> commons-math subproject.
>>> I understand and agree with the point that a parser is outside of the
>>> scope of commons-math, but may be we can create a subproject
>>> "commons-math-sandbox" or "commons-math-ext" or
>>> "commons-math-optional", that will host efforts and project related
>>> but does not fit the scope. This will separate the concerns and allow
>>> those who need this functionality to find it easily, at the same time
>>> it will give the project a home, and make it available for wider
>>> users.
>>>
>>> Is this a valid suggestion ?
>>>
>>>
>>>
>>>
>>> On Mon, Jul 21, 2014 at 8:39 AM, William Speirs <[hidden email]>
>>> wrote:
>>>> Errr... nothing at the moment, but I'll make it Apache2 :-)
>>>>
>>>> Bill-
>>>>
>>>>
>>>> On Mon, Jul 21, 2014 at 8:29 AM, Paul Libbrecht <[hidden email]>
>>> wrote:
>>>>
>>>>> Coool. License?
>>>>>
>>>>> paul
>>>>>
>>>>>
>>>>> On 21 juil. 2014, at 14:26, William Speirs <[hidden email]> wrote:
>>>>>
>>>>>> It's certainly incomplete, but I started working on a CAS (Computer
>>>>> Algebra
>>>>>> System: http://en.wikipedia.org/wiki/Computer_algebra_system) that
>>> was
>>>>>> "backed" by commons-math: https://github.com/wspeirs/math
>>>>>>
>>>>>> The JJT (parser file for JavaCC) file can be found here, and is fairly
>>>>>> complete if I remember correctly:
>>>>>>
>>>>>
>>> https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt
>>>>>>
>>>>>> I'd be happy to help you with it further and/or accept pull requests
>>> to
>>>>>> improve it :-)
>>>>>>
>>>>>> Bill-
>>>>>>
>>>>>>
>>>>>> On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <[hidden email]>
>>>>> wrote:
>>>>>>
>>>>>>> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
>>>>>>> [hidden email]
>>>>>>>> wrote:
>>>>>>>
>>>>>>>> As Luc said, it will big project to write a parser that takes any
>>>>>>>> equation as a string, and generate the matrix (2-dimensional array)
>>> to
>>>>>>>> feed it into Commons Math.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> It actually isn't a big project.
>>>>>>>
>>>>>>> See http://www.antlr.org/
>>>>>>>
>>>>>>> The simplest example they give there is this one:
>>>>>>>
>>>>>>> *grammar Expr;*
>>>>>>> *prog: (expr NEWLINE)* ; *
>>>>>>> *expr: expr ('*'|'/') expr *
>>>>>>> *    | expr ('+'|'-') expr *
>>>>>>> *    | INT | '(' expr ')' ; *
>>>>>>> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
>>>>>>>
>>>>>>> This will compile into a java program that parses expressions very
>>> much
>>>>>>> like what you want.
>>>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Mansour Al Akeel
Paul, we are on the same page. We are looking for independent
component separated from apache commons-math, but as a subproject.
The value of keeping it under apache, is the visibility. What I have
in mind is a sub project "commons-math-extensions" or c-m-optional,
c-m-extra .. etc
This sub project has one maven groupId and multiple artifacts that may
belong to the math topic, but not a direct fit for commons-math.

The artifacts can include "formula-parser". Other packages that do not
directly fit in commons-math may move there.
For example some may argue (and I am not suggesting this) that genetic
algorithm is not a direct fit for commons-math and can be moved to
it's own component under that umbrella.





On Mon, Jul 28, 2014 at 2:39 AM, Paul Libbrecht <[hidden email]> wrote:

> I am definitely in favor of an independent component such as "formula-parser".
>
> paul
>
>
> On 28 juil. 2014, at 02:34, Mansour Al Akeel <[hidden email]> wrote:
>
>> William,
>> I agree with you about the maturity and active community associated
>> with commons math.
>> I noticed other commons project are not as active.
>>
>> Moving to a top level project, in my own opinion is valid, since the
>> math topic covers a big area, unlike other projects in commons where
>> they solve an focus on specific problem.
>>
>> So beside the visibility (which is enough for me), what other
>> advantages do we get ??
>>
>> By the way, even staying as we are under commons, does not really
>> prevent us from building these subprojects. We may get more
>> contributors if we go higher level, but not too early to consider
>> these subprojects under commons.
>>
>>
>>
>>
>>
>> On Sun, Jul 27, 2014 at 7:42 PM, William Speirs <[hidden email]> wrote:
>>> I think the better idea would be to promote commons-math to it's own
>>> top-level project. It's a very impressive math library, and more active
>>> than some of the other commons projects.
>>>
>>> If made a top-level project then we could make subprojects like a parser,
>>> GUI, etc.
>>>
>>> Thoughts?
>>>
>>> Bill-
>>> On Jul 27, 2014 7:34 PM, "Mansour Al Akeel" <[hidden email]>
>>> wrote:
>>>
>>>> William,
>>>> Thank you a lot.
>>>>
>>>> Is there building instructions ?
>>>>
>>>> Are there any interest in creating/adding these efforts as
>>>> commons-math subproject.
>>>> I understand and agree with the point that a parser is outside of the
>>>> scope of commons-math, but may be we can create a subproject
>>>> "commons-math-sandbox" or "commons-math-ext" or
>>>> "commons-math-optional", that will host efforts and project related
>>>> but does not fit the scope. This will separate the concerns and allow
>>>> those who need this functionality to find it easily, at the same time
>>>> it will give the project a home, and make it available for wider
>>>> users.
>>>>
>>>> Is this a valid suggestion ?
>>>>
>>>>
>>>>
>>>>
>>>> On Mon, Jul 21, 2014 at 8:39 AM, William Speirs <[hidden email]>
>>>> wrote:
>>>>> Errr... nothing at the moment, but I'll make it Apache2 :-)
>>>>>
>>>>> Bill-
>>>>>
>>>>>
>>>>> On Mon, Jul 21, 2014 at 8:29 AM, Paul Libbrecht <[hidden email]>
>>>> wrote:
>>>>>
>>>>>> Coool. License?
>>>>>>
>>>>>> paul
>>>>>>
>>>>>>
>>>>>> On 21 juil. 2014, at 14:26, William Speirs <[hidden email]> wrote:
>>>>>>
>>>>>>> It's certainly incomplete, but I started working on a CAS (Computer
>>>>>> Algebra
>>>>>>> System: http://en.wikipedia.org/wiki/Computer_algebra_system) that
>>>> was
>>>>>>> "backed" by commons-math: https://github.com/wspeirs/math
>>>>>>>
>>>>>>> The JJT (parser file for JavaCC) file can be found here, and is fairly
>>>>>>> complete if I remember correctly:
>>>>>>>
>>>>>>
>>>> https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt
>>>>>>>
>>>>>>> I'd be happy to help you with it further and/or accept pull requests
>>>> to
>>>>>>> improve it :-)
>>>>>>>
>>>>>>> Bill-
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <[hidden email]>
>>>>>> wrote:
>>>>>>>
>>>>>>>> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
>>>>>>>> [hidden email]
>>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> As Luc said, it will big project to write a parser that takes any
>>>>>>>>> equation as a string, and generate the matrix (2-dimensional array)
>>>> to
>>>>>>>>> feed it into Commons Math.
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> It actually isn't a big project.
>>>>>>>>
>>>>>>>> See http://www.antlr.org/
>>>>>>>>
>>>>>>>> The simplest example they give there is this one:
>>>>>>>>
>>>>>>>> *grammar Expr;*
>>>>>>>> *prog: (expr NEWLINE)* ; *
>>>>>>>> *expr: expr ('*'|'/') expr *
>>>>>>>> *    | expr ('+'|'-') expr *
>>>>>>>> *    | INT | '(' expr ')' ; *
>>>>>>>> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
>>>>>>>>
>>>>>>>> This will compile into a java program that parses expressions very
>>>> much
>>>>>>>> like what you want.
>>>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>
>>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

William Speirs
In reply to this post by Mansour Al Akeel
So here is an idea, let's not worry about where said project would live,
but focus on implementing/working on it. I'm happy to host it off my GitHub
and give anyone access that wants to play.

If people are really interested, then we should start by speccing out what
the "language" will look like. For example, is exponentiation going to be ^
or **?

I'd say let's start there, see how much traction we get, then we can figure
out where/how to host it.

Thoughts?

Bill-


On Mon, Jul 28, 2014 at 5:14 AM, Mansour Al Akeel <[hidden email]
> wrote:

> Paul, we are on the same page. We are looking for independent
> component separated from apache commons-math, but as a subproject.
> The value of keeping it under apache, is the visibility. What I have
> in mind is a sub project "commons-math-extensions" or c-m-optional,
> c-m-extra .. etc
> This sub project has one maven groupId and multiple artifacts that may
> belong to the math topic, but not a direct fit for commons-math.
>
> The artifacts can include "formula-parser". Other packages that do not
> directly fit in commons-math may move there.
> For example some may argue (and I am not suggesting this) that genetic
> algorithm is not a direct fit for commons-math and can be moved to
> it's own component under that umbrella.
>
>
>
>
>
> On Mon, Jul 28, 2014 at 2:39 AM, Paul Libbrecht <[hidden email]> wrote:
> > I am definitely in favor of an independent component such as
> "formula-parser".
> >
> > paul
> >
> >
> > On 28 juil. 2014, at 02:34, Mansour Al Akeel <[hidden email]>
> wrote:
> >
> >> William,
> >> I agree with you about the maturity and active community associated
> >> with commons math.
> >> I noticed other commons project are not as active.
> >>
> >> Moving to a top level project, in my own opinion is valid, since the
> >> math topic covers a big area, unlike other projects in commons where
> >> they solve an focus on specific problem.
> >>
> >> So beside the visibility (which is enough for me), what other
> >> advantages do we get ??
> >>
> >> By the way, even staying as we are under commons, does not really
> >> prevent us from building these subprojects. We may get more
> >> contributors if we go higher level, but not too early to consider
> >> these subprojects under commons.
> >>
> >>
> >>
> >>
> >>
> >> On Sun, Jul 27, 2014 at 7:42 PM, William Speirs <[hidden email]>
> wrote:
> >>> I think the better idea would be to promote commons-math to it's own
> >>> top-level project. It's a very impressive math library, and more active
> >>> than some of the other commons projects.
> >>>
> >>> If made a top-level project then we could make subprojects like a
> parser,
> >>> GUI, etc.
> >>>
> >>> Thoughts?
> >>>
> >>> Bill-
> >>> On Jul 27, 2014 7:34 PM, "Mansour Al Akeel" <[hidden email]
> >
> >>> wrote:
> >>>
> >>>> William,
> >>>> Thank you a lot.
> >>>>
> >>>> Is there building instructions ?
> >>>>
> >>>> Are there any interest in creating/adding these efforts as
> >>>> commons-math subproject.
> >>>> I understand and agree with the point that a parser is outside of the
> >>>> scope of commons-math, but may be we can create a subproject
> >>>> "commons-math-sandbox" or "commons-math-ext" or
> >>>> "commons-math-optional", that will host efforts and project related
> >>>> but does not fit the scope. This will separate the concerns and allow
> >>>> those who need this functionality to find it easily, at the same time
> >>>> it will give the project a home, and make it available for wider
> >>>> users.
> >>>>
> >>>> Is this a valid suggestion ?
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> On Mon, Jul 21, 2014 at 8:39 AM, William Speirs <[hidden email]>
> >>>> wrote:
> >>>>> Errr... nothing at the moment, but I'll make it Apache2 :-)
> >>>>>
> >>>>> Bill-
> >>>>>
> >>>>>
> >>>>> On Mon, Jul 21, 2014 at 8:29 AM, Paul Libbrecht <[hidden email]>
> >>>> wrote:
> >>>>>
> >>>>>> Coool. License?
> >>>>>>
> >>>>>> paul
> >>>>>>
> >>>>>>
> >>>>>> On 21 juil. 2014, at 14:26, William Speirs <[hidden email]>
> wrote:
> >>>>>>
> >>>>>>> It's certainly incomplete, but I started working on a CAS (Computer
> >>>>>> Algebra
> >>>>>>> System: http://en.wikipedia.org/wiki/Computer_algebra_system) that
> >>>> was
> >>>>>>> "backed" by commons-math: https://github.com/wspeirs/math
> >>>>>>>
> >>>>>>> The JJT (parser file for JavaCC) file can be found here, and is
> fairly
> >>>>>>> complete if I remember correctly:
> >>>>>>>
> >>>>>>
> >>>>
> https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt
> >>>>>>>
> >>>>>>> I'd be happy to help you with it further and/or accept pull
> requests
> >>>> to
> >>>>>>> improve it :-)
> >>>>>>>
> >>>>>>> Bill-
> >>>>>>>
> >>>>>>>
> >>>>>>> On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <
> [hidden email]>
> >>>>>> wrote:
> >>>>>>>
> >>>>>>>> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
> >>>>>>>> [hidden email]
> >>>>>>>>> wrote:
> >>>>>>>>
> >>>>>>>>> As Luc said, it will big project to write a parser that takes any
> >>>>>>>>> equation as a string, and generate the matrix (2-dimensional
> array)
> >>>> to
> >>>>>>>>> feed it into Commons Math.
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> It actually isn't a big project.
> >>>>>>>>
> >>>>>>>> See http://www.antlr.org/
> >>>>>>>>
> >>>>>>>> The simplest example they give there is this one:
> >>>>>>>>
> >>>>>>>> *grammar Expr;*
> >>>>>>>> *prog: (expr NEWLINE)* ; *
> >>>>>>>> *expr: expr ('*'|'/') expr *
> >>>>>>>> *    | expr ('+'|'-') expr *
> >>>>>>>> *    | INT | '(' expr ')' ; *
> >>>>>>>> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
> >>>>>>>>
> >>>>>>>> This will compile into a java program that parses expressions very
> >>>> much
> >>>>>>>> like what you want.
> >>>>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: [hidden email]
> >>>>>> For additional commands, e-mail: [hidden email]
> >>>>>>
> >>>>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: [hidden email]
> >>>> For additional commands, e-mail: [hidden email]
> >>>>
> >>>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

William Speirs
For anyone who cares (and maybe we should take this off the mailing list) I
updated the now called MathBlotter to use Maven to construct the JJTree
files. It *should* compile, but fails on some tests. It will run though and
render equations in pretty LaTeX output.
https://github.com/wspeirs/MathBlotter

Again, any help would be greatly appreciated...

Bill-


On Mon, Jul 28, 2014 at 10:16 AM, William Speirs <[hidden email]> wrote:

> So here is an idea, let's not worry about where said project would live,
> but focus on implementing/working on it. I'm happy to host it off my GitHub
> and give anyone access that wants to play.
>
> If people are really interested, then we should start by speccing out what
> the "language" will look like. For example, is exponentiation going to be ^
> or **?
>
> I'd say let's start there, see how much traction we get, then we can
> figure out where/how to host it.
>
> Thoughts?
>
> Bill-
>
>
> On Mon, Jul 28, 2014 at 5:14 AM, Mansour Al Akeel <
> [hidden email]> wrote:
>
>> Paul, we are on the same page. We are looking for independent
>> component separated from apache commons-math, but as a subproject.
>> The value of keeping it under apache, is the visibility. What I have
>> in mind is a sub project "commons-math-extensions" or c-m-optional,
>> c-m-extra .. etc
>> This sub project has one maven groupId and multiple artifacts that may
>> belong to the math topic, but not a direct fit for commons-math.
>>
>> The artifacts can include "formula-parser". Other packages that do not
>> directly fit in commons-math may move there.
>> For example some may argue (and I am not suggesting this) that genetic
>> algorithm is not a direct fit for commons-math and can be moved to
>> it's own component under that umbrella.
>>
>>
>>
>>
>>
>> On Mon, Jul 28, 2014 at 2:39 AM, Paul Libbrecht <[hidden email]>
>> wrote:
>> > I am definitely in favor of an independent component such as
>> "formula-parser".
>> >
>> > paul
>> >
>> >
>> > On 28 juil. 2014, at 02:34, Mansour Al Akeel <[hidden email]>
>> wrote:
>> >
>> >> William,
>> >> I agree with you about the maturity and active community associated
>> >> with commons math.
>> >> I noticed other commons project are not as active.
>> >>
>> >> Moving to a top level project, in my own opinion is valid, since the
>> >> math topic covers a big area, unlike other projects in commons where
>> >> they solve an focus on specific problem.
>> >>
>> >> So beside the visibility (which is enough for me), what other
>> >> advantages do we get ??
>> >>
>> >> By the way, even staying as we are under commons, does not really
>> >> prevent us from building these subprojects. We may get more
>> >> contributors if we go higher level, but not too early to consider
>> >> these subprojects under commons.
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> On Sun, Jul 27, 2014 at 7:42 PM, William Speirs <[hidden email]>
>> wrote:
>> >>> I think the better idea would be to promote commons-math to it's own
>> >>> top-level project. It's a very impressive math library, and more
>> active
>> >>> than some of the other commons projects.
>> >>>
>> >>> If made a top-level project then we could make subprojects like a
>> parser,
>> >>> GUI, etc.
>> >>>
>> >>> Thoughts?
>> >>>
>> >>> Bill-
>> >>> On Jul 27, 2014 7:34 PM, "Mansour Al Akeel" <
>> [hidden email]>
>> >>> wrote:
>> >>>
>> >>>> William,
>> >>>> Thank you a lot.
>> >>>>
>> >>>> Is there building instructions ?
>> >>>>
>> >>>> Are there any interest in creating/adding these efforts as
>> >>>> commons-math subproject.
>> >>>> I understand and agree with the point that a parser is outside of the
>> >>>> scope of commons-math, but may be we can create a subproject
>> >>>> "commons-math-sandbox" or "commons-math-ext" or
>> >>>> "commons-math-optional", that will host efforts and project related
>> >>>> but does not fit the scope. This will separate the concerns and allow
>> >>>> those who need this functionality to find it easily, at the same time
>> >>>> it will give the project a home, and make it available for wider
>> >>>> users.
>> >>>>
>> >>>> Is this a valid suggestion ?
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>> On Mon, Jul 21, 2014 at 8:39 AM, William Speirs <[hidden email]>
>> >>>> wrote:
>> >>>>> Errr... nothing at the moment, but I'll make it Apache2 :-)
>> >>>>>
>> >>>>> Bill-
>> >>>>>
>> >>>>>
>> >>>>> On Mon, Jul 21, 2014 at 8:29 AM, Paul Libbrecht <[hidden email]>
>> >>>> wrote:
>> >>>>>
>> >>>>>> Coool. License?
>> >>>>>>
>> >>>>>> paul
>> >>>>>>
>> >>>>>>
>> >>>>>> On 21 juil. 2014, at 14:26, William Speirs <[hidden email]>
>> wrote:
>> >>>>>>
>> >>>>>>> It's certainly incomplete, but I started working on a CAS
>> (Computer
>> >>>>>> Algebra
>> >>>>>>> System: http://en.wikipedia.org/wiki/Computer_algebra_system)
>> that
>> >>>> was
>> >>>>>>> "backed" by commons-math: https://github.com/wspeirs/math
>> >>>>>>>
>> >>>>>>> The JJT (parser file for JavaCC) file can be found here, and is
>> fairly
>> >>>>>>> complete if I remember correctly:
>> >>>>>>>
>> >>>>>>
>> >>>>
>> https://raw.githubusercontent.com/wspeirs/Math/master/src/main/java/com/educatedsolutions/parser/Math.jjt
>> >>>>>>>
>> >>>>>>> I'd be happy to help you with it further and/or accept pull
>> requests
>> >>>> to
>> >>>>>>> improve it :-)
>> >>>>>>>
>> >>>>>>> Bill-
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> On Mon, Jul 21, 2014 at 1:59 AM, Ted Dunning <
>> [hidden email]>
>> >>>>>> wrote:
>> >>>>>>>
>> >>>>>>>> On Sun, Jul 20, 2014 at 9:18 PM, Mansour Al Akeel <
>> >>>>>>>> [hidden email]
>> >>>>>>>>> wrote:
>> >>>>>>>>
>> >>>>>>>>> As Luc said, it will big project to write a parser that takes
>> any
>> >>>>>>>>> equation as a string, and generate the matrix (2-dimensional
>> array)
>> >>>> to
>> >>>>>>>>> feed it into Commons Math.
>> >>>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>> It actually isn't a big project.
>> >>>>>>>>
>> >>>>>>>> See http://www.antlr.org/
>> >>>>>>>>
>> >>>>>>>> The simplest example they give there is this one:
>> >>>>>>>>
>> >>>>>>>> *grammar Expr;*
>> >>>>>>>> *prog: (expr NEWLINE)* ; *
>> >>>>>>>> *expr: expr ('*'|'/') expr *
>> >>>>>>>> *    | expr ('+'|'-') expr *
>> >>>>>>>> *    | INT | '(' expr ')' ; *
>> >>>>>>>> *NEWLINE : [\r\n]+ ; INT : [0-9]+ ;*
>> >>>>>>>>
>> >>>>>>>> This will compile into a java program that parses expressions
>> very
>> >>>> much
>> >>>>>>>> like what you want.
>> >>>>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> ---------------------------------------------------------------------
>> >>>>>> To unsubscribe, e-mail: [hidden email]
>> >>>>>> For additional commands, e-mail: [hidden email]
>> >>>>>>
>> >>>>>>
>> >>>>
>> >>>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail: [hidden email]
>> >>>> For additional commands, e-mail: [hidden email]
>> >>>>
>> >>>>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [hidden email]
>> >> For additional commands, e-mail: [hidden email]
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Paul Libbrecht-4
In reply to this post by William Speirs
Send an announce to [hidden email]?
I'm happy to do that.

Aim at ASCIIIMath syntax?

paul


On 28 juil. 2014, at 16:16, William Speirs <[hidden email]> wrote:

> So here is an idea, let's not worry about where said project would live,
> but focus on implementing/working on it. I'm happy to host it off my GitHub
> and give anyone access that wants to play.
>
> If people are really interested, then we should start by speccing out what
> the "language" will look like. For example, is exponentiation going to be ^
> or **?
>
> I'd say let's start there, see how much traction we get, then we can figure
> out where/how to host it.
>
> Thoughts?

Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

William Speirs
Seems like it's more for entering math formulas for display than for
computation: http://www.intmath.com/help/send-math-email-syntax.php

Like I don't think we care about a/b vs a//b (regular vs inline fractions).
For this, it's the same, right? Thoughts?

Bill-
On Jul 28, 2014 3:03 PM, "Paul Libbrecht" <[hidden email]> wrote:

> Send an announce to [hidden email]?
> I'm happy to do that.
>
> Aim at ASCIIIMath syntax?
>
> paul
>
>
> On 28 juil. 2014, at 16:16, William Speirs <[hidden email]> wrote:
>
> > So here is an idea, let's not worry about where said project would live,
> > but focus on implementing/working on it. I'm happy to host it off my
> GitHub
> > and give anyone access that wants to play.
> >
> > If people are really interested, then we should start by speccing out
> what
> > the "language" will look like. For example, is exponentiation going to
> be ^
> > or **?
> >
> > I'd say let's start there, see how much traction we get, then we can
> figure
> > out where/how to host it.
> >
> > Thoughts?
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

Michael Pigott
So here are some random thoughts / questions I had:

1. Would this be significantly different from SymJa?
https://bitbucket.org/axelclk/symja_android_library/wiki/Home
2. Should this be an implementation of an existing spec, like RPN or
MathML, or do we need a new one?
3. Will the language be interpreted, or will Java code be generated, or
will JSR 199 be used to invoke the Java compiler?

Thanks,
Mike
On Jul 28, 2014 6:42 PM, "William Speirs" <[hidden email]> wrote:

> Seems like it's more for entering math formulas for display than for
> computation: http://www.intmath.com/help/send-math-email-syntax.php
>
> Like I don't think we care about a/b vs a//b (regular vs inline fractions).
> For this, it's the same, right? Thoughts?
>
> Bill-
> On Jul 28, 2014 3:03 PM, "Paul Libbrecht" <[hidden email]> wrote:
>
> > Send an announce to [hidden email]?
> > I'm happy to do that.
> >
> > Aim at ASCIIIMath syntax?
> >
> > paul
> >
> >
> > On 28 juil. 2014, at 16:16, William Speirs <[hidden email]> wrote:
> >
> > > So here is an idea, let's not worry about where said project would
> live,
> > > but focus on implementing/working on it. I'm happy to host it off my
> > GitHub
> > > and give anyone access that wants to play.
> > >
> > > If people are really interested, then we should start by speccing out
> > what
> > > the "language" will look like. For example, is exponentiation going to
> > be ^
> > > or **?
> > >
> > > I'd say let's start there, see how much traction we get, then we can
> > figure
> > > out where/how to host it.
> > >
> > > Thoughts?
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Parsing and solving algebraic equation from string

William Speirs
Someone else who is more experienced please jump-in here. My $0.02...

1. Would this be significantly different from SymJa?
> https://bitbucket.org/axelclk/symja_android_library/wiki/Home


I think we're talking about two different thing:

1) Mansour was asking for a library that can take a string and returned
some sort of AST for mathematical equations. Maybe it would also produce a
tree of components that are found in commons-math.

2) I'm looking at/working on a GUI that can take a string, display it in
LaTex output, and also produce a tree structure of components found in
commons-math. Then this tree would be evaluated/interpreted to produce an
output for the user. My project is akin to commons-math + parser +
evaluator/interpreter.

I don't know enough about SymJa, but it looks to be much closer to #2 than
#1 -- which isn't to say that it doesn't already contain #1 in it. It looks
like JAS (which SymJa uses) does a lot of this:
http://krum.rz.uni-mannheim.de/jas/


> 2. Should this be an implementation of an existing spec, like RPN or
> MathML, or do we need a new one?
>

My goal was to match the Maple "spec" as closely as possible. It's fairly
close to LaTex (again, LaTex has more syntax for formatting than needed
here). I went with that primarily because I know Maple and didn't know
about RPN or MathML :-) Also, I'm looking for things like A := 2*x + 3
where you're assigning an equation to the "variable" A.


> 3. Will the language be interpreted, or will Java code be generated, or
> will JSR 199 be used to invoke the Java compiler?
>

My thought would be the resulting tree structure from after parsing would
be evaluated/interpreted and the result presented to the user.

The site seems to be down, but I think you can play around with a demo
version of Maple here: http://www.maplesoft.com/products/maple/demo/

That is what I'm going for... thoughts?

Bill-
12