The purpose of this applet is to illustrate function combinations. It shows the graphs of three functions, f(x), g(x), and h(x), with h(x) usually being defined as some combination of the others (e.g., h(x) = f(x) + g(x)). An applet parameter can be used to turn on the display of tangent lines at each of these points, in order to illustrate the sum and difference rules for calculus. Here is what the applet looks like with no applet params:
You can implement another version of the applet with the following button. This example is configured to show tangent lines and the slope of each tangent line. The applet will respond to mouse actions on the canvas (click, shift-click, click-and-drag, and right-click-and-drag). Note that each coordinate rect can be resized independently using these actions, but the buttons at the lower right affect all the coordinate rects. The applet is also configured with several loadable examples.
Here is the applet tag for this version:<applet archive="webcompmath.jar" code="net.sourceforge.webcompmath.applets.FunctionCombination" width=200 height=35>
<param name="UseMouseZoom" value="yes">
<param name="UsePanner" value="yes">
<param name="ShowTangents" value="yes">
<param name="Example1" value="f(x) + g(x); x; sin(x);f(x)+g(x); -5 5 -5 5 1">
<param name="Example2" value="f(x) - g(x); x; sin(x);f(x)-g(x); -5 5 -5 5 1">
<param name="Example3" value="f(x) * g(x); x; sin(x);f(x)*g(x); -5 5 -5 5 1">
<param name="Example4" value="f(x) / g(x); x; sin(x);f(x)/g(x); -5 5 -5 5 1">
FunctionCombination inherits from GenericGraphApplet. However, a lot of the code from GenericGraphApplet is superceded. In particular, it is not possible to have a limit control panel in FunctionCombination. The following applet params from GenericGraphApplet that affect the limit control panel have no effect in FunctionCombination: "UseLimitsPanel", "TwoColumnLimits", "LimitsOnLeft", "SetLimitsButton", "UseZoomButtons", "UseRestoreButton", and "UseEqualizeButton". The Zoom, Equalize, and Restore buttons that appear in a FunctionCombination applet are added if the applet param "UseFunctionInput" is yes. If "UseFunctionInput" is "no", then the buttons do not appear and there is no way to add them.
Most of the other applet params from GenericGraphApplet should work as expected with FunctionCombination. Here are the additional applet params that are processed by the FunctionCombination applet.
Param Name Type Default Description GraphColor Color magenta The color used to draw the graphs. TextColor Color black The color that is used for all the textual labels, such as "y=f(x)" that are drawn over the graph. TangentColor Color gray The color used to draw tangent lines, if they are turned on with the "ShowTangents" applet param. DerivativeColor Color blue The color used to draw derivative curves, if they are turned on with the "ShowDerivativeGraphs" applet param. ShowSlider yes/no no Shows an x input box and a slider at the bottom of the applet. The slider effects the locations of the tangent lines. SliderStep int 1000 Sets the number of steps in the x slider. Function String 3 - x^2 The expression that initially defines f(x). SecondFunction String sin(x) The expression that initially defines g(x). ThirdFunction String f(x)+g(x) The expression that initially defines h(x). TableFunction String (none) The initial table function for f(x). If this param has a value but "Function" is not explicitly given a value, f(x) is shown first as a table rather than as an expression. The format for a table function is as follows: It can start, optionally, with the word "table". (This is optional because in this context, we know it's a table.) Then, optionally, can come one of the words "smooth", "linear", or "step" to define how the graph is interpolated between points in the table. The default is "smooth". The comes the definition of the points in the table. There are two ways to do this. One is simply to give the (x,y) coords of the points as a list of 2*N numbers, where N is the number of points. If you want to use the other method, start with the word "intervals", then the number of intervals, then a maximum and a minimum value for x. The specified range of x-values will be divided into the specified number of equal-sized intervals. Then, give up (intervals+1) y-values. Missing y-values are set to 0. SecondTableFunction String (none) The initial table function for g(x). If this param has a value but "SecondFunction" is not explicitly given a value, g(x) is shown first as a table rather than as an expression. For the format of a table function, see the previous item. ShowTangents yes/no no If this is yes, then tangent lines are drawn to each curve. ShowSlopes yes/no no If this is yes, and "ShowTangents" also has value yes, then a label is added to each graph to show the slope of the tangent line. ShowFunctionNames yes/no yes If this is yes, then the labels "y=f(x)", "y=g(x)" and "y=g(f(x))" are added to the graphs. ShowCoordinates yes/no yes If this is yes, then labels are added at the bottom of each graph showing the coordinates of the point that is currently marked. ShowDerivativeGraphs yes/no no If this is yes, then the derivatives of the three functions are added to the graphs. Example,
String (none) These params, if present, define examples that appear in an Examples menu at the top of the applet. You can define "Example1" whether or not you define "Example". However, you can only have an "Example2" if you have an "Example1", you can only have "Example3" if you have "Example2", and so on. An example takes the following form: First, a descriptive title that will appear in the example menu, followed by a semicolon. This is followed by three function definitions, separated by a semicolon. The first two function definitions, for f(x) and g(x), can be either an expression or a table definition. The format for a table definition is given above, under the description of "TableFunction", except that in this context, the definition must start with the work "table". After the function definition, there can be another semicolon and four or five numbers. The first four numbers give the x- and y- limits on the graphs. The fifth number gives the x-coordinate of the slider (if used).