Skip to content

Incorrect expression evaluation #105

@cesar-ioc

Description

@cesar-ioc

I'm trying to evaluate the following expression:

sin x - (0.02449*x^3)-(1.67049*x)+(64.85606+(0.33683*x^2))+(sin (2*x))

Using this code:

String equation = "sin x - (0.02449*x^3)-(1.67049*x)+(64.85606+(0.33683*x^2))+(sin (2*x))";

Expression exp = new ExpressionBuilder(equation)
					.variables("x")
					.build()
					.setVariable("x", 1);

System.out.println(exp.evaluate()); // prints 0.5364612580927792

But according to WolframAlpha the correct result is 65.2487
Here is the direct link to WolframAlpha

I'm using version 0.4.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions