• Please use real names.

    Greetings to all who have registered to OPF and those guests taking a look around. Please use real names. Registrations with fictitious names will not be processed. REAL NAMES ONLY will be processed

    Firstname Lastname

    Register

    We are a courteous and supportive community. No need to hide behind an alia. If you have a genuine need for privacy/secrecy then let me know!
  • Welcome to the new site. Here's a thread about the update where you can post your feedback, ask questions or spot those nasty bugs!

Mathematical equations in OPF posts

Doug Kerr

Well-known member
You may have seen in various forum sections recently several threads with posts mostly by myself and Ted Cousins, discussing various technical topics. Often these post have included mathematical equations. And the need to do so will no doubt time to time arise here.

Both Ted and I have looked into various ways to include mathematical equations in OPF posts. The OPF application is not really very amenable to that.

So far it seems that there are three ways to include equations. I will illustrate by using this equation (shown here as a picture, in fact the third of the three methods I will discuss).

1784645609526.png

Method 1 - Straight ASCII text with pseudocode

This method uses only ASCII characters. Here is the above equation rendered in that form:

x=(-b+-sqrt(b^2-4ac))/2a

The constructs "+-" and "sqrt" are what I consider pseudocode in this context.

Especially for complex equations, this can be a bit hard for the reader to follow.

Method 2 - Some non-ASCII Unicode characters included

Ted has pointed out that some improvement in "readability" can sometimes be gotten with the use of non-ASCII Unicode characters, which in general the OPF application deals with graciously.

Here is an example for the same equation:

x=(-b±√(b²-4ac))/2a

On Windows keyboards, the Unicode superscript "2" can be entered with Alt+0178 (the digits being entered on the numeric keypad). The Unicode superscript "3" can be entered with Alt+0179. (There are no further superscript digits available, as far as I know.) The Unicode square root symbol is Alt+251. The Unicode "plus/minus" symbol (±) is Alt+0177.

Method 3 - Picture of an equation composed in "standard" form

There are various applications that permit the generation of equations in "standard" form. One way or another (even with "screen shot" software) we can capture a picture of the finished equation and include it in our OPF post, like so:

1784645609526.png

Further particulars of different ways of doing this are beyond the scope pf this post.

Best regards,

Doug
 
Last edited:

Doug Kerr

Well-known member
Another nice WYSIWYG equation editor is MathMagic. It is seemingly currently supported. It comes in several editions. The "Lite" edition is free; the "Personal" edition and above must be purchased (there being several licensing plans)m although the Personal edition can be used "for a while" on a free trial basis.

The Lite edition can import files in the program's parochial code and in such languages as Tex (and LaTex) and MathML (the latter being the encoding system seemingly used for most embedments of equations in HTML documents). It however cannot output an equation in Tex (or LaTeX) or MathML formats.

The Personal edition can import files in those formats and also export an equation in Tex (LaTeX) or MathML format.

I will know more later.

Best regards,

Doug
 
Last edited:

Ted Cousins

Member
Ted has pointed out that some improvement in "readability" can sometimes be gotten with the use of non-ASCII Unicode characters, which in general the OPF application deals with graciously.

Here is an example for the same equation:

x=(-b±√(b²-4ac))/2a

On Windows keyboards, the Unicode superscript "2" can be entered with Alt+0178 (the digits being entered on the numeric keypad).

Sadly, my Windows keyboard doesn't have a numeric keypad, so I can't do the "Alt+" trick. But one Unicode lister I know of inserts whatever character I click on directly into whatever editor I have open after the cursor - very handy!

... grump ... not here apparently ... worked in Misago, see link below ...

 
Last edited:

Ted Cousins

Member
Sadly, my Windows keyboard doesn't have a numeric keypad, so I can't do the "Alt+" trick. But one Unicode lister I know of inserts whatever character I click on directly into whatever editor I have open after the cursor - very handy!

... grump ... Misago but not here apparently

ho ho ... but in 'Compart' I can select the large glyph - ctl-C copy it and paste here -> ⟦
see also Hₘ (mean exposure) Or EV₁₀₀ (EV based on ISO 100).
 
Last edited:

Doug Kerr

Well-known member
Hi, Ted,

You said:

Sadly, my Windows keyboard doesn't have a numeric keypad, so I can't do the "Alt+" trick. But one Unicode lister I know of inserts whatever character I click on directly into whatever editor I have open after the cursor - very handy!

... grump ... not here apparently

ho ho ... can select the large glyph - ctl-C copy it and paste here -> ⟦

Yes, I also have a tool that will insert any Unicode character based on entry of its codepoint.

Best regards,

Doug
 

Doug Kerr

Well-known member
My so-far brief encounters with MathMagic Lite and MathMagic Personal (the latter in "trial" mode) suggest that this application is much more capable and flexible than Math Editor.

There is for me a problem, however. I have the "magnification" of my display (Windows 7) set to 150%. I need to do this because of my degraded visual acuity (I am after all 90 years old).

The MathMagic code does not properly deal with display magnification settings other than the default 100%. The result is that some critical dialog boxes are ill-displayed and in fact inoperable.

(The same is true of some other programs I use, such as the musical notation program Overture 5.)

I am in correspondence with the program's publisher on this matter.

Best regards,

Doug
 

Doug Kerr

Well-known member
MathMagic Lite and MathMagic Personal come with, and install into Windows, quite a handful of its own typefaces, which are used by default for various potential elements of equations. I have so far kept the default typefaces in play (in part because I can't yet conveniently change them owing to the interface problem I mentioned recently).

In any case, here is the old favorite, the quadratic equation, as rendered onscreen in MathMagic Lite:

1784735350037.png


Best regards,

Doug
 

Doug Kerr

Well-known member
All the above being said about MathMagic, it turn out that Math Editor is just as easy to use and takes care well of most situations I can imagine.

But it cannot, for example, export a composed equation in MathML format, the form in which equations seem most often to be represented in an HTML document.

Best regards,

Doug
 

Doug Kerr

Well-known member
This is regarding the problem with MathMagic when I have the display resolution set to other than 100%

The very kind (and responsive) tech support people at InfoLogic (the publisher of MathMagic):

• Pointed out that this is a recognized issue, which is discussed in the Read Me First (which I didn't).

• Described a relatively easy workaround which indeed gets around almost all of the problem.

• Said that they would look into curing the problem.

All very satisfying!

Best regards,

Doug
 
Last edited:

Ted Cousins

Member
Found these unicodes y=x⁽²·²⁾ (gamma) but not superscript "forward slash" in the math block so would have to calculate 1/2.2 (0.45 recurring) - a bit tedious ...

Could also go y=xⁿ where n=1/2.2
 
Last edited:

Ted Cousins

Member
All the above being said about MathMagic, it turn out that Math Editor is just as easy to use and takes care well of most situations I can imagine.

But it cannot, for example, export a composed equation in MathML format, the form in which equations seem most often to be represented in an HTML document.

Best regards,

Doug
Any use (HTML5)?

Simple Addition x + 5 = 0

Code:
xml<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi>x</mi>
  <mo>+</mo>
  <mn>5</mn>
  <mo>=</mo>
  <mn>0</mn>
</math>

 
Last edited:

Doug Kerr

Well-known member
Hi, Ted,
Any use (HTML5)?

Simple Addition x + 5 = 0

Code:
xml<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mi>x</mi>
  <mo>+</mo>
  <mn>5</mn>
  <mo>=</mo>
  <mn>0</mn>
</math>

Yes, this is the "MathML" syntax. Parts of the syntax are very odd, especially with respect to sub- and superscripts. But it seems to be the way equations are often embedded in HTML code. (It is for example how my email client, Thunderbird, will let an equation be included in a messages that is set to use HTML encoding.)

Note that the <mi> tag is for "[math]indicators" (including variable names), <mo> is for "operators", and <mn> is for numbers.

MathMagic Personal (and above) will export a composed equation in this form.

Sadly. so far as I know there is no way to put HTML code in an OPF post.

Thanks.

Best regards,

Doug
 

Doug Kerr

Well-known member
Hi, Ted,

In situations where we can "describe" an equation in the LaTeX language, for most of the equations you and I are likely to encounter it is pretty easy to hand code in LaTex.

For example,. for this favorite:

1784818854975.png

The LaTeX code is:

x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

I think the syntax there is pretty self-explanatory

Note that each what I will call "element" is enclosed in curly brackets, which can be nested as we might expect.

"Operators" and "tokens" are preceded by "\".

The fraction construct is introduced by "\frac" which is followed, without further ado, by the numerator (as an "element") and then the denominator (as an "element"), no delimiter between them.

For radicals of order greater than 2, we use (the example is for a fourth root):

\sqrt[4]x

Best regards,

Doug
 

Ted Cousins

Member
Hi, Ted,

Yes, this is the "MathML" syntax. Parts of the syntax are very odd, especially with respect to sub- and superscripts. But it seems to be the way equations are often embedded in HTML code. (It is for example how my email client, Thunderbird, will let an equation be included in a messages that is set to use HTML encoding.)

Note that the <mi> tag is for "[math]indicators" (including variable names), <mo> is for "operators", and <mn> is for numbers.

MathMagic Personal (and above) will export a composed equation in this form.

Sadly. so far as I know there is no way to put HTML code in an OPF post.
Yes, the only way I know would be to create an HTML file, enter the equation, save as "xxxx.html", put it up on my website, then link to it from here

Code:
[url]mywebsite/xxxx.html[/url]

best, Ted.
 

Doug Kerr

Well-known member
I suspect that, for the foreseeable future, here I will mostly compose equations in Math Editor, take a screen grab of the equation onscreen, and paste that picture into the OPF post editor.

Here are the two exposure metering equations from ISO 2720, rearranged to put the photographic exposure on the left (and with some of my notation):

1784827330273.png


Best regards,

Doug
 
Last edited:

Doug Kerr

Well-known member
In MathMagic (including the free Lite version) one can enter enter (or Paste) into the composition screen an "ASCII text" description of an equation, and MathMagic will transform that into an actual conventional equation.

If for example if I paste into the composition screen this:

root3( - ( q )/2 + sqrt(( q ^2)/4 + ( p ^3)/(27))) + root3( - ( q )/2 - sqrt(( q ^2)/4 + ( p ^3)/(27)))​

MathMagic without further ado turns that into this:

1784906268611.png


I think that also one can enter (or Paste) into the composition screen a LaTeX description of an equation, and MathMagic will transform that into an actual conventional equation, but I'm not sure how to do that.

Best regards,

Doug
 

Doug Kerr

Well-known member
MathMagic Personal (and above, but not the free Lite version) can export a composed equation as a picture in various formats., including JPG.

Interestingly enough, in JPG (and several other image formats), MathMagic somehow embeds a coded description of the equation. (I suspect it is in the "user comment" place.) Thus if you have MathMagic (including the Lite version) open a JPG file created by MathMagic, the equation appears, in conventional form (as originally composed in MathMagic) in the equation composition window.

That does not mean that MathMagic can interpret an actual picture of an equation. If I ask MathMagic to open a JPG file of a picture of an equation (but not one generated by MathMagic), it reports the filetype as unsupported.

Best regards,

Doug
 

Doug Kerr

Well-known member
The free open-source application suite called LibreOffice includes a module ("Math Formula") that is an equation composer. Its seems to operate with an input syntax much like that of LaTeX. I have only looked at it briefly.

But there are "palettes" that allow you to enter the code for many needed constructs by selecting a picture of the construct.

The equation so-far described by the code in the input window is shown in "developed" form in the window above.

Thus, this code in the input window:

c = sqrt{ a^2 + b^2 }​

gives this "developed" equation:

1784917202933.png

Now how one moves this into, for example, a Writer document I don't yet know.

Best regards,

Doug
 
Last edited:

Doug Kerr

Well-known member
It seems that the LibreOffice Math Formula module can export a composed equation in MathML format. This seems to be the format commonly used to represent equations in an HTML file.

Best regards,

Doug
 

Doug Kerr

Well-known member
To include an equation in a LibreOffice Writer text document:

• With the cursor at the location at which it is desired to insert the equation, select Insert>Object>Formula object.

• A window will open just like the window in the Math Equation module. But now the upper pane will show the current portion of the text document, and the nascent equation will be seen in place there as it grows.

• Compose the equation just as if one were in the Math Equation module.

• When the equation is finished, click in the upper pane anyplace other than on the new equation. The view will change back to the normal view for the text document.

To modify a completed equation in a text document, double click on it. The view will change to the equation composition view. Changes in the equation can be made in the code in the lower pane. Etc.

Best regards,

Doug
 

Doug Kerr

Well-known member
Here is a relatively serious equation shown "developed" on the LibreOffice Math Equation module:

1784923162953.png


(This is from an example supplied with the program.)

This was done with all typography and so forth per the factory defaults.

Here is the code that generated it:

f(x) = {1} over { %sigma sqrt{2 %pi} } func e^-{ {(x-%mu)^2} over {2 %sigma^2} }​
The command "func" means that the following item (here, "e") is not a variable (to be set italic) but is a "function", in which case it would be set upright. Of course here "e" is not really a function; it is only the typographical implications of the command that are of importance.

Note that many of the spaces are not needed by the syntax but are included in the input routine for clarity.

It is clear that this is not in the LateX language but in a language perhaps "inspired" by LaTeX.

Best regards,

Doug
 
Last edited:

Doug Kerr

Well-known member
A certain amount of poking around seems to confirm the notion that there is really no way to use HTML code to represent things in an OPF post.

If that is indeed so, then the only way to include any but the simplest equations in a post in the standard form is to include a picture of the equation, which as I have discussed above can be created with various tools.

While this might be considered unfortunate intellectually, in reality it is not at all disabling, nor even gravely inconvenient.

As you might expect, I close with an equation, this representing Newton's second law of motion, an equation beloved to physicists and mechanical engineers, here shown in rigorous form (with vector notation):

1784994538724.png


Best regards,

Doug
 
Last edited:

Ted Cousins

Member
https://kronometric.org/tmp/Untitled1.html

I copied a Google AI html <math> formula into the above url

Click on it and the formula will show up in a new tab, top left, small text (I've long forgotten how to enlarge text in HTML, duh) .... but on my system in FireFox, ctl-+ will expand the formula ad lib

Can also be done in XML

Code:
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mrow>
    <mi>x</mi>
    <mo>+</mo>
    <mn>5</mn>
    <mo>=</mo>
    <mn>0</mn>
  </mrow>
</math>

 
Last edited:

Doug Kerr

Well-known member
Hi, Ted,
https://kronometric.org/tmp/Untitled1.html

I copied a Google AI html <math> formula into the above url
Nicely done. Works fine here. Looks line this in my browser:

1785002446013.png

Click on it and the formula will show up in a new tab, top left, small text (I've long forgotten how to enlarge text in HTML, duh) .... but on my system in FireFox, ctl-+ will expand the formula ad lib

Can also be done in XML

Code:
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mrow>
    <mi>x</mi>
    <mo>+</mo>
    <mn>5</mn>
    <mo>=</mo>
    <mn>0</mn>
  </mrow>
</math>
And here is the code in your "HTML" example, as I'm sure you know:

<math>
<mi>x</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo>-</mo>
<mi>b</mi>
</mrow>
<mrow>
<mn>2</mn>
<mi>a</mi>
</mrow>
</mfrac>
</math>

I think that is in MathML.

The MathML tag <mrow> is used to ensure that all the elements within are rendered "in the same row"; that is, aligned. It is usually not needed, but seemingly certain "compilers" always include it out of caution (much like putting in unneeded parentheses in an expression to make the structure clearer to a human reader).

Note also that the construct with the tag <mfrac> indicates a fraction, where the numerator and denominator follow without any intervening delimiter

In the example, the numerator and denominator are both enclosed in <mrow></mrow> tags. but even if those weren't present the syntax I mentioned just above is OK. That is, this makes a nice fraction "2/3" (I think). I have not broken this into lines with indenting, a nicety used my many "compilers". I have made the numerator red and the denoninator green to help clarify the structure).:

<mfrac><mn>2</mn><mn>3</mn></mfrac.


Thanks for the examples.

Best regards,

Doug
 
Last edited:

Doug Kerr

Well-known member
For example, I write this in the code pane of LibreOffice Math:

x= frac {a} {b}​

and it shows this in the "output" pane:

1785004173785.png


But this is the MathML code it generates:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">​
<semantics>​
<mrow>​
<mi>x</mi>​
<mo stretchy="false">=</mo>​
<mfrac>​
<mi>a</mi>​
<mi>b</mi>​
</mfrac>​
</mrow>​
<annotation encoding="StarMath 5.0">x= frac {a} {b} </annotation>​
</semantics>​
</math>​

Best regards,

Doug
 

Doug Kerr

Well-known member
Hi, Ted,

I think you said recently that you use Open Office to prepare text documents and such.

I do not have Open Office here. I do have LibreOffice (although I don't regularly use it). As I understand it, Open Office and LibreOffice are "cousins".

A little poking around suggest that the equation construction facility of Open Office is much like that in LibreOffice, about which I have reported some here recently.

A little poking around suggests that an equation composed in Open Office can be saved as a MathML file. (In fact, it is said that Open Office natively stores equations in MathML form.)

This could be a handy route to generating MathML code for various reasons.

Best regards,

Doog
 

Ted Cousins

Member
'Lo Doug,

Hi, Ted,

I think you said recently that you use Open Office to prepare text documents and such.

I do not have Open Office here. I do have LibreOffice (although I don't regularly use it). As I understand it, Open Office and LibreOffice are "cousins".

A little poking around suggest that the equation construction facility of Open Office is much like that in LibreOffice, about which I have reported some here recently.

A little poking around suggests that an equation composed in Open Office can be saved as a MathML file. (In fact, it is said that Open Office natively stores equations in MathML form.)

This could be a handy route to generating MathML code for various reasons.

Best regards,

Doog
Hi Doug,

After poking around in MathML for a few days using my free Coffee Cup HTML/XML Editor, I'm finding it quite tedious writing ab initio MathML ... too much for this old brain to remember; therefore something like Open Office that generates copy/pasteable MathML code would be more useful for me ...

"poking around" continues ...

I have Apache OfficeWriter - interesting statement from their site:

.odt Standard - Save your documents in OpenDocument format, the new international standard for office documents. This XML based format means you’re not tied in to Writer. You can access your documents from any OpenDocument compliant software.
 
Last edited:

Doug Kerr

Well-known member
Hi, Doug,
'Lo Doug,

Hi/lo!
Hi Doug,

After poking around in MathML for a few days using my free Coffee Cup HTML/XML Editor, I'm finding it quite tedious writing ab initio MathML
Indeed. The syntax is very tedious, and occasionally "odd"
... therefore something like Open Office that generates copy/pasteable MathML code would be more useful for me ...
Yes, I would think so.

Best regards,

Doug
 
Top