from hp50g expression 2 latex
|
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 ;-)) ) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)