Second derivative in AsciiMath - mathjax

I'd like to express "the second derivative of f(x)" in AsciiMath.
In LaTeX, it's simply f''(x):
The same in AsciiMath results in single quotes instead prime symbols:
I can get a perfect first derivative in AsciiMath using f^'(x)
But the same approach doesn't work for second derivative: f^('')(x):
Is there a syntax in AsciiMath that results in the same output as LaTeX, with prime symbols and not single quotes?

As you point out, AsciiMath doesn't handle this situation very well. The approaches suggested so far produce poor quality MathML, and while MathJax's output handles even this awkward MathML, native MathML rendered (like Firefox's) will produce poorer results. Here is f^'text()^'(x) rendered by Firefox's native MathML:
This is badly rendered because the underlying MathML has two separate <msup> elements, and the bases for the two superscripts are not the same height:
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle displaystyle="true">
<mrow>
<msup>
<mi>f</mi>
<mo>′</mo>
</msup>
<msup>
<mrow>
<mtext></mtext>
</mrow>
<mo>′</mo>
</msup>
</mrow>
<mrow>
<mo>(</mo>
<mi>x</mi>
<mo>)</mo>
</mrow>
</mstyle>
</math>
One possible solution that produces better MathML is to use the double-prime unicode character, U+2033, as in f^″(x), or if you are entering it in an HTML page, as f^″(x). This is rendered by MathJax's HTML-CSS output as
and as
by Forefox's native MathML renderer. Moreover, the MathML that AsciiMath produces for this input is more semantically meaningful:
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mstyle displaystyle="true">
<mrow>
<msup>
<mi>f</mi>
<mo>″</mo>
</msup>
<mrow>
<mo>(</mo>
<mi>x</mi>
<mo>)</mo>
</mrow>
</mrow>
</mstyle>
</math>
There is also a triple prime at U+2034 and a quadruple prime at U+2057, in case you need those as well. It would be nice if AsciiMath could combine the two separate primes into U+2033 automatically, but it doesn't currently do that.

Try this
f^('')(x)
It yields the following

I was able to achieve it by inserting an empty text block and putting the second prime symbol onto that, like this: f^'text()^'(x)
There is also a slightly shorter form using quotes for the text block: f^'""^'(x)

Related

How to code circles around text in Mathjax

The following image is from an exercise in Chiswell and Hodges Mathematical Logic, page 21:
I would like to display something similar when I post an answer on Mathematics Stack Exchange, but I don't know how to make the circles with the numbers inside nor the forward slashes through the letters in Mathjax. I think I can handle the fractions with "\frac" as well as the rest of it.
I've looked for examples from other posts to copy, but people seem to replace the circle with parenthesis as an alternative.
Would someone be able to show me how or what software I should use to get this effect?
There are a number of possible ways to get a circle around the one. Here are three:
Use the enclose extension with the circle notation:
\require{enclose}
{\scriptstyle \enclose{circle}{\kern .06em 1\kern .06em}}
You only need to include the \require{enclose} once on the page before your first usage of \enclose. The \kern commands are to make the circle be round rather than oval, since the size of the one is taller than it is wide.
Use \rlap to place the 1 over top of a \bigcirc:
{scriptstyle \rlap{\kern .18em 1}\raise.04em{\bigcirc}}}
we also raise the big circle slightly to get the placement better.
Use the \unicode{} command to obtain the U+2460 character, which is "circled digit one":
{\textstyle\unicode{x2460}}
You can use the cancel package to get \cancel, which produces an diagonal upward slash over its argument, and use a superscript to put the circled 1 in place:
{scriptstyle\cancel{\psi}^{\raise.2em{\enclose{circle}{\kern .06em 1\kern .06em}}}}
Putting this all together with your fractions, you can do something like the following horrible hack:
\require{enclose}\require{cancel}
\frac{
\lower.3em{\scriptstyle\cancel{\psi}\raise.6em{\enclose{circle}{\kern .06em 1\kern .06em}}}
\kern 2.6em
\frac{(\psi\wedge\phi)}{\phi}
{\scriptstyle (\wedge\rm E)}
\kern -2.5em
}{
\kern -.7em
{\scriptstyle\enclose{circle}{\kern .06em 1\kern .06em}}
\frac{(\psi\wedge\phi)}{(\psi\rightarrow(\psi\wedge\phi))}
{\scriptstyle(\rightarrow\rm I)}
\kern -1.7em
}\ {\scriptstyle (\wedge\rm I).}
This includes a lot of spacing adjustments by hand to get the fraction lines to be the right length. It would be painful to do this for very many of these.
Here is the result:

Double brackets in MathJax

How can I achieve stretchy double brackets in MathJax using TeX? For example,
The TeX package stmaryrd has this but MathJax doesn't support the import of arbitrary packages.
I'd like the double brackets to look good at all sizes.
Bonus: Is this possible in AsciiMath?
The MathJax TeX fonts don't include the characters needed for these brackets. But you can get a similar effect using something like \left[\!\!\left[x^2\over 2\right]\!\!\right] or \left[\!\left[x+1\right]\!\right] or even [\![x+1]\!]. Unfortunately, the number of backspaces (\!) that you need depends on the content, so it is not easy to automate this. This is also dependent on the font in use, so if you are doing this on your own web site and using HTML-CSS (as opposed to SVG or CommonHTML output), you might want to disable the use of local STIX fonts, since the spacing would be different for that.
Alternatively, you could configure your page to use the STIX-Web fonts, which do include the needed characters (though not everyone likes the look of them), but you would also have to add the proper names and characters to the TeX delimiters list. Something like
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS": {fonts: ['STIX-web']},
SVG: {font: 'STIX-Web'},
TeX: {Augment: {
Definitions: {
delimiter: {
'\\llbracket': '27E6',
'\\rrbracket': '27E7
}
}
}}
});
</script>
added just before the script that loads MathJax.js itself should do it. Note that this works for HTML-CSS and SVG output, but not CommonHTML output, since the latter only uses the MathJax TeX fonts at the moment.

Displaying binomials and matrices using asciimath with mathjax

I'm trying to display different math problems using asciimath and mathjax. However some things does not seem to be supported in asciimath. For instance I'm trying to display a binomial/matrix and I can't really figure out how to do it. Would I have to use latex or mathml to do this, or is there a way to use asciimath for this?
update: I found a kinda cheeky way to show binomials in asciimath: (""_1^2) This works, but it is kinda hacky.
You can use
([1],[3])
to get a matrix with two rows of one element each surrounded by parentheses. That may be what you want, though it may be too tall for use with in-line expressions.

Manually stretch arrow in MathJax

I am using the Extpfeil extension in Mathjax to produce arrows in my html page. In particular I am using:
\Newextarrow{\cs}{lspace,rspace}{unicode-char}
This works great for some arrows (for example, see answer by Davide), but as the documentation states:
Note that MathJax knows how to stretch only a limited number of
characters, so you may not actually get a stretchy character this way.
Unfortunately, I really need to use one of these non-supported characters (specifically, 0x21CC), and it would be very nice if I could get it to stretch. Is there a way I can manually specify an amount to stretch the arrows in a nice way? For context, I'm trying to make chemical reaction diagrams like this:
The overset and underset variables may be a few characters long, so the stretching is necessary.
The ability of MathJax to stretch a character depends on the availability of the appropriate glyphs within the font that it is using. The MathJax TeX font (the usual web-based font) doesn't have the necessary glyphs to stretch U+21CC; however, the STIX fonts do, and as of version 2.3, MathJax includes web versions of the STIX fonts. So if you are authoring your own pages and can specify the font, you could get U+21CC to stretch. But if you are using a site like StackExchange, where you can't control the font, you are limited to the font in use.
To do this, add
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS": {
preferredFont: "STIX",
availableFonts: ["STIX"],
webFont: "STIX-Web"
},
SVG: {
font: "STIX-Web"
},
TeX: {
extensions: ["extpfeil.js"]
}
});
</script>
just before the script that loads MathJax.js. Then in the body of your page use
<div style="display:none">
$$\Newextarrow{\rightleftharpoons}{5,5}{0x21CC}$$
</div>
to define the arrow (somewhere early on before it is used. Then use
\rightleftharpoons[xyz]{abcdefg}
to put "abcdefg" over the arrow and "xyz" below it, and have it stretch. It looks like the vertical positioning of the under-text is not great (it is a bit too low), but the arrow stretches!
Here is an example:

How can you combine Mathjax with Mathplayer?

This site http://accessiblemath.dessci.com/2010/09/mathplayer-mathjax-more-accessible-math.html is telling me it's possible to combine Mathjax with Mathplayer to make mathematics display faster.
A great feature of MathJax is that it can turn the display of math
over to a native MathML renderer such as MathPlayer. This results in
much faster display of the math.
Is this a good idea and if so, how should one go about doing this?
You don't have to do anything. MathJax will recognize the presence of MathPlayer automatically and hand over rendering of any MathML. (MathJax will still convert TeX or AsciiMath to MathML first.)

Resources