Simplifying equations with a custom division operator

20 görüntüleme
İlk okunmamış mesaja atla

João Francisco Barreto da Silva Martins

okunmadı,
27 Kas 2017 02:53:2227.11.2017
alıcı Jep Java Users
Hello everyone,

I have a custom division operator implemented called the Analytic Quotient operator(AQ), which represents divisions as d/sqrt(1 + q²). Is it possible for JEP to simplify equations with this operator represented as "AQ" in the string, and if so, how can it be done? Thanks in advance.

Richard Morris

okunmadı,
28 Kas 2017 11:46:1528.11.2017
alıcı Jep Java Users
Following on from the previous reply.

It certainly possible to add a new operator to Jep, see http://singularsys.com/jep/doc/html/operators.html for details. So being able to parse
"d AQ q" is possible.

As i mentioned in the previous post standard Jep does not have many symbolic capabilities. The upcoming extensions do allow custom rewrite rules to be specified. 

Here you will be able to specify a rewite rule

public interface RewriteRuleI extends JepComponent {
/** 
* Returns true if node needs to be rewritten, according to this rule. 
* @throws ParseException if for some reason rewriting cannot be performed.
**/
public boolean test(ASTFunNode node,Node children[]) throws ParseException;
/** Rewrites the node
* @throws JepException */
public Node apply(ASTFunNode node,Node children[]) throws ParseException, JepException;
}

and there will be methods which walk through the parse tree applying the rule. So you might be able to specify a rule so that the 
expression 

"a AQ b AQ c" is rewritten as "a AQ (b+c)"

or whatever the correct expression is. 

Hope that helps

Richard  

João Francisco Barreto da Silva Martins

okunmadı,
28 Kas 2017 13:20:1928.11.2017
alıcı Jep Java Users
Hello Richard, thanks for your answer. I'm mainly interested in XJep, for it's Expression to String and Expression Simplification capabilities. I can substitute the AQ for a Protected Division, which will use the normal division operator. This operator should substitute the result by the constant 1 when the quotient is 0, but I think I'm not going to be able to reproduce this behaviour while simplifying expressions with XJep, will I? 

I'm going to have a try with XJep now and I'm hoping it can do what I want, as it is only the simplification of simple equations with the basic operators(+, -, *, /). In my equations there are some parts with Euler's number to some exponents, which doesn't need to be simplified. Can any other Java library do this kind of thing?

João Francisco Barreto da Silva Martins

okunmadı,
28 Kas 2017 13:41:2928.11.2017
alıcı Jep Java Users
Richard, XJep wasn't the right tool for me because it can't simplify expressions like (2*x^2 + x^2) to 3*x^2. Will your future extensions be able to do this? Do you know any Java library that can do this? 

Richard Morris

okunmadı,
28 Kas 2017 16:28:4928.11.2017
alıcı Jep Java Users


On Tuesday, 28 November 2017 18:41:29 UTC, João Francisco Barreto da Silva Martins wrote:
Richard, XJep wasn't the right tool for me because it can't simplify expressions like (2*x^2 + x^2) to 3*x^2. Will your future extensions be able to do this? Do you know any Java library that can do this? 

The new package builds on XJep and adds a new simplification algorithm based on conversion to polynomials. It can simplify (2*x^2 + x^2) to 3*x^2.  But not much more than that. Its not clever enough to simplify (x^2-1) / ( x + 1) to (x - 1).

Richard
Tümünü yanıtla
Yazarı yanıtla
Yönlendir
0 yeni ileti