Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • May 27 21:11
    anisabboud opened #1467
  • May 27 18:24
    timmckague opened #1466
  • May 27 15:09
    arnog closed #1443
  • May 27 14:49
    arnog closed #1445
  • May 26 15:49
    arnog commented #1443
  • May 25 15:23
    ImGelu commented #724
  • May 25 15:19
    ImGelu commented #724
  • May 25 15:10
    arnog commented #724
  • May 25 10:24
    ImGelu commented #724
  • May 25 10:24
    ImGelu commented #724
  • May 25 10:22
    ImGelu commented #724
  • May 25 10:21
    ImGelu commented #724
  • May 25 10:21
    ImGelu commented #724
  • May 25 01:22
    arnog commented #1444
  • May 25 01:21
    arnog commented #1465
  • May 25 01:19
    arnog closed #1465
  • May 25 01:19
    arnog labeled #1465
  • May 25 01:19
    arnog labeled #1465
  • May 25 01:19
    arnog assigned #1465
  • May 24 23:16
    picodeflank opened #1465
Arno Gourdol
@arnog
The documentation for the Compute Engine has been substantially improved, and reflects the current API (i.e. new API as of 0.4.3)
Also improved the SDK reference for both MathLive and the Compute Engine (https://cortexjs.io/docs/mathlive/ and https://cortexjs.io/docs/compute-engine/) thanks to an improved version of grok, the API documentation tool that turns a TypeScript file into HTML (https://github.com/ui-js/grok)
MathLive as of 0.70.0 uses the Compute Engine to parse LaTeX and to serialize MathJSON
Edin
@physedo
👍💪
k2rta
@k2rta
Hi getting errors for loading fonts in angular application, the fonts are not missing but for some reason console is full of 404-s
for example: GET http://localhost:4200/fonts/KaTeX_Caligraphic-Regular.woff2 net::ERR_ABORTED 404 (Not Found)
Arno Gourdol
@arnog
Hard to tell without access to your setup, but if you are getting a 404 it indicates that the fonts are in fact missing, or at least that they are not at the location they are looked for (i.e. in a fonts directory in the root of your site)
k2rta
@k2rta
Thanks for the response, but solved it already.
For info: setup is Angular13 application and it loaded fonts from src, not src/assets, as a solution I moved fonts to src/fonts and updated angular.json config to load assets from src/fonts aswell
errors be gone now :D
But another question: can the input be made readonly?
Arno Gourdol
@arnog
yes, just add the readonly attribute to the element
Mārtiņš Mednis
@MartinsMednis
Hi, I was wondering if it is possible to pass the expression to math-field in MathJSON format instead of Latex. I found there is .getValue('math-json') to get the json. Is there something for set?
Arno Gourdol
@arnog
@MartinsMednis that's a great point. This is currently missing, but it should really be there.
OK, you can now pass math-json as a format option to setValue, i.e. .setValue(["Add", 2, "x"], {format: "math-json"})
Mārtiņš Mednis
@MartinsMednis

Thank you @arnog. That was really quick. I can now .setValue to ["Add", 2, "x"] and .getValue('math-json')) returns exactly what was set i.e. ["Add", 2, "x"].

When I set value to ["Divide", "weight", ["Square", "height"]] (it's Body Mass Index formula), the rendering in browser works as expected, however, the getValue('math-json') returns something that is very far from what was set: ["Divide",["Error","Missing","'unknown-command'",["LatexForm","'\\mathrm{weight}'"]],["Power",["Delimiter",["Error","Missing","'unknown-command'",["LatexForm","'\\mathrm{height}'"]]],2]].

The backstory is I have built a python API that solves MathJSON expressions. In my example the weight and height are obviously outside of the supported MathJSON vocabulary, so my python API recognizes that and looks for actual weight and height values elsewhere to plug them in the expression to solve. I'd be willing to change my API to make it more compatible with math-field generated MathJSON as it would be much less work than to create another equation builder.

The question is - how to use variables that are longer than a single character?

Arno Gourdol
@arnog
ah, yes, I think there's a bug in the version of the Compute Engine used by the current MathLive when parsing multi-char variables. I'll need to update MathLive with a newer Compute Engine...
Mārtiņš Mednis
@MartinsMednis
Great! So, eventually multi-char variables will be supported, yes?
Arno Gourdol
@arnog
oh yes, absolutely
ciola
@ciola
Hello,
Before asking my question, I would like to say how much mathlive and cortex help us to propose interesting exercises to the students. Congratulations for all this wonderful work.
Now I come to my neophyte question:
Are the inverse sinus or cosinus functions implemented?
Indeed, when I enter \cos^{-1}(0) on https://cortexjs.io/compute-engine/demo/
the system recognizes \operatorname{Apply}(\mathrm{InverseFunction}(\cos), \mathrm{List}(0)) but does not return the right value.
Arno Gourdol
@arnog
Thanks @ciola , that's very kind.
Yes, the inverse functions should work, but it does look like there's a bug in their evaluation right now. I'll have a look at it. Thanks for pointing it out.
ciola
@ciola
Your welcome.
ciola
@ciola
Do I have to make a report in gitHub ?
Edin
@physedo
https://cortexjs.io/mathlive/guides/static/ is not working at the bottom in my browser Google Chrome
Version 100.0.4896.60 (Officiell version) (64 bitar) @arnog . When you have read only
Arno Gourdol
@arnog
ah, yes, I see that. Thanks for letting me know.
Arno Gourdol
@arnog
OK, I've checked in a fix for this. Not sure if the way custom element were initialized changed, but having an attribute on a <math-field> caused the default value to be ignored.
ciola
@ciola
Hello, I am doing my first tests and my goal is to calculate some exact values of cos, sin, acos and asin.
How should I do it?
Thanks in advance.
Arno Gourdol
@arnog
You could do ce.parse('\cos\frac14').simplify().latex -> \frac{1}{2}\sqrt{2}
ciola
@ciola
What object does valueOf() methode belong to?
Arno Gourdol
@arnog
it's a JavaScript standard method, so you can apply it to most objects. In the context of CortexJS, you could apply it to a BoxedExpression (i.e. the result of .parse() or .box()) but this will rarely do what you want. You probably want to call evaluate() or .value instead.
ciola
@ciola
Thanks.
engine.parse('\arccos(\frac{\sqrt{3}}{2})').simplify() -> Uncaught TypeError: ti[t] is undefined
Arno Gourdol
@arnog
Make sure you escape the backslashes:
console.log(engine.parse('\\arccos(\\frac{\\sqrt{3}}{2})').simplify());
although, even with the correct backslashes, it appears there's a bug, I'm getting the error as well. I'll look into it.
ciola
@ciola
Yes I do
Arno Gourdol
@arnog
oh, I think gitter is removing your double backslash :)
Arno Gourdol
@arnog
ok, I've checked in a fix
ciola
@ciola
So I have to update cortex to continue my tests?
Arno Gourdol
@arnog
it depends on how you are integrating cortex. If you have a fork, you need to sync your fork to the upstream branch. If you are using npm, you need to update to head, or wait until I push a tag to npm. If you are using a CDN, I need to make a build and push an update, then you can update to this version.
ciola
@ciola
We use npm.
ciola
@ciola
What is the meaning of "update to head" ?
ViridityCorn
@ViridityCorn
Hi! I'm new to the project, and it looks exactly like, what I need. I do have a question though. It may be a stupid question, but how can I programmatically calculate sinus to a value of degrees and not radians using compute engine? Is there a way to explicitly tell compute engine to calculate it as degrees?
ciola
@ciola
@ViridityCorn sin(pi/180 x) ;)
1 reply
ViridityCorn
@ViridityCorn
Has anyone experienced the "document is not defined"-error while implementing MathLive with React and NextJs? Or is that simply not possible?
Arno Gourdol
@arnog
yes, there have been reports of this when using server-side rendering. It should work, though. However, I have not been provided with a test case that I could debug, so I have not been able to fix this.
ViridityCorn
@ViridityCorn
I can create a GitHub issue regarding this. How much information should I provide? I can also provide the project files, since this is the first thing I'm trying to implement
Arno Gourdol
@arnog
a github repo that demonstrates the problem would be great
27 replies
ViridityCorn
@ViridityCorn
Got it. I'm on it
ViridityCorn
@ViridityCorn
Has anyone succesfully integrated MathLive with Vue 3?
Arno Gourdol
@arnog
Yes!
For anyone who might be interested: arnog/vue-mathlive#49
KondakovArtem
@KondakovArtem

Hello. Can anyone help/tell me - is it possible to do this with mathlive?

I have a set of variables L1, L2, L3, ... LN. Each of these variables has a set of properties, one of which is a visual representation such as "A" , "B" , "C" , etc. Representations for variables can be the same.

There is a formula "L1 + L2 + L3". I need to be able to edit it using mathlive. But using visual representation

For example, there are variables
L1 = {view: V, id: 1, name: Variable1 }
L2 = {view: S, id: 2, name: Variable2 }
L3 = {view: V, id: 3, name: Variable3 }

There is a formula L1 + L2 + L3

It is necessary to represent via mathlive as
V + S + V

Is it possible when entering a variable, for example, through a macro, so that its meta description is still preserved, and in the future it would be possible to convert back to L1 + L2 + L3

Also, is it possible to display a hint when hovering over a variable in a matnlive?

Arno Gourdol
@arnog

@KondakovArtem yes, you could do something like that by defining a macro. The arguments to the macro would include both the name of the variable and its visual representation, but would only display its visual representation.
You could do this using:

mf.setOptions( { macros: { var: "#2" } })

Then using this in LaTeX: \var{Variable1}{V}, and it would display V. However, you would get back the LaTeX as \var{Variable1}{V} which would allow you to associated it back to L1 (or you could use L1 directly instead of Variable1).
There is currently no support do display a hint/tooltip, but if someone wants to contribute support for it (there is a semi-standard \tooltip LaTeX command), I'd be happy to merge it.