On 22/02/2019 01:57, Phu Nguyen wrote: > im actually interested in comparing two OpenMath-Objects with each other > in terms of equality (despite being build a bit differently in XML) by > using Java. > > For example I want "x^2+2x-35=0" to be equal to "-35+2x+x^2=0". > > So im wondering if there is a way to achieve this. I at least understand > OpenMath as some sort of tree structure and thought there might be a way > to compare them. > > I already tried writing the expressions for those two equations, but > ended up with no luck or good idea. > > *|Equation 1: x^2+2x-35=0|*/|<OMOBJ xmlns='http://www.openmath.org/OpenMath' > version='2.0' > cdbase='http://www.openmath.org/cd'> <OMA> <OMS cd='relation1' > name='eq'/> <OMA> <OMS cd='arith1' name='minus'/> <OMA> <OMS cd='arith1' > name='plus'/> <OMA> <OMS cd='arith1' name='power'/> <OMV name='x'/> > <OMI> 2 </OMI> </OMA> <OMA style='invisible'> <OMS cd='arith1' > name='times'/> <OMI> 2 </OMI> <OMV name='x'/> </OMA> </OMA> <OMI> 35 > </OMI> </OMA> <OMI> 0 </OMI> </OMA> </OMOBJ> |/*|Equation 2: > -35+2x+x^2|*/|<OMOBJ xmlns='http://www.openmath.org/OpenMath' version='2.0' > cdbase='http://www.openmath.org/cd'> <OMA> <OMS cd='relation1' > name='eq'/> <OMA> <OMS cd='arith1' name='plus'/> <OMA> <OMS cd='arith1' > name='unary_minus'/> <OMI> 35 </OMI> </OMA> <OMA style='invisible'> <OMS > cd='arith1' name='times'/> <OMI> 2 </OMI> <OMV name='x'/> </OMA> <OMA> > <OMS cd='arith1' name='power'/> <OMV name='x'/> <OMI> 2 </OMI> </OMA> > </OMA> <OMI> 0 </OMI> </OMA> </OMOBJ>|/ > > Thank you for your time > > Sincerely > > Phu >
The usual OpenMath model is that it encodes the data in a system-neutral way, but reasoning about that data happens in the application, so typically you'd import the two OpenMath polynomials into a computer algebra system test for equality and write out an OpenMath boolean. If writing custom code it would be easier to check for equality if using a specific more constrained polynomial constructor rather than generic symbolic arith1 expressions. unfortunately there are several possible formulations so all are classed as experimental but in for example https://www.openmath.org/cd/polyr.html such a polynomial is just modelled as a sequence of the coefficients in order of exponent on the variable, and so the two forms you show would be normalized to the same thing while creating the OpenMath (which may or may not be a good thing, depending on the use case) David Disclaimer The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.
_______________________________________________ Om mailing list Om@openmath.org http://mailman.openmath.org/cgi-bin/mailman/listinfo/om