Faster Plotting

By means of the speed parameter

The default value of the speed parameter is 4. This means that one in every four pixels is calculated and the graph is drawn by connecting these pixels by line segments. When greater accuracy is needed the speed parameter may be set to a lower value. Setting the speed parameter to 1 is a factor 4 slower then with the default setting.
For some graphs speed may also be set to a higher value, say 6, 8 or even 10, without much loss to the graph drawn. When set to 10 the speed gain is about a factor 2.5 with respect to the default value of 4.
Try to experiment which setting of speed gives the best result for the given functions.

The user function

When a function value starts with the word 'user', like this:

<PARAM name=function3 value="user............>

GraphApplet does not present the function string to the eval method in Eval.class from the Lundin Symbolic Math package but to one of the methods of user.class. This class is primarily meant for those that have access to a JAVA compiler to compile their own functions with. The speed gain is obtained by not using a general string evaluator but only precompiled functions.
People that do not have access to a JAVA compiler may profit from the functions compiled into the user.class that is part of this distribution.
Three types
GraphApplet recognises 3 types of user methods. These types are:
  1. user
    This type is entered as follows
    <PARAM name=function2 value="user">

    Only one function of this type can be present. In the version of user.class in this distribution it is the function y=sin(x)+cos(x)
    Note 1: it is not the function number that matters; it could also have been function1 or function4
    Note 2: only the current value of x is presented to the method double f(double x) in user.class. Those that want to change this function should alter it in user.java and compile user.class again.

  2. user:text
    For GraphApplet to use this type something like the following should be entered:
    <PARAM name=function2 value="user:text">

    Everything after user: is presented as functie to the method double f(String functie,double x) in user.class.
    In the version of user.class in this distribution text can be 1,2,3,4,5. This not a property of GraphApplet but of this version of user.class.
    The functions compiled into user.class are
    user:1sin
    user:2cos
    user:3tan
    user:4exp
    user:5abs
    So entering: <PARAM name=function2 value="user:2"> will draw the cosine function.
    >Look at this example to see these functions at work

    Note 1: Adding new functions is straightforward: look at the syntax in the method double f(String functie,double x) and you can add other functions and compile user.class again
    Note 2: You can also invent a new scheme that uses names instead of numbers. That's up to the one that compiles user.class. The only thing that may not be altered is the heading of the method.

  3. user:text;parameterlist
    For GraphApplet to use this type something like the following should be entered:
    <PARAM name=function2 value="user:text";a=1,2;b=1,3,4>

    First of all GraphApplet calculates the possible combinations of the parameters in the parameterlist. All combinations are then one after another stored in something called a hashtable. The part text part between user: and the paramterlist together with the hashtable is then presented to to the method double f(String functie,double x, Hashtable h) in user.class.
    In the version of user.class in this distribution text can be sin, cos, par, part, exp, power, line . This not a property of GraphApplet but of this version of user.class.
    The functions so compiled into user.class are
    siny=a+b*sin(x+c)
    cosy=a+b*cos(x+c)
    parthe parabola:y=ax2+bx+c
    partthe parabola: y=a(x-b)2+c
    expy=a*ebx+c
    powery=a*xb+c
    liney=ax+b
    So entering: <PARAM name=function1 value="user:line;a=2,3;b=1,5"> will draw the lines y=2x+1, y=2x+5, y=3x+1 and y=3x+5
    >Look at this example to see these functions at work

    Note 1: As you can see the only parameters allowed in this version of user.class are a, b and c. Between different functions these parameters are not cleared. Omitting them in a function call that needs them may give rise to unpredictable results.
    Note 2: Looking at the syntax of this method you can add new functions as you wish and compile user.class again. Should you wish to use more or different parameters you can use the provided method double getvar(String var,Hashtable h) that is also part of user.class
    Note 3: When you do not use the built in string evaluator but only functions described by the user prefix you can better use uGraphApplet instead of GraphApplet. uGraphApplet does not mention Eval.class from the Lundin Symbolic Mathpackage. The subdirectory lundin needs not to be present when using uGraphApplet instead of GraphApplet. This decreases download time when viewed over the web.