update work flow
This commit is contained in:
@@ -285,6 +285,96 @@ gif(anim, imgfile, fps = 1)
|
||||
ImageFile(imgfile, caption)
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
This interactive graphic (built using [JSXGraph](https://jsxgraph.uni-bayreuth.de/wp/index.html)) allows the adjustment of the point `x0`, initially at ``0.85``. Five iterations of Newton's method are illustrated. Different positions of `x0` clearly converge, others will not.
|
||||
|
||||
```=html
|
||||
<div id="jsxgraph" style="width: 500px; height: 500px;"></div>
|
||||
```
|
||||
|
||||
```ojs
|
||||
//| echo: false
|
||||
//| output: false
|
||||
|
||||
JXG = require("jsxgraph");
|
||||
|
||||
// newton's method
|
||||
|
||||
b = JXG.JSXGraph.initBoard('jsxgraph', {
|
||||
boundingbox: [-3,5,3,-5], axis:true
|
||||
});
|
||||
|
||||
|
||||
f = function(x) {return x*x*x*x*x - x - 1};
|
||||
fp = function(x) { return 4*x*x*x*x - 1};
|
||||
x0 = 0.85;
|
||||
|
||||
nm = function(x) { return x - f(x)/fp(x);};
|
||||
|
||||
l = b.create('point', [-1.5,0], {name:'', size:0});
|
||||
r = b.create('point', [1.5,0], {name:'', size:0});
|
||||
xaxis = b.create('line', [l,r])
|
||||
|
||||
|
||||
P0 = b.create('glider', [x0,0,xaxis], {name:'x0'});
|
||||
P0a = b.create('point', [function() {return P0.X();},
|
||||
function() {return f(P0.X());}], {name:''});
|
||||
|
||||
P1 = b.create('point', [function() {return nm(P0.X());},
|
||||
0], {name:''});
|
||||
P1a = b.create('point', [function() {return P1.X();},
|
||||
function() {return f(P1.X());}], {name:''});
|
||||
|
||||
P2 = b.create('point', [function() {return nm(P1.X());},
|
||||
0], {name:''});
|
||||
P2a = b.create('point', [function() {return P2.X();},
|
||||
function() {return f(P2.X());}], {name:''});
|
||||
|
||||
P3 = b.create('point', [function() {return nm(P2.X());},
|
||||
0], {name:''});
|
||||
P3a = b.create('point', [function() {return P3.X();},
|
||||
function() {return f(P3.X());}], {name:''});
|
||||
|
||||
P4 = b.create('point', [function() {return nm(P3.X());},
|
||||
0], {name:''});
|
||||
P4a = b.create('point', [function() {return P4.X();},
|
||||
function() {return f(P4.X());}], {name:''});
|
||||
P5 = b.create('point', [function() {return nm(P4.X());},
|
||||
0], {name:'x5', strokeColor:'black'});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
P0a.setAttribute({fixed:true});
|
||||
P1.setAttribute({fixed:true});
|
||||
P1a.setAttribute({fixed:true});
|
||||
P2.setAttribute({fixed:true});
|
||||
P2a.setAttribute({fixed:true});
|
||||
P3.setAttribute({fixed:true});
|
||||
P3a.setAttribute({fixed:true});
|
||||
P4.setAttribute({fixed:true});
|
||||
P4a.setAttribute({fixed:true});
|
||||
P5.setAttribute({fixed:true});
|
||||
|
||||
sc = '#000000';
|
||||
b.create('segment', [P0,P0a], {strokeColor:sc, strokeWidth:1});
|
||||
b.create('segment', [P0a, P1], {strokeColor:sc, strokeWidth:1});
|
||||
b.create('segment', [P1,P1a], {strokeColor:sc, strokeWidth:1});
|
||||
b.create('segment', [P1a, P2], {strokeColor:sc, strokeWidth:1});
|
||||
b.create('segment', [P2,P2a], {strokeColor:sc, strokeWidth:1});
|
||||
b.create('segment', [P2a, P3], {strokeColor:sc, strokeWidth:1});
|
||||
b.create('segment', [P3,P3a], {strokeColor:sc, strokeWidth:1});
|
||||
b.create('segment', [P3a, P4], {strokeColor:sc, strokeWidth:1});
|
||||
b.create('segment', [P4,P4a], {strokeColor:sc, strokeWidth:1});
|
||||
b.create('segment', [P4a, P5], {strokeColor:sc, strokeWidth:1});
|
||||
|
||||
b.create('functiongraph', [f, -1.5, 1.5])
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
##### Example: numeric not algebraic
|
||||
|
||||
|
||||
Reference in New Issue
Block a user