Examples of algebra syntax

Examples of algebra syntax

by Zbigniew Fiedorowicz -
Number of replies: 44

InputOutput
@@@x^2@@@@@x^2@@
@@@A=pi r^2@@@@@A=pi r^2@@
@@@dy/dx=3x^2/y^3@@@@@dy/dx=3x^2/y^3@@
@@@asin(x/y)@@@@@asin(x/y)@@
@@@int(x/(x^2+4) dx)@@@@@int(x/(x^2+4) dx)@@
@@@int(x/(x^2+4) dx,0,1)@@@@@int(x/(x^2+4) dx,0,1)@@
@@@sqrt(x^2+y^2)@@@@@sqrt(x^2+y^2)@@
@@@sqrt(x^2+y^2,3)@@@@@sqrt(x^2+y^2,3)@@
@@@x>=1@@@@@x>=1@@
@@@x<=pi@@@@@x<=pi@@
@@@x<>infty@@@@@x<>infty@@
@@@cos(x,2)+sin(x,2)=1@@@@@cos(x,2)+sin(x,2)=1@@
@@@cosh(x,2)-sinh(x,2)=1@@@@@cosh(x,2)-sinh(x,2)=1@@
@@@lim((x-2)/(x^2-4),x,2)=1/4@@@@@lim((x-2)/(x^2-4),x,2)=1/4@@
@@@lim(x/(x^2+1),x,infty)=0@@@@@lim(x/(x^2+1),x,infty)=0@@
Average of ratings: -
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Lars Jensen -
Hi Zig,

Great job!

Is there any way to avoid the superfluous parentheses in the denominators of some of these expressions?

Lars.
In reply to Lars Jensen

Re: Examples of algebra syntax

by Zbigniew Fiedorowicz -

Is there any way to avoid the superfluous parentheses in the denominators of some of these expressions?

No, not the way the filter currently works. It relies on the WeBWorK parsing engine, which puts in the extra parentheses.  Martin doesn't like it either, because it's written in Perl.sad

In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Yip wing chiu -
Excellent! Thank you very much. Now I can post mathematical expression to my students. I want to know where I can find the whole set of functions/constants/greek chars list. I found that pi is @@pi@@ but alpha is not @@alpha@@ .
In reply to Yip wing chiu

Re: Examples of algebra syntax

by Zbigniew Fiedorowicz -

Currently @@pi@@ is the only Greek letter that the algebra filter recognizes.  It would not be difficult to add other Greek letters to the list of allowed constants/variables.  However the algebra filter is really meant to handle only very simple expressions.  More complicated expressions are supposed to be handled with the TeX filter.  For instance $$$\alpha$$$ => $$\alpha$$.  You can use the algebra debugger I posted here to translate a calculator type algebraic expression into TeX, edit it manually to add extra symbols, delete unwanted parentheses,  etc., then paste it within double dollar signs to be handled by the TeX filter.

A long term goal that Martin and Janne are hoping to realize is to integrate a mathematics editor into the HTML Editor to output MathML.

In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Sergio Di Fiore -
As for the Π, I found it very small, and was not able to resize... After all, I just used the HTML &Pi; and workr very clean and well.

Actually, a lot of things can be done that way, without much processor use approve
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Sergio Di Fiore -
As for the Π, I found it very small, and was not able to resize... After all, I just used the HTML &Pi; and workr very clean and well. Actually, it is how it's done here...

Actually, a lot of things can be done that way, without much processor use approve
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Lars Jensen -
It seems like all that is needed to remove the superfluous parentheses is to strip the outer pair parentheses (if they exist) from any denominator.

Lars.
In reply to Lars Jensen

Re: Examples of algebra syntax

by Zbigniew Fiedorowicz -
How about $$\frac{x}{(x+1)(x-1)}$$?
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Lars Jensen -
Hi Zig,

You produced this with the TeX filter, right? My comment went on the calculator filter - not the tex filter.

It is hard to produce the above expression with the calculator filter - correct me if I'm wrong. For an expression like the above, most students will enter, @@@x/((x+1)(x-1))@@@ to produce this:

@@x/((x+1)(x-1))@@

Wouldn't stripping the first \left and the last \right  from the tex-translation of the denominator of a calculator notation expression solve this problem?

Lars.
In reply to Lars Jensen

Re: Examples of algebra syntax

by Zbigniew Fiedorowicz -
OK, you've convinced me. I've now added an extra transformation rule to the filter to strip out the outermost parentheses in denominators. I've posted the updated filter to the CVS.
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Lars Jensen -
Hi Zig,

There does seems to be a problem here - I think I may be coming around to your original point of view that it may be problematic to remove any parentheses:

Check out these:
@@@1/( (c+d)/(e+f) )@@@, which produces: @@1/( (c+d)/(e+f) )@@
@@@1/( (c+d)/(e+f)/(g+h) )@@@, which produces: @@1/( (c+d)/(e+f)/(g+h) )@@
@@@1/( (c+d)/(e+f)(g+h) )@@@, which produces: @@1/( (c+d)/(e+f)(g+h) )@@

Lars.

In reply to Lars Jensen

Re: Examples of algebra syntax

by Zbigniew Fiedorowicz -

Hi Lars,

I think I've pinpointed the place in WeBWorK's AlgParser.pm where the superfluous parentheses are added to fractions. Try the new cvs algebra filter.

Zig

In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Lars Jensen -
Hi Zig,

Tried it out - it works wonderfully!

Thank you so much,
Lars.
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Frank Park -
How were you able to show that expression so cleanly?  Is that latex or mimetex?  I am trying to render equations cleanly like that but all I can do is display mimetex which is quite rigid.
In reply to Frank Park

Re: Examples of algebra syntax

by Marc Grober -
Frank,

Please stick to your other thread where I have posted info about open_basedir.
As I said, you are not getting anything from the tex binaries and are getting the results of mimetex only.
In reply to Marc Grober

Re: Examples of algebra syntax

by Ângelo Rigo -

Hi!

How can i display literally the dollar signal : $ 

Today if i type a dollar it is parsed as a algebric notation.

Thank's in advance

In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Richard Williamson -
Zig, is there a way of whowing a standard x for multiplication?

What I want to show is @@(3.72 x 5.13)/0.2=1.4   with the x appearing as a times sign.
This is for a GCSE exam practice and is needed for an example.

In reply to Richard Williamson

Re: Examples of algebra syntax

by Zbigniew Fiedorowicz -
You can't do it currently in algebra syntax.  You can do it with TeX:
$$$(3.72\times 5.13)/0.2=1.4$$$ => $$(3.72\times 5.13)/0.2=1.4$$
or
$$$\frac{3.72\times 5.13}{0.2}=1.4$$$ => $$\frac{3.72\times 5.13}{0.2}=1.4$$
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Yew Rong-shyang -

Hi,Zbigniew Fiedorowicz :
Would please show me below in TeX syntax(or algebra),thank you very much!

     98
    ×76
    588
  6860
  7448

In reply to Yew Rong-shyang

Re: Examples of algebra syntax

by John Forkosh -
TeX syntax $$$\Large \begin{array}{r} 98 \\ \times 76 \\ \hline 588 \\ 6860 \\ \hline 7448\end{array}$$$

renders

$$\Large \begin{array}{r} 98 \\ \times 76 \\ \hline 588 \\ 6860 \\ \hline 7448\end{array}$$

Oops. The copy of mimetex on moodle is several years old and doesn't seem to recognize \hline. Download a recent copy of mimetex from http://www.forkosh.com/mimetex.html which will render (with slightly better antialiasing and gamma video correction than the old version, too)

mimetex.cgi?\Large \begin{array}{r} 98 \\ \times 76 \\ \hline 588 \\ 6860 \\ \hline 7448\end{array}
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Frank Park -
How were you able to render that equation so cleanly? If I put that exact tex into my moodle site, it produces the equation very messy and jagged. If you can assist me to producing such clean tex, it would be of great help.
In reply to Frank Park

Re: Examples of algebra syntax

by Marc Grober -
There may be some confusion.
The algebra filter parses text expressions using the webworks algebra parser, then essentially passes the results to the Moodle tex filter.
If you are writing TeX then there is arguably no reason to use the algebra filter. If you are looking for something simpler than TeX, then I would argue you look at asciimathml, but that is neither here nor there.

The display of your text expressions is handled either via your local tex installation, or if there is some issue with that, via the mimetex binary shipped with Moodle.

If your display, then, is problematic, I would suggest reviewing the docs on the tex filter and use the debug page to review your tex installation.

If you find issues with your tex install, I would post in a thread focusing on debugging tex, not in the algebra filter thread, though subscription is by forum, so everyone subscribed to this forum will see your post no matter where you post it....



In reply to Zbigniew Fiedorowicz

Quadratic Formula?

by Sam Mudle -

I'm trying to get the quadratic formula in the algebra filter.

http://www.sosmath.com/algebra/quadraticeq/quadraformula/quadraformula.html

As you can see I'm not getting the result I want:

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

gives

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

In reply to Sam Mudle

Re: Quadratic Formula?

by Lars Jensen -
Hi Jeremy,

Looks like the algebra filter is broken. Use tex instead:
$$$\frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$$

gives,

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

Lars.
In reply to Lars Jensen

Re: Quadratic Formula?

by Frank Park -
How were you able to render that equation so cleanly? If I put that exact tex into my moodle site, it produces the equation very messy and jagged. If you can assist me to producing such clean tex, it would be of great help.
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Michelle Ricketts -
Thank you thank you thank you!!!

You answered my question before I even asked it.
This is exactly what I was looking for

approveMichelle
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Fred Portier -

I am looking for a complete list of what is possible using the algebra filter. Is the set of examples above complete? I intend to use Moodle in a caclulus II class and I was thinking TeX may be too much to require.

In reply to Fred Portier

Re: Examples of algebra syntax

by Gustav W Delius -
It is true that TeX is a very powerful syntax that can do almost anything. However TeX can also be very simply if you only need simple formulas. There is would advise you to use TeX syntax for your class. There are also new tools coming in a few weeks for getting an immediate preview of the typeset formulas as you type them in using TeX. These tools will not be available for the algebra syntax.
In reply to Gustav W Delius

Re: Examples of algebra syntax

by Gregory Gorny -
Hi,

Where can I find those previews of the typeset formulas for TeX???

Thank You very much for any answer.

Grzegorz Górny
In reply to Gregory Gorny

Odp: Re: Examples of algebra syntax

by Gregory Gorny -
Me again ;)

I've found what I was looking for..

thanks anyway..

Greg


In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Fei Zheng -

Hi, I've tried to input these algebra syntax in different activities such as Resource, Chat, Forum, Journal, etc. But they all show up like as I input, @@x^2@@ instead of math output. Could you tell me how to make it interpret as a math notation?

Thanks very much,

Fei

In reply to Fei Zheng

Matrix

by javi gallego -

Hello, I want to know if this syntax suports matrix, in order to write something like this:

| 0 0 1 2 |
| 1 2 1 1 |
| 3 3 2 1 |
| 1 2 3 1 |

thank a lot

In reply to javi gallego

Re: Matrix

by Yakov Keselman -
You can use this script: $$ \left| { \begin{array}{4} 0 & 0 & 1 & 2 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 1 & 2 \end{array} } \right| $$ Notes: You can replace each "&" with an "&". Use text mode. Watch out for disappearing backslashes (known bug). \left| { \begin{array}{4} 0 & 0 & 1 & 2 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 1 & 2 \\ 0 & 0 & 1 & 2 \end{array} } \right|
In reply to Zbigniew Fiedorowicz

Re: Examples of algebra syntax

by Jo Lopez -

hello Zig

Is there a book, manual, file giving all the possible algebra syntaxes?

thank you

Georges 

In reply to Jo Lopez

Re: Examples of algebra syntax

by John Isner -
Interesting.... I couldn't find any syntax reference for Algebra, only examples like the one at the beginning of this discussion. Even the official Moodle documentation on the Algebra filter doesn't contain any useful references.

Since Moodle translates Algebra notation to LaTeX, I recommend that you use the LaTeX language with the TeX filter. LaTeX is an international language, not a local dialect, and there are millions of good LaTeX references on the Web.

Don't wait for Zbigniew Fiedorowicz to reply. He is no longer subscribed to this forum.
In reply to Zbigniew Fiedorowicz

subscript syntax

by Jerald Calinisan -

Sir good day:

Please help me how to write subscript in moddle quiz. I want to write that in Multiple choice space not on the feedback space.

Thank you

Jerry

In reply to Jerald Calinisan

Re: subscript syntax

by John Isner -
Make sure the TeX filter is on. Then you can type most anywhere...

$$$\{a_1, a_2, a_3, a_4\}$$$

and it will display as

$$\{a_1, a_2, a_3, a_4\}$$
In reply to John Isner

Re: subscript syntax

by Jerald Calinisan -
Thank you very much John for your answer. One more question please... How can mixed number eg: 3 and 1/4
In reply to Jerald Calinisan

Re: subscript syntax

by John Isner -
$$$3 \frac{3}{4}$$$

displays as

$$3 \frac{3}{4}$$

You need a good LaTeX reference sheet, like this one.

If you don't want to learn LaTeX, you can also use DragMath. It is a WYSIWYG equation editor that launches from the Moodle HTML editor toolbar. It creates the LaTeX for you.