Examples using the CAS of JSXGraph
Wigand Rathmann
Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU), Department Mathematik, Erlangen, Germany
Abstract
I use JSXGraph a lot in my engineering mathematics classes. I can set up a board for special purposes, perhaps by using a CAS like Maxima. This often follows the typical cycle of developing and debugging a JSXGraph applet:
🤔😕😫🤔😡😮🤦♂️😊😅😎
When an applet works as expected, you are usually very happy. At this point the loop of improvements and the search for tools to realize the ideas (and the development and debugging phases) starts.
My idea is often to create flexible JSXGraph applets, where the user can insert information directly into the applet. At this point I look for solutions that run entirely within JSXGraph. Mostly I use numerical approaches, but sometimes it is better or just nicer to have an analytical approach.
In calculus we deal a lot with functions and their derivatives. When thinking about tangents on a graph, the following three lines of code generate a function graph together with a tangent in a JSXGraph board.
var graph = board.create('functiongraph', ["sin(x)", -10, 10], { strokeColor: '#00ff00'});
var p1 = board.create('glider', [0,0,graph], {style:6, name:'P'});
var t = board.create('tangent', [p1]);
To be more flexible, one could use an input box to enter and change the function term and e.g. show tangents.
The next step could be to demonstrate a Taylor polynomial \(T_{f,n}\) of degree \(n\) for a chosen function \(f\) (provided by the user) at point \(x_0\):
$$T_{f,n}(x,x_0)=\sum_{k=0}^n\frac{1}{k!}f^{(k)}(x_0)(x-x_0)^n.$$And now I need “good” derivatives. JSXGraph comes with some computer algebra algorithms. The functionality is provided to the user via JessieCode, a “scripting language designed to provide an interface to JSXGraph”. Two functions are used to handle function expressions: jc.snippet
to generate a JavaScript function from the function string and jc.manipulate
to calculate derivatives.
In the same way, Maxima and JSXGraph can be linked in STACK questions. This allows you to develop and test JSXGraph applets before using them in a STACK question. The derivatives of a function can be calculated in Maxima, but some symbols have to be replaced. For example, the symbols for \(\pi\) or \(e\) are different in Maxima and JSXGraph. At this point the powerful member function replace
of strings helps and supports regular expressions.
In this talk I will show how to pass a function expression from an input field to the JSXGraph objects and how I used it to
- Construct the osculating circle on a graph,
- plot the Taylor polynomial on a graph,
- construct the curl \(\nabla \times V\) of a given vector field \(V:\mathbb{R}^{3}\to\mathbb{R}^{3}\),
- give an impression of atomic orbitals using the spherical harmonic function \(Y_l^m\) of degree \(l\) and order \(m\).
All examples will be published.