Using GeoGebra To Create Applets For Visualization and Exploration PDF
Using GeoGebra To Create Applets For Visualization and Exploration PDF
GeoGebraApplets
http://www.slu.edu/classes/maymk/GeoGebra/
GeoGebra Applets
GeoGebra is a GNUed software package for mathematics visualization. The home for the applications
is http://www.geogebra.at.
Educational material for GeoGebra is available at http://www.geogebra.at/en/wiki
The following are some Applets pages I have created with the software.
Some of the applet pages look at standard constructions from calculus, making the pictures dynamics
and subject to manipulation by the instructor.
The tangent as the limit of secant lines.
The slope of tangents and the derivative of a function.
The graph of a function and its first and second derivatives in the same window.
The Newton's Method page illustrates the use of tangent lines to find roots of functions. It also
gives examples where the technique fails.
The Taylor polynomial approximation of a function.
Some pages look at precalculus material to allow a quick review,
The Linear Equations page connects the normal ways of defining a line, either by giving two
points, or by giving a point and a slope, or by giving the slope and intercept. Each window
connects a set of information with a line and derives the other presentations of the line.
The Quadratic Equations applet allows you to make connections between the graph of a quadratic
function, and various ways to write the equation, focusing either on roots or the vertex of the
parabola.
Conic Sections - The Ellipses and Hyperbolas applet lets you specify a conic section by
specifying the length from the center to a vertex on the major axis and the length to a focus. You
get either an ellipse or a hyperbola, depending on which length is bigger. The Parabolas applet
looks at Parabolas defined by a focus and a directrix. The General Conic Sections applet lets you
explore the graph of a quadratic relation in general format.
Graphs of related functions -The family of curves applet lets you graph a function with three
parameters and then vary those parameters with a slider. The Translations and Compressions
Applet lets you compare the graph of a function with the graph of a function transformed by
translations and compressions or expansions.
Trigonometric Functions - The Trig Review applet connects the values of the 6 basic trig
functions with segments on the unit circle. The Sin Curve Fitting applet lets you fit a sinusoidal
curve to a pair of specified points.
Some of the applet pages look at standard results in the construction of triangles.
The side-side-side applet, lets you construct a triangle by specifying the lengths of the three sides.
If such a triangle can be constructed, it is unique.
The side-angle-side applet, lets you construct a triangle by specifying the lengths of two of the
sides and the included angle. If such a triangle can be constructed, it is unique.
The angle-side-angle applet, lets you construct a triangle by specifying the lengths of two of the
sides and the included angle. If such a triangle can be constructed, it is unique.
The side-side-angle applet, lets you construct a triangle by specifying the lengths of two of the
sides and an non-included angle. If such a triangle can be constructed, it may not be unique.
The angle bisector applet looks at the theorem that the three angle bisectors of a triangle all meet in
a single point. The first frame lets the student explore the result with various triangles. A second
1 of 2
3/17/08 1:47 PM
GeoGebraApplets
http://www.slu.edu/classes/maymk/GeoGebra/
2 of 2
3/17/08 1:47 PM
Items to note:
1) Sliders with dynamic control of values.
2) Javascript line for controlling viewing window
3) Javascript line that gets and returns function definition, using parameters
4) Javascript line for drop down menu of examples
5) Customizations - Restricted toolbar with only 4 tools available; No command line; No algebra window.
Notes on use:
Items to note:
1) The Javascript line for controlling viewing window has been repeated as have the customizations.
2) The Javascript line for the function has a second input for guessing the derivative. (This is the dotted
line in the default picture. It has been set incorrectly so the students need to produce it.)
3) The value of the point T is in a separate Javascript line since the point and functions will be changed at
different times.
Items to note:
1) The Javascript line for controlling viewing window has been repeated as have the customizations.
2) The Javascript line for the function has extra information that one would want in doing taylor
polynomials.
3) The text area gives a lot of textual information.
Items to note:
1) The Javascript line for controlling viewing window has been repeated as have the customizations.
2) The center, the lengths of the major and minor axes, and the point on the conic can be changed by
dragging.
3) A lot of information about the conic is given as text with an organization of regions as controls,
measurements, and summary data.
4) (Below) Changing the focus lenth and major length changes the kind of conic, with different text
showing up using conditional definitions.
Items to note:
1) Several GeoGebra windows are used in a single page.
2) Text, objects, and labels are connected by use of color.
Items to note:
1) Check boxes are used to make items appear and disappear.
Items to note:
1) The slider walks students through the steps of a proof.
2) The vertices are dynamic and can be changed by dragging.
Many of the geometric object can be created using the icon menus. The
composite picture above shows the icons in the pictures. Most are clear enough
to understand from the icon. The next page shows each menu along with the
text descriptions that accompany the icons.
GeoGebra also has more algebraic commands available from the input line. (The
commands invoked by the icons each have text based versions.) I have organized
some of those common courses in the pages that follow.
The following gives some sample code from Applet web pages.
It is intended to give examples so that you can understand enough to copy paste and modify.
*****************Applet code Name added to generated code
<applet code="geogebra.GeoGebraApplet" name="ggbApplet"
codebase="./" archive="geogebra.jar" height="500" width="730">
<param name="filename" value="FamilyOfFunctions_worksheet.ggb">
<param name="framePossible" value="true">
<param name="showResetIcon" value="true">
<param name="enableRightClick" value="false">
<param name="showMenuBar" value="false">
<param name="showToolBar" value="true">
<param name="showToolBarHelp" value="true">
<param name="showAlgebraInput" value="false">
Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is
installed and activated. (<a href="http://java.sun.com/getjava">click here to install Java
now</a>)</applet>
*******************Comments
The block of code above is from the page for the families of functions applet.
1) In the first line, which begins with "applet", the string
name="ggbApplet"
was added to the code generated by GeoGebra. This names the applet so that
I can communicate with the applet using javascript.
2) In the second line
codebase="./"
indicates where the geogebra.jar file is to be found. In this case, the file is to be found in
the same directory as the html file.
3) The value of the filename parameter indicates the Geogebra file to be used.
4) The remaining lines show options that can be set for the web page.
These can be set with advanced features when the web page is exported. They can also be
changed by changing the values true and false.
From that Family of Functions Applet, we want to focus on two lines of the web page. There is
a line to either get the function f from the applet or to send a new definition of f to the
applet. There is also a line that sets the viewing window.
We will be looking at Javascript for two forms (FunctionForm and ViewForm) and three functions.
(setFunction, getFunction, and setView)
**************************************
Function sending Info to Applet
<script type="text/javascript">
function setFunction(objName) {
var applet = document.ggbApplet;
var f= document.functionForm.FunctionField.value;
applet.evalCommand(f);
}
Function getting info from applet
function getFunction(objName) {
var applet = document.ggbApplet;
var f= applet.getDefinitionString("f");
document.functionForm.FunctionField.value = f
}
Function to send view window info
function setView(objName) {
var applet = document.ggbApplet;
var LowX = document.ViewForm.LowXField.value;
var HighX = document.ViewForm.HighXField.value;
var LowY = document.ViewForm.LowYField.value;
var HighY = document.ViewForm.HighYField.value;
applet.setCoordSystem(LowX, HighX, LowY, HighY);
}
</script>
Form to show/get function
<form name="functionForm" onsubmit="setFunction('T'); return false;">
<input value="get function" onclick="getFunction('T');" type="button">
<input name="FunctionField" size="40"value="f(x) = a*x^2+b*x+c" type="text">
<input value="set function" onclick="setFunction('T');" type="button"> </form>
Form to collect view window info
<form name="ViewForm" onsubmit="setView('T'); return false;">
Min X = <input name="LowXField" size="5" onchange="setView('T');" value="-10"
Max X = <input name="HighXField" size="5" onchange="setView('T');" value="10"
Min Y = <input name="LowYField" size="5" onchange="setView('T');" value="-10"
Max Y = <input name="HighYField" size="5" onchange="setView('T');" value="10"
<input value="Set Window" onclick="setView('T');" type="button">
</form>
type="text">
type="text">
type="text">
type="text">
***********************Comments
1) In javascript, document refers to the current web page. As noted above, the applet is named
ggbApplet and the forms are functionForm and viewForm.
2) The 3 functions provided above can be separated into separate scripts.
From that Family of Functions Applet, we now want to focus on line of the web page that
provided a list of examples. Note that each menu choice has us executing several commands.
Function to load selected example
<script type="text/javascript">
function ExampleLoader(objName) {
var applet = document.ggbApplet;
var n= document.ExampleForm.ExampleSelect.value;
if (n==0) {
var f="f(x)=a*x^2+b*x+c";
applet.setCoordSystem(-10, 10, -8, 8);
applet.evalCommand(f);
document.functionForm.FunctionField.value = f;}
else if (n==1) {
var f="f(x)=a*(x-b)*(x-c)";
applet.setCoordSystem(-10, 10, -8, 8);
applet.evalCommand(f);
document.functionForm.FunctionField.value = f;}
else if (n==2) {
var f="f(x)=a*(x-b)^2+c";
applet.setCoordSystem(-10, 10, -8, 8);
applet.evalCommand(f);
document.functionForm.FunctionField.value = f;}
else if (n==3) {
var f="f(x)=a*sin(b*(x-c))";
applet.setCoordSystem(-7, 7, -4, 4);
applet.evalCommand(f);
document.functionForm.FunctionField.value = f;}
else if (n==4) {
var f="f(x)=a*sin(x)+b*cos(x)";
applet.setCoordSystem(-7, 7, -4, 4);
applet.evalCommand(f);
document.functionForm.FunctionField.value = f;}
else if (n==5) {
var f="f(x)=a*ln(b*x)+c";
applet.setCoordSystem(-1, 10, -8, 8);
applet.evalCommand(f);
document.functionForm.FunctionField.value = f;}
else if (n==6) {
var f="f(x)=a*b^x+c";
applet.setCoordSystem(-10, 10, -8, 8);
applet.evalCommand(f);
document.functionForm.FunctionField.value = f;}
}
</script>
Form with drop down menu of examples
<form name="ExampleForm">
<select name="ExampleSelect" size="1">
<option value ="">Example Families</option>
<option value =0>General Quadratic: a*x^2+b*x+c</option>
<option value =1>Factored Quadratic: a*(x-b)*(x-c)</option>
<option value =2>Vertex Parabola: a*(x-b)^2+c</option>
<option value =3>Sin Curve with Phases: a*sin(b*(x-c))</option>
<option value =4>Linear Combination of sin and cos: a*sin(x)+b*cos(x)</option>
<option value =5>Logrithmic Curve: a*ln(b*x)+c</option>
<option value =6>Exponential Curve: a*b^x+c</option>
</select>
<input value="Load Example" onclick="ExampleLoader(this)" type="button">
</form>
This last page of code comes from the Taylor Polynomial Approximation applet page.
It is noteworthy since it gathers a lot of information together, both for input and output.
**********************************
<script type="text/javascript">
Setting functions and parameters
function setFunction(objName) {
var applet = document.ggbApplet;
var f= document.functionForm.setFunctionField.value;
applet.evalCommand("f(x)="+f);
var n= document.functionForm.setTaylorDegree.value;
applet.evalCommand("n="+n);
var x0= document.functionForm.setx0.value;
applet.evalCommand("x_0="+x0);
var x1= document.functionForm.setx1.value;
applet.evalCommand("x_1="+x1);
}
gathering lots of output together
function setOutput(objName) {
var applet = document.ggbApplet;
var TaylorPoly= applet.getValueString("TaylorPoly");
var TaylorDegree = applet.getValue("n")
var x0 = applet.getValue("x_0")
var x1 = applet.getValue("x_1")
var T1y = applet.getYcoord("T_1")
var P1y = applet.getYcoord("P_1")
var E1y = applet.getYcoord("E_1")
document.outputForm.TextAreaOutput.value =
"We are looking at the Taylor polynomial of degree " + TaylorDegree +
"\ncentered at x_0 = " + x0 + "\n" +
"At x_1 = " + x1 + " the function has value " + P1y +
"\nwhile the polynomial approximation is " + T1y +
"\ngiving an error of " + E1y + "\n" +
TaylorPoly
}
</script>
Function data form
<form name="functionForm" onsubmit="setFunction('T'); return false;">
<input value="set values" onclick="setFunction('T');" type="button">
f(x) = <input name="setFunctionField" onchange="setFunction('T');" size="30"
value="3*sin(x/2)+5*cos(x)" type="text"><br>
Degree of Approximation = <input name="setTaylorDegree" size="5"
onchange="setFunction('T');" value="4" type="text">
, x_0 = <input name="setx0" size="10" onchange="setFunction('T');" value="1"
type="text">
, x_1 = <input name="setx1" size="10" onchange="setFunction('T');" value="2" type="text">
</form>
Test area output form
<form name="outputForm" onsubmit="setOutput('T'); return false;">
<input value="Get output" onclick="setOutput('T');" type="button"><br>
<textarea name="TextAreaOutput" rows="10" cols="90" value=" "
onchange="setOutput('T');"></textarea>
</form>
*****************************Comments
1) The output to the textarea is made up of a collection of things concatenated together with
plus signs. The character \n gives a new line.