from hp50g expression 2 latex
|
05-23-2015, 01:35 PM
Post: #1
|
|||
|
|||
from hp50g expression 2 latex
Hello hp 50g fans,
Does anybody know a program in UserRPL (or SysRPL) which translate the hp 50g expressions into latex? I know there exist a program which transfer a latex expression in grob for displaying with the 50g. But I think the other way would be although very useful. I tried such a program, but I didn't overcome the obstacle with pairing the braces right together. Because in latex you have two kinds of braces. The argument braces for latex commands and algebra braces for grouping the expressions. While I'm writing this, I get the idea that a graph representation of the expression is a useful starting point. Sincerely peacecalc |
|||
05-26-2015, 06:02 PM
Post: #2
|
|||
|
|||
RE: from hp50g expression 2 latex
There is a new command on Prime named "latex" that will spit out a string with the input written in latex form. I've not heard of anything similar for the 50g though. It wouldn't be too difficult to make one however that would cover most stuff pretty easily.
TW Although I work for HP, the views and opinions I post here are my own. |
|||
05-26-2015, 07:50 PM
(This post was last modified: 05-26-2015 07:52 PM by peacecalc.)
Post: #3
|
|||
|
|||
RE: from hp50g expression 2 latex
Yes, for me it is not so easily because I'm not professional in programming. But the main obstacles are in solution.
The original algebraic term is transformed with the MATCH command into a new algebraic term where for example the root sign \[ \sqrt c \] is written as a function like ó(c), or the quotient a/b is substituted by ò(a;b). This strange function names are necessary to avoid any conflict by doubling names. The program takes an algebraic term and with \->STR you get a string. This string is analyzed by a program that generates a list whose elements indicates which function opens a parenthesis on which parenthesis level. The output is a simple string with latex commands. Haste makes waste. That is the plan. |
|||
05-27-2015, 02:42 PM
Post: #4
|
|||
|
|||
RE: from hp50g expression 2 latex
So my first try:
that the expression in hp 50g: Code: %%HP: T(3)A(R)F(,); and that is what I get in latex: \[ \frac{\sqrt{A+(B-C)*COS(\frac{4}{D})}*{7+E}^{\frac{F}{G-H}}}{5*({X}^{3}-{X}^{A})*LN(2*Y)*{e}^{\frac{{X}^{2}-7*X}{5}}} \] and source text is: Code: %%HP: T(3)A(R)F(,); But it is not perfect, "7 + E" needs parenthesis and the backslash is generated as a digraph after communication to pc. So you have to replace \\ with \ after copying to pc. Isn't too bad, isn't it? Programs and description of them with use later. |
|||
05-27-2015, 08:54 PM
(This post was last modified: 05-27-2015 09:18 PM by peacecalc.)
Post: #5
|
|||
|
|||
RE: from hp50g expression 2 latex
Next try:
\[ \frac{\sqrt{a+\left(b-c\right)\cdot cos\left(\frac{4}{d}\right)}\cdot \left(7+e\right)^{\frac{f}{g-h}}}{5\cdot \left(\left(x\right)^{3}-\left(x\right)^{a}\right)\cdot ln\left(2\cdot y\right)\cdot \left(e\right)^{\frac{\left(x\right)^{2}-7\cdot x}{5}}} \] Is that worth going on or it's not very useful? Code: \frac{\sqrt{a+\left(b-c\right)\cdot cos\left(\frac{4}{d}\right)}\cdot \left(7+e\right)^{\frac{f}{g-h}}}{5\cdot \left(\left(x\right)^{3}-\left(x\right)^{a}\right)\cdot ln\left(2\cdot y\right)\cdot \left(e\right)^{\frac{\left(x\right)^{2}-7\cdot x}{5}}} I implemented uppercase letters are change to lowercase. Because typing in HP 50g is easier with capitals, but normally in mathematical expressions are used lowercase letters (not always I know). Because my program is only analyzing one sign after the other, I have no change to distinguish between "e^x" and "(7+e)^x", so I always get the basis with parenthesis. The MATCH command eliminates double parenthesis always, the equation writer, too. The asterix "*" is replaced by "\cdot". You have then more multiplication dots as required by mathematical conventions, but nevertheless the expression is correct. The double backslash: I haven't any idea for a workaround (only with the replace function of an editor). If you transfer binary the result you get a chinese code on win 7. |
|||
05-27-2015, 09:24 PM
Post: #6
|
|||
|
|||
RE: from hp50g expression 2 latex
It's interesting for me so we could easily post algebraic expression from HP50 on the net
If I had to do this, I think the heart of my program could use a recursive approach with the OBJ-> command. |
|||
05-28-2015, 08:09 AM
(This post was last modified: 05-28-2015 08:12 AM by peacecalc.)
Post: #7
|
|||
|
|||
RE: from hp50g expression 2 latex
Hello Gilles,
I first tried indeed a recursiv approach, but I wasn't such familiar with that kind of programming (and the things go more complicated). I decided to use the serial programming (it's raw and not optimized anyway). The program takes its time to work on an expression (but for this might be the MATCH command reasponsible, because it's a relative "slow" command). I've found out that the editor program "jedit" (freeware) can read the *.hp (binary files with the output string) and translate it into readable text (no chinese anymore, but I do not know how this works, but who cares...) and without doubling the backlashes. And here you can see the code: Code:
And of course the code can be extended to integrals, sums and / or products with an index. |
|||
06-11-2015, 08:13 PM
(This post was last modified: 06-11-2015 09:53 PM by peacecalc.)
Post: #8
|
|||
|
|||
RE: from hp50g expression 2 latex
Hello 50g freaks,
as I tried to program for example the integral from RPL to TeX I failed with my serial approach. Further analysis shows me that there a two kind of functions such like "+" with the operands surround and like int(...) with the arguments one after the other. Similar to TeX. So I tried a second time the recursive approach (by the way, there is no need anymore for the little programs with the MATCH command, so it is really faster). I made two programs \->HP2TEX and LOOKUP and a nested list TXPAT for the patterns. \->HP2TEX is the main program LOOKUP is the helper for searching in TXPAT. \->HP2TEX has some restrictions: a) No conversion from caps to small letters b) If LOOKUP find no pattern in TXPAT it returns 0, this case will not be captured (means you get an error the program abort). First the content of TXPAT every sublist has same structure: Let us say you have RPL XROT (Read please the bigger italc comment further on!) command: This function has two arguments -> sublist has four entries: { "XROT" "\\sqrt[" "]{" "}" } the double backslash is necessary otherwise you get no backslash. A function with four arguments has six entries and so on. The advantage you can add simply rules as many you like. The counting is is fix if you needn't an element you can take "" (kind of nullstring) that doesn't change the output string, but the program works properly. Code: %%HP: T(3)A(R)F(,); EDIT: XROOT decomposes in a inverse order like other function with two arguments: XROOT(A;B) OBJ\-> you get: B A 2, XROOT instead of A B 2, XROOT so the translation rule fails. My workaround is, if you have an algebraic expression with XROOT you use a little program with MATCH to convert 'XROOT(A;B)' into 'XROT(A;B)' (this function mustn't exist, but 'XROT(A;B)' decomposes into A B 2, XROT, so the translation rule works. Now the code for LOOKUP: Code: %%HP: T(3)A(R)F(,); And now the main program \->HP2TEX Code: %%HP: T(3)A(R)F(,); input: '\.S(1;2;\->K(A+B)^3;B)' output:\[\int_{1}^{2}{\left(A+B\right)}^{3}dB\] the function \->K produces only the parenthesis in TeX (in RPL there is no need for this ;-)) ) |
|||
06-13-2015, 04:40 PM
(This post was last modified: 06-16-2015 05:40 AM by peacecalc.)
Post: #9
|
|||
|
|||
RE: from hp50g expression 2 latex
Hello all,
last revision, now it works with non ruled functions see example above and the function name is written with small letters. XRT program: Code:
the ->K code: Code:
the LOOKUP program: Code:
the rulelist TXPAT: Code:
and the main program: Code:
And now a example: input: '\.S(1;2;XROT(SIN(5);\->K(A+B)^3);B)' and you get: \[ \int\limits_{1}^{2}\sqrt[\text{sin}\left(5\right)]{{\left(A+B\right)}^{3}}dB \] So have fun, maybe someone extends the rulelist and shares it with us. greetings peaceglue P.S.: EDIT: IMPORTANT!!!!!! e, pi, i are not typed as global variables, they are typed as algebraic expressions with no argument or operants, so wie have to do a little workaround. There is a little change in the main program ->HP2TEX and the TXPAT. The function names are also inserted with a command, that they aren't displayed in italics. |
|||
06-14-2015, 12:38 PM
Post: #10
|
|||
|
|||
RE: from hp50g expression 2 latex | |||
06-16-2015, 07:40 PM
Post: #11
|
|||
|
|||
RE: from hp50g expression 2 latex
Hi all,
I changed the main program a little bit and extended the pattern file, now my little program suite is able to generate the greek alphabet as far as the small greek letters are supported by the 50g. The new version will be soon available in the subforum "General Software Libary" as one directory file. Only a question: this thread has nearly 1000 hits, but only one reply. What should I conclude: my posts are such brilliant so nobody has a question or a comment or the posts of the thread are such a below grade rubbish, but you are too polite community telling me such a truth? Greetings peacecalc |
|||
06-17-2015, 05:31 AM
Post: #12
|
|||
|
|||
RE: from hp50g expression 2 latex
You're doing good work, but I have no use for the results myself
Although I have a 50g nowadays, thanks to Bernard Parisse, it's been a number of years since I did nontrivial math, on my ~25 calculators (only 2 of which are HP) or otherwise. |
|||
06-20-2015, 08:35 AM
Post: #13
|
|||
|
|||
RE: from hp50g expression 2 latex
Thank you debrouxl for answer.
I worked with tex since twenty five years. So sometimes I forget that only a few persons still working with this textformatting software (at the programming view, in nowadays there exist WYSISWYG editors for tex). But nevertheless every interested person is invited to use and maybe to develop the program. |
|||
06-20-2015, 02:00 PM
Post: #14
|
|||
|
|||
RE: from hp50g expression 2 latex
LaTeX is highly unpopular in the enterprise world where I'm working nowadays, but academia, where I used to be as an engineer, basically tolerates nothing else not even through the likes of LyX.
In an enterprise world, our small team used LaTeX for the documentation, mostly specs and design, of our project, as well as slides of some presentations. But we're total weirdos anyway: for a start, we're programming Linux-based C++ programs, under Linux... |
|||
06-21-2015, 02:23 PM
Post: #15
|
|||
|
|||
RE: from hp50g expression 2 latex
(06-20-2015 02:00 PM)debrouxl Wrote: LaTeX is highly unpopular in the enterprise world They want the "professional" stuff for their marketing departments, and don't care much at all about support docs and such. I've seen horrid fax-machine copies packed into PDFs for user's manuals, available for download for all their products, for example. I'm trying to change things by showing them how nice things COULD look, and pointing out how they could perhaps impress potential clients. And it's amazing how nice LaTeX is after having to mess with a word processor and styles for a few days on someone's large user's manual. Regarding the subject of this thread, is there some reason why you are trying to convert the expressions in the calculator? Is the LaTeX code of some use inside the calc, or should you just send it to the desktop computer and convert it there, which is where you'd use the LaTeX code anyhow? Either way, it's a cool example of what can be done. |
|||
06-21-2015, 06:37 PM
Post: #16
|
|||
|
|||
RE: from hp50g expression 2 latex
Hello Brian,
it is your second guess how I use it. I'm a teacher for physics and math. And when I'm prepare lessons or tests, I first use my hp 50g and when the expression are useful for my aims I'm now able to transfer it to the pc where I write the sheets in LaTeX. It is a little bit clumsy, but i I've the best typesetted expression in our math department (sounds toffee-nosed, but what should I do, it's the truth ;-) ). |
|||
06-23-2015, 02:09 PM
Post: #17
|
|||
|
|||
RE: from hp50g expression 2 latex
Hey LaTeX fans,
now I implemented into my little package the support for 2-, 3 dim vectors, 2x2 and 3x3 matrices. That wasn't easy, because with the hp 50g you can't put an vector or matrix into an algebraic expression (you only can put algebraic expressions for components of vektors or matrices). The object vektor or matrix is a kind of superior stucture. So I created the program V->F which transformed a vector or matrix in a function i. e.: [ 1 A ] becomes O2(1;2) or for [[1 0] [2 A]] you get M2(1;0;2;A). The function O2, O3, M2 or M3 doesn't exist (they aren't defined), but you can build algeraic expressions in your hp 50g i. e.: 'O2(3;B)+O2(-2;3*B)'. With normal vector representation you cannot do that when you put [ 3 'B' ] on stack 2 and [ - 2 '3*B' ] on stack 1 and press "+" you get immediately [ 1 '4*B' ]. On the other hand the hp 50g will never perform the addition of two non defined functions, but the hp 50g is mighty: 'O2(3;B)+O2(3;B)' is reduced to '2*O2(3;B)' if you press EVAL. With the functional representation you can build nested vectors or matrices and a lot of more astonishing: LaTeX accepts this (we are not asking for wether it is useful or not). The whole package is in the subforum HERE post #3 |
|||
02-19-2017, 07:59 PM
Post: #18
|
|||
|
|||
RE: from hp50g expression 2 latex
I'm sorry for gravedigging but very nice work of yours! On my thinclient sometimes it is easier to build the formula directly from the hp 50g (I use it as a equation/plot drawer) and I need to take a screenshot from it.
With your program one could speed up the operation and having latex is way more easier to manage on a pc. PS: my thinclient can barely run this forum page for example with my browsing habits (many tabs open on the same website). Wikis are great, Contribute :) |
|||
02-24-2017, 02:35 AM
Post: #19
|
|||
|
|||
RE: from hp50g expression 2 latex
(06-23-2015 02:09 PM)peacecalc Wrote: The whole package is in the subforum HERE post #3 I didn't try the previous versions, but in this one I had to introduce the pair of parentheses manually in the second expression. Very useful, nevertheless. '(255+114*√5-√(5*√5)*√(1292+577*√5))/10' \(\frac{255+114\cdot\sqrt{5}-\sqrt{5\cdot\sqrt{5}}\cdot \sqrt{1292+577\cdot \sqrt{5}}}{10}\) '(275+123*√5+√(5*(30238+13530*√5)))/20' \(\frac{275+123\cdot \sqrt{5}+\sqrt{5\cdot (30238+13530\cdot \sqrt{5}) }}{20}\) \frac{275+123\cdot \sqrt{5}+\sqrt{5\cdot(30238+13530\cdot\sqrt{5})}}{20} Gerson. |
|||
02-26-2017, 01:40 PM
Post: #20
|
|||
|
|||
RE: from hp50g expression 2 latex
Hello Gerson,
that is correct, but that is the reason why the function \->K exists. If you put in: '(275+123*√5+√(5*\->K(30238+13530*√5)))/20' you had to get the correct parentheses in LaTex. The Operators *,/, + and - are not recognized as functions, but as operators. The program analyzes for instance: stack n+2 : 5 stack n+1 : 2 + 3 stack n : "*" meaning : 5*(2 + 3) here you need \->K I decide me against always setting parentheses with the operators, because the I would get: (5)*((2)+(3)) in LateX, that is valid, but not beautyful. Sincerely peacecalc |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)