Git Product home page Git Product logo

Comments (10)

mossadal avatar mossadal commented on September 27, 2024 1

Ok, that's a little weird, I will look into it.

0*log(0) should certainly return NAN or possibly throw an exception. As a mathematician, I prefer to leave 0^0 undefined, even though I realize that 0^0=1 is often a useful convention.

(It's not hard to write a custom Evaluator making sure 0^0 returns 1, though.)

from math-parser.

mossadal avatar mossadal commented on September 27, 2024 1

@byCedric Thank you for the report, I think that should fix it.

from math-parser.

mossadal avatar mossadal commented on September 27, 2024 1

@byCedric Looking forward to it!

from math-parser.

byCedric avatar byCedric commented on September 27, 2024

Haha, I will never force a mathematician to some common conventions. Thanks for the tip on creating a custom evaluator, will definitely look into it. If I can help, you can message me anytime. Again, thanks for this library and your quick response!

from math-parser.

mossadal avatar mossadal commented on September 27, 2024

I had a look at the 0*log(0) issue. It is due to some slightly overaggressive simplification in the parser. I will think of how to fix this without losing some simplifications that I'd like to keep, but it might take a few days.

In the meantime (and for your use case, it won't hurt much), try

$parser = new StdMathParser(); // or RationalMathParser if you prefer
$parser->setSimplifying(false);

and 0*log(0) will evaluate to NAN as expected.

from math-parser.

mossadal avatar mossadal commented on September 27, 2024

Actually, with setSimplifying(false), you will also get 0^0 = 1 for free.

from math-parser.

byCedric avatar byCedric commented on September 27, 2024

You are the best! If I can help you on something, you can always message me. Thanks you once again for your quick response and good workarounds!

from math-parser.

byCedric avatar byCedric commented on September 27, 2024

I don't know if this is related or if I should open up a new issue. Right now we have an exception (non math-exception) being thrown when the expression !1 is being evaluated.

With version 1.2.3 this threw an UnknownTokenException: Unknown token 0 encountered in Lexing/Lexer.php on line 85 which is correct. But as of 1.3.3 a Uncaught Error: Call to a member function accept() on null in Interpreting/Evaluator.php:186 is being thrown. I briefly tried to find the cause, but I'm still searching.

from math-parser.

mossadal avatar mossadal commented on September 27, 2024

This doesn't seem to be related. 1.3.0 added support for factorials, so "!1" shouldn't throw a UnknownTokenException, but it should throw a SyntaxErrorException instead. It seems like some malformed expressions containing ! slips through the Parser. I'll check it out.

from math-parser.

byCedric avatar byCedric commented on September 27, 2024

Thank you once again for your quick fix! If you are ever visiting Amsterdam I will buy you a beer or something!

from math-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.