Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
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 TI-BASIC 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. 68k Calculator Basic => TI-BASIC
Author Message
blcArmadillo


Newbie


Joined: 06 Mar 2008
Posts: 1

Posted: 06 Mar 2008 06:14:55 pm    Post subject:

I've written a program to quickly find the order of reactants for a given element in an integrated rate law for use in my AP Chemistry class. However, I'm running into one slight problem. The way you pick the order of reactants is by graphing three graphs: [A] versus t, ln[A] versus t, and 1/[A] versus t where [A] is concentration and t is time. You then pick the graph that produces the straightest graph. The way I've handled this is you enter in the time and respective concentrations, the program then finds out what the slopes would be between each of the plots on all three of the graphs. Then to make the program easy to use, I want to compare all the slopes for ever consecutive points and output which one is most consistent. I initially did this by outputting the slopes to a list and then using the variance command. However, when testing the program I realized I had made a huge blunder seeing as if the graph of [A] versus t produces extremly small slopes (on the order of 10^-5) but deviate further from the slope of a straight line as compared to if a graph of say ln[A] versus t produced a vary straight line but has smaller slopes (on the order of 10^-2) than if you assume that the most accurate line is the one with the least variance you will be lead astray since the small slopes but less straight graph will give you a small (on the order of 10^-5) value of variance compared to the more linear graph. Does anyone know how I would go about using the slopes to calculate how far they deviate from a straight line and then output the result with 0 (zero) signifying a perfectly straight line and anything greater then zero signifying increasing curvature? One way I though of was using:

Code:
abs(0-mean(d)/median(d))      //d is the list holding the slopes

This worked however I'm not sure that it will work for all cases. Any input would be great. Sorry for the lengthy description/explanation. In case any of you want to play with the program I've included the full source code below. Thanks in any help you can give me, it's greatly appreciated.
-Ian B.

FULL CODE:

Code:
 rates()
 Prgm
 ClrIO
 1->c
 Loop
 Dialog
 Title "Integrated Rate Laws"
 Request "Time",x,0
 Request "[A]",y,0
 Text "Enter x for Time to denote end."
 EndDlog
 expr(x)->x
 expr(y)->y
 If x="x" Then
 Goto end
 EndIf
 If c=1 Then
 [[x,y]]m
 c+1->c
 Else
 augment(m;[[x,y]])m
 EndIf
 EndLoop
 Lbl end
 1->f
 Lbl fuction
 If f=1 Then
 Define g(s)=s
 ElseIf f=2 Then
 Define g(s)=ln(s)
 ElseIf f=3 Then
 Define g(s)=1/s
 Else
 Goto exitp
 EndIf
 1->c
 For i,1,rowDim(m)-1
 If c=1 Then
 {(g(m[2,2])-g(m[1,2]))/(m[2,1]-m[1,1])}d
 c+1->c
 Else
 augment(d,{(g(m[i+1,2])-g(m[i,2]))/(m[i+1,1]-m[i,1])})d
 EndIf
 EndFor
 Output (f-1)*10,50,approx(abs(0-mean(d)/(median(d))))
 f+1->f
 Goto fuction
 Lbl exitp
 Output 0,0,"Zero"
 Output 10,0,"First"
 Output 20,0,"Second"
 DelVar c,m,x,y,t,d,i,f,g
 EndPrgm
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 06 Mar 2008 10:30:47 pm    Post subject:

I would use the LinReg command on each set of points; this will attempt to fit a straight line to them. The resulting line is stored in regeq(x), but this doesn't really matter; what does matter is that the "correlation coefficient" is stored to the system variable corr. The correlation coefficient is a measure of how close a fit the line is. If it's a close fit, it will either be close to 1 (if the line has a positive slope) or close -1 (if the line has a negative slope). If it's a bad fit, the correlation coefficient will be close to 0.
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 GMT - 5 Hours

 

Advertisement