import cam.symfun.*; public class SFtest4 { // //###################################################################### // // Create and then evaluate a SymbolicFunction that // implements function a*x^2 + b*x + c where // a, b, and c are symbolic constants. // //###################################################################### // public static void main(String[] args) { SymbolicFunction Sym = new SymbolicFunction(); String[] V = new String[1]; V[0] = new String("x"); // x = ind. variable String[] C = new String[3]; // array for symbolic constants C[0] = new String("a"); C[1] = new String("b"); C[2] = new String("c"); double [] Cvalues = {1.0, 2.0, 1.0}; // initial values of a,b,c String E = "a*x^2 + b*x + c"; try { Sym.initialize(V,C,Cvalues,E); } catch(Exception e) { System.out.println(e.getMessage()); } double val = Sym.evaluate(1.0); System.out.println(" SymbolicFunction F = " + Sym.getConstructorString()); System.out.println(" With " + Sym.getConstantName(0) + " = " + Sym.getConstantValue(0)); System.out.println(" With " + Sym.getConstantName(1) + " = " + Sym.getConstantValue(1)); System.out.println(" With " + Sym.getConstantName(2) + " = " + Sym.getConstantValue(2)); System.out.println(" Evaluated at x = 1.0 is : " + val); // // Pause command window // System.out.println(" "); System.out.println(" Program End : Hit Return to Continue "); java.io.BufferedReader d = new java.io.BufferedReader (new java.io.InputStreamReader(System.in)); try{d.readLine();}catch(Exception e){}; } }