Calling SageMath functions from Javascript

不羁岁月 提交于 2019-12-13 07:19:02

问题


I ask the question and I have to admit that I'm a bit confused on the way to be precise to ask the question... Sorry for that!

Anyhow, I'm using from time to time SageMath on a local machine. I have seen that SageMath is also offering access from a server Sage Cell Server. If I understand well this is a way to access SageMath interpreter from a web browser.

But this doesn't provide access to the "base functions" of SageMath from JavaScript. That would be a kind of "wrapping" of SageMath basic functions in JavaScript calling a server. Is that possible?


回答1:


Sage functions work with Sage structures (variables, matrices, functions, etc), which are not JavaScript objects. JavaScript does not have a thing to which you could apply Sage commands like plot or indefinite_integral.

The mobile Sage apps work by sending user input to be parsed to Sage Cell Server, and displaying the HTML they get from the server.

Of course one could write JavaScript functions like

function integrate(fn, var, a, b) {
    var SageCommand = ['definite_integral('+fn, var, a, b+')'].join(); 
    // send SageCommand string to be parsed by Cell Server
    // parse the response and return the result of integration as a float
}

which would make it look like you are doing things in JS with JS objects. But this is just adding another wrapper, i.e., making access to Sage even less direct than it was. The bottom line is, Sage is not a JavaScript library.



来源:https://stackoverflow.com/questions/29985377/calling-sagemath-functions-from-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!