coshIntegral script slows down browser
axkr opened this issue · 6 comments
The coshIntegral
script slows down the browser.
Is there some wrong call to coshIntegral?
<html>
<head>
<meta charset="utf-8">
<title>JSXGraph</title>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/jsxgraph@1.3.2/distrib/jsxgraph.css"/>
<script src="https://cdn.jsdelivr.net/gh/paulmasson/math@1.4.6/build/math.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jsxgraph@1.3.2/distrib/jsxgraphcore.js"></script>
</head>
<body>
<div id="jxgbox" class="jxgbox"></div>
<script>
var board = JXG.JSXGraph.initBoard('jxgbox', {axis:true,boundingbox:[-2.75,6.05,2.75,-6.05]});
board.suspendUpdate();
var a = board.create('slider',[[-2.2,4.84],[2.2,4.84],[1,1,10]],{name:'a'});
function $f1(x) { try { return [re(coshIntegral(mul(a.Value(),x)))];} catch(e) { return Number.NaN;} }
function $f2(x) { try { return [im(coshIntegral(mul(a.Value(),x)))];} catch(e) { return Number.NaN;} }
board.create('functiongraph',[$f1, -2.0, 2.0],{strokecolor:'#5e81b5'});
board.create('functiongraph',[$f2, -2.0, 2.0],{strokecolor:'#e19c24'});
board.unsuspendUpdate();
</script>
</body>
</html>
coshIntegral(x)
seems to hang infinitely when called with x = -1.0
.
Further, the correct definition of $f1
and $f2
is probably
function $f1(x) { try { return re(coshIntegral(mul(a.Value(),x)));} catch(e) { return Number.NaN;} }
function $f2(x) { try { return im(coshIntegral(mul(a.Value(),x)));} catch(e) { return Number.NaN;} }
@axkr any function that goes through the upper incomplete gamma is likely to have issues. I've spent quite a bit of time figuring out how to address problems with that function as well as hypergeometricU
. Think I know a way forward but it will be a lot of work and I've been procrastinating. Need to get focused...
Further, the correct definition of
$f1
and$f2
is probably
@alfredwassermann, @paulmasson - I inserted a JSFiddle button into the graphics iframe
, to make it easier checking problems with the generated JavaScript.
Example:
@alfredwassermann you were correct that coshIntegral
hangs at -1. Traces back to expIntegralEi
which hangs at -1 and +i/-i. I've added a fix in d1d69f3 to avoid this and allow the page to load.
@axkr your page now finishes loading, although slowly, but nothing appears. Since this appears to be an issue with your implementation of JSXGraph, I'm closing this issue. Feel free to reopen it if there's still a problem on my end.
@paulmasson should I post examples of slow Mathcell 3D renderings in a new issue or do you assume they have all the same cause?
@axkr probably all the same root cause. Reopen this issue as needed. Thanks!