This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message
Snipes17


Advanced Newbie


Joined: 07 May 2008
Posts: 62

Posted: 11 Nov 2008 09:46:08 pm    Post subject:

While doing some calculus homework the other night, I found and indefinite integral solver online that did everything I would encounter in the book. Later, I began to think about why TI did not put one into a calc. I thought it would not be too hard so, I started on one in basic. I didn't get far before I began websurfing for an algorithm to help me with me program. Unfortunately, I found out that the process is very complicated and it uses Risch's Theorem as well as Heuristic Style of Algorithm (coding an algorithm that solves a problem without there being a known or optimal process for doing so) coding.

The "best" solver is known as Axiom and the developers have many pages worth of text explaining the process so any dev can pick it up and modify it if possible. Unfortunately, this looks like a hard thing to do in ASM, and an even harder task in basic.

I guess I realize why TI didn't make one now... they didn't even get a perfect algebraic solver implemented and that is simpler. I wish I had some code to show for my rant, but for now you'll have to be content with the back story and a hope for a brighter future. Any help or direction would be greatly appreciated.
Back to top
thornahawk
μολών λαβέ


Active Member


Joined: 27 Mar 2005
Posts: 569

Posted: 11 Nov 2008 11:02:40 pm    Post subject:

Risch's algorithm is so terribly big and complicated that you'd be hard-pressed to try and fit the algorithm into a TI calculator, much less the special cases that fall through the cracks. The TI 89 and ilk implement a rather restricted portion of this algorithm, and one shouldn't wonder that it can't do some "simple" indefinite and definite integrals a computer algebra system can spit out in a heartbeat.

As to The Integrator, it uses something more elaborate than Risch's algorithm. See here (scroll down to "Differentiation and Integration") for details.

thornahawk
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 11 Nov 2008 11:18:13 pm    Post subject:

If you're interested in an easier challenge, try writing a program for symbolic differentiation. Unlike integration, this can be done recursively using the chain rule and such. Simplification can get tricky, depending on how far you go with it.

Last edited by Guest on 11 Nov 2008 11:18:31 pm; edited 1 time in total
Back to top
Snipes17


Advanced Newbie


Joined: 07 May 2008
Posts: 62

Posted: 12 Nov 2008 01:04:30 am    Post subject:

Quote:
As to The Integrator, it uses something more elaborate than Risch's algorithm. See here (scroll down to "Differentiation and Integration") for details.


From what I have read, Risch's Theorem is only the basis for the rest of the algorithm and that Axiom trumps The Integrator, but I use The Integrator anyway.

Also, I realized this might be too big for a TI 83/4 memory wise, but I'm still going to give it a shot and see what happens. Every "solver" that I have seen on ticalc.org is weak and limited to polynomials or are even worse than that. If all goes well, I will have one that solves enough integrals to let you check (or cheat if that is what you do) on tests, homework, etc.

Quote:
If you're interested in an easier challenge, try writing a program for symbolic differentiation. Unlike integration, this can be done recursively using the chain rule and such. Simplification can get tricky, depending on how far you go with it.


You mean something like differentiate xy+2y-x^2=38 right? That would be simpler, but I know it is already out there, so I might make a calc pack or something.
Back to top
Snipes17


Advanced Newbie


Joined: 07 May 2008
Posts: 62

Posted: 15 Nov 2008 04:35:17 pm    Post subject:

With no real time to work on this program, I have only managed to create an equation editor that works from the graphscreen. Anyway, I was wondering if there are any big optimizations that can be made to this:

Code:

1→A
1→B
7→C
1→F
SetUpEditor SD,SL,OL
4→dim([sub]L[/sub]OL
276→dim(<span style='font-size:8pt;line-height:100%'>[sub]L[/sub]</span>SL
{4,5,12,14,14,4,4,0,3,3,4,14,4,4,4,6,10,4,4,4,4,0,4,4,4,4,0,4,2,4,4,0,17,19,19,6
,7,4,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0→<span style='font-size:8pt;line-height:100%'>[sub]L[/sub]</span>SD
Text(0,0,"Y=
Text(0,83,"REG
" →Str1
Repeat M=105
-5→D
Repeat M=32 or max(Ans={23,45,105}) or (M>50 and (Amin(M!={62,91}) or not(A)((M<71 or M>95) and min(M!={51,63,64,102,104
D+1-10(D>4→D
If max(D={1,-4
Line(B,-C-1,B,-C-5,(D=1
If M=21
Then
not(A→A
Text(0,83,sub("2NDREG",3A+1,3
End
getKey→M
End
Line(B,-C-1,B,-C-5,0
If min(M!={23,45,105
Then
1+(M!=32)((10fPart(.1M)+5(iPart(.1M)-5→E
<span style='font-size:8pt;line-height:100%'>[sub]L[/sub]</span>SD(Ans+30(not(A→<span style='font-size:8pt;line-height:100%'>[sub]L[/sub]</span>SL(length(Str1
If B+Ans>93 and C<57
Then
B→<span style='font-size:8pt;line-height:100%'>[sub]L[/sub]</span>OL(iPart(C/7
1→B
C+10→C
Else
If B+Ans>93 and C=57
DelVar F
End
If A
Then
sub("X[sup]-1[/sup]sin(cos(tan(^[sup]2[/sup] ()/log(789*ln(456- 123+ 0.-",E,1
Else
sub("X sin[sup]-1[/sup](cos[sup]-1[/sup](tan[sup]-1[/sup]({pi}sqrt( <span style='font-size:8pt;line-height:100%'>E</span>  e                 [i]i[/i]",E,1
End
If F
Then
Text(C,B,Ans
Str1+Ans→Str1
B+<span style='font-size:8pt;line-height:100%'>[sub]L[/sub]</span>SL(length(Ans)-1→B
End
Else
If M=23 and 1<length(Str1
Then
If not(F
1→F
B-<span style='font-size:8pt;line-height:100%'>[sub]L[/sub]</span>SL(length(Str1)-1→B
If B<1
Then
C-10→C
<span style='font-size:8pt;line-height:100%'>[sub]L[/sub]</span>OL(iPart(C/7→B
Else
For(X,B,B+<span style='font-size:8pt;line-height:100%'>[sub]L[/sub]</span>SL(length(Str1)-1
Text(C,X,"
End
sub(Str1,1,length(Str1)-1→Str1
End
End
If M=45
Then
ClrDraw
Text(0,1,"Y=
Text(0,83,sub("2NDREG",3A+1,3
1→B
7→C
1→F
" →Str1
End
End
End


This code is just the custom text input routine. This file is the program as a whole: (Note: there is a bit of variable cleanup required after running the program)


Last edited by Guest on 15 Nov 2008 04:39:51 pm; edited 1 time in total
Back to top
Galandros


Active Member


Joined: 29 Aug 2008
Posts: 565

Posted: 16 Nov 2008 02:45:40 pm    Post subject:

Instead of:
If not(F
1→F
Use: F or 1→F

Big optimizations, I had to see more close the program flow.
Back to top
Snipes17


Advanced Newbie


Joined: 07 May 2008
Posts: 62

Posted: 16 Nov 2008 08:34:53 pm    Post subject:

Quote:
Instead of:
If not(F
1→F
Use: F or 1→F


Ummmm.... I don't know if that's what I meant to type. Thanks, I'll look at that again.
Back to top
luby
I want to go back to Philmont!!


Calc Guru


Joined: 23 Apr 2006
Posts: 1477

Posted: 17 Nov 2008 08:19:53 am    Post subject:

No, you should use not(F→F

@ snipes, I think you are confused by the "or" part. That means that you should use the or in the (2nd+math, right) Logic menu. It does an or on it, but I'm not sure it would work.


Last edited by Guest on 22 Jul 2010 11:50:24 am; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 17 Nov 2008 02:22:49 pm    Post subject:

luby wrote:
No, you should use not(F→F

@ snipes, I think you are confused by the "or" part. That means that you should use the or in the (2nd+math, right) Logic menu. It does an or on it, but I'm not sure it would work.
[post="128988"]<{POST_SNAPBACK}>[/post]

From the little code snippet, it seemed that he wanted F to become 1 if it was 0, but not vice versa. Wink


Last edited by Guest on 22 Jul 2010 11:50:49 am; edited 1 time in total
Back to top
Snipes17


Advanced Newbie


Joined: 07 May 2008
Posts: 62

Posted: 17 Nov 2008 06:02:06 pm    Post subject:

Quote:
From the little code snippet, it seemed that he wanted F to become 1 if it was 0, but not vice versa. wink.gif


Yes, you are right. That is what I was trying to do. I put the "If not(F" part in there because it was in another "If" statement beforehand and I forgot to take it out.

If you want the long explanation, here it is:
When you type in text, it wraps around if the next character is off the edge. When you are on the last row and this happens, F is reset and the character is not added to the string or the graphscreen. When you can't type anymore, and you press delete (backspace), F is set so that it knows to allow text again.

*Edit*
As I was typing this, a thought just hit me. When you type a long character, it resets F based on what was described, but what if the character was shorter and could fit at the end? I realized that if I set F to 1 before the getkey loop, I could erase the other two, and the one that initializes F and it would fix that small bug. Thanks for the help! I might not have caught this as early on if you all hadn't mentioned it.


Last edited by Guest on 17 Nov 2008 06:03:15 pm; edited 1 time in total
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 18 Nov 2008 07:25:18 am    Post subject:

Galandros wrote:
Instead of:
If not(F
1→F
Use: F or 1→F

Big optimizations, I had to see more close the program flow.
[post="128952"]<{POST_SNAPBACK}>[/post]


uhm, isn't that exacly the same as
1→F?
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 18 Nov 2008 04:55:24 pm    Post subject:

The big question is, can F take on a value other than zero or one? If not(F:1→F sets F to one if F is zero, but leaves F alone otherwise. In F or 1→F, it doesn't matter what F is, and isn't what we'd want if F could be something other than zero or one. Looking at it from this angle, the If variety cannot always be substituted for one of the others, but is acceptable in the context of this program. Lastly, the expression F or 1 is always true regardless of F, so we can replace the expression with its inevitable result of one.

Let's try optimizing something more worthwhile. Smile


Last edited by Guest on 22 Jul 2010 11:51:13 am; edited 1 time in total
Back to top
Snipes17


Advanced Newbie


Joined: 07 May 2008
Posts: 62

Posted: 18 Nov 2008 09:41:03 pm    Post subject:

Quote:
Let's try optimizing something more worthwhile. smile.gif


Well, I did post my code, and you always have this ability to reduce a solid program to a faster, smaller one, so I was hoping you could help.
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 19 Nov 2008 06:43:47 am    Post subject:

Frankly, I would optimize it to the home screen... I know that's not in the spirit of things, but I tend to want to adjust programs in the direction of what'd get the job done in the fastest time or in the least amount of space, and those are rarely graphical. :)

My above comment on finding something more worthwhile to optimize was aimed at the over-attentiveness of something so trivial; posts went by, and it's like no one else had anything to add. I had instead hoped that people would give a good shot at it.

Anyway, since the program is overall pretty decent, I'll only make note of a few things. In parts, the coding is a bit more "safe" than useful, resulting in repeated conditions and extraneous parentheses. One example is the cursor movement...

    If B+Ans>93 and C<57
    Then
    B→[font="arial"]L
    OL(iPart(C/7
    1→B
    C+10→C
    Else
    If B+Ans>93 and C=57
    DelVar F
    End

...which can be made leaner at a glance. Breaking apart and nesting the conditions (using C≠57→F as a finishing touch):

    If B+Ans>93
    Then
    If C<57
    Then
    B→[font="arial"]L
    OL(iPart(C/7
    1→B
    C+10→C
    Else
    C≠57→F
    End
    End

Saved only five bytes, but that's a good five Rollover® bytes, so don't waste it!

Three-valued whitelists like max(Ans={23,45,105}) I rarely use, and this one I'd stay away from; the comparison in question can be replaced by Ans=23 or abs(Ans-75)=30, using the rules explained here.

The logical and has greater precedence than or, so the parentheses around A or (B and C) or D can be dropped, and it will still work the same.

10fPart(.1M)+5(iPart(.1M)-5→E can be replaced by M-25-5int(.1M→E, believe it or not (as long as M remains positive).

Also, tiny things that don't need to be there, like the parenthesis in the last Line( argument, can start packing.

But, nice job with the lookup, I have to say!


Last edited by Guest on 22 Jul 2010 11:50:03 am; edited 1 time in total
Back to top
Snipes17


Advanced Newbie


Joined: 07 May 2008
Posts: 62

Posted: 19 Nov 2008 09:00:59 pm    Post subject:

Thank you for the help Goose. I knew you had some modifications for what I could hardly do any better! As for the text input, it has been a goal of mine to make a graphscreen text input for awhile, so I wanted to do it for this project. I know it takes up a lot more room, but I was doing the graphscreen so I could fit more of the equation on there for the user and use a small amount of prettyprint (not implemented yet, of course) for exponents. I haven't had much time to further this due to basketball every day, but it is moving along, albeit at a snail's pace!
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement