mathcell
mathcell copied to clipboard
More "adaptive" plot function?
Can we get a more "adaptive" plot function?
See for example these discussions:
- https://scicomp.stackexchange.com/questions/2377/algorithms-for-adaptive-function-plotting
- https://github.com/JuliaPlots/Plots.jl/issues/621
Especially this function plot example will benefit from such an "adaptive" approach:
<html>
<head>
<meta charset="utf-8">
<title>MathCell</title>
<link rel="stylesheet" type="text/css" href="style.css">
<style></style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/gh/paulmasson/[email protected]/build/math.js"></script>
<script src="https://cdn.jsdelivr.net/gh/paulmasson/[email protected]/build/mathcell.js"></script>
<script src="https://cdn.jsdelivr.net/gh/mathjax/[email protected]/MathJax.js?config=TeX-AMS_HTML"></script>
<div class="mathcell" style="width: 100%; height: 100%; padding: .25in .5in .5in .5in;">
<script>
var parent = document.scripts[ document.scripts.length - 1 ].parentNode;
var id = generateId();
parent.id = id;
MathCell( id, [ ] );
parent.update = function( id ) {
function z1(x) { return tan(x); }
var p1 = plot( z1, [0, (6.283185307179586)], { } );
var data = [ p1 ];
var config = { type: 'svg' , yMin: -200, yMax: 200 };
evaluate( id, data, config );
}
parent.update( id );
</script>
</div>
</body>
</html>
Another interesting example:
<html>
<head>
<meta charset="utf-8">
<title>MathCell</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<script src="https://cdn.jsdelivr.net/gh/paulmasson/[email protected]/build/math.js"></script>
<script src="https://cdn.jsdelivr.net/gh/paulmasson/[email protected]/build/mathcell.js"></script>
<script src="https://cdn.jsdelivr.net/gh/mathjax/[email protected]/MathJax.js?config=TeX-AMS_HTML"></script>
<div class="mathcell" style="width: 100%; height: 100%; padding: .25in .5in .5in .5in;">
<script>
var parent = document.scripts[ document.scripts.length - 1 ].parentNode;
var id = generateId();
parent.id = id;
MathCell( id, [ ] );
parent.update = function( id ) {
function z1(x) { return Math.round(x); }
var p1 = plot( z1, [-5, 5], { } );
var data = [ p1 ];
var config = { type: 'svg' };
evaluate( id, data, config );
}
parent.update( id );
</script>
</div>
</body>
</html>
More input from @axkr:
Interval arithmetic to solve the problems for Tan, Cot: https://mauriciopoppe.github.io/function-plot/