通过使用JSX图表
问题描述:
如何F(X)(通过用户输入),并且其中从滑块接收的值F(XA)的曲线图的曲线图可以是创建F(X)和f(XA)的曲线图通过使用jsx图形绘制?例如,如果一个从滑块用户输入x x和值是1,那么两个图表将在JSX板:一个x的和其他(X-1)的(X-1)?通过使用JSX图表
答
从Changing the function in the text box is not changing the graph拿起我的回答用户提供的函数f(x)
的同时情节和功能f(x-a)
取决于滑块可以是这样的:
board = JXG.JSXGraph.initBoard('box', {boundingbox: [-6, 12, 8, -6], axis: true});
a = board.create('slider', [[-4,7], [4,7], [-10, 1,10]], {name:'a'});
doPlot = function() {
var txtraw = document.getElementById('input').value, // Read user input
f = board.jc.snippet(txtraw, true, 'x', true), // Parse input with JessieCode
curve, curve2;
board.removeObject('f'); // Remove element with name f
board.removeObject('g'); // Remove element with name g
curve = board.create('functiongraph', [f, -10, 10], {name:'f'});
curve2 = board.create('functiongraph', [
function(x) {
return f(x - a.Value());
}, -10, 10], {name:'g', strokeColor: 'red'});
};
doPlot();
这意味着,关键是要界定第二功能它返回f(x-a)
。请参阅https://jsfiddle.net/qmp0qdvv/1/。正如上面提到的其他问题一样,这个例子允许使用JSXGraph的JessieCode解析器输入简单的数学语法而不是JavaScript代码。
太棒了!!按预期工作....! – mathsbeauty
什么修改将需要绘制F(X)+ B的曲线图中,f(-x)和-f(x)的? b的值将在滑块上再次更改。 – mathsbeauty
没问题,请参阅https://jsfiddle.net/c4cwxdq7/1/ –