Hello,

it would be nice to have an interpreter for mathematical expressions so that 
functions may be defined at runtime.

Example for f(x):

  ExpInter ei = new ExpInter();
  ei.setFunction("ln(3*sin(2*x)+3)");
  // Plot the function:
  for (double x=0.0;x<3.0;x+=0.1) {
    y = ei(x);
    // ... do something useful with x,y
  }

Can be expanded to f(x,y) or functions wit params f(x,p1,p2,p3):

  ei.setFunction("1+p0*x-5*p1*(p2+7)*p3/x");
  double[] params = { 1.0, 2.0, 4.0, -1 };
  ei.setParams(params);
  // plot ....

If the interpreter implements UnivariateFunction it would be even nicer:

ExpInter function = new ExpInter("x^3-2*x^2+x-27");
double root = solver.solve(99999, function, 0.0, 5.0);
System.out.println("root is " + root + " / " + function.value(root));

function.setFunction("sin(x)");
root = solver.solve(99999, function, 3.0, 4.0);
System.out.println("root is " + root + " / " + function.value(root));

Result:
de.guenther.roots.RegulaFalsi:
        [java] root is 3.7009897720655234 / 0.0
        [java] root is 3.141592653589793 / 1.2246467991473532E-16

I may post my interpreter.

Kind regards

Detlef Guenther


-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                          
        
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to