Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 99 users online: 0 members, 80 guests and 19 bots. Members: None. Bots: MSN/Bing (3), VoilaBot (1), Baidu (1), Magpie Crawler (3), Yahoo! Slurp (1), Googlebot (10).
RSS & Social Media
SAX
You must log in to view the SAX chat widget

This is an archived, readonly copy of the UnitedTI 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 TIBASIC subforum. Some of these topics may also be directlylinked to active Cemetech topics. If you are a Cemetech member with a linked UnitedTI account, you can link UnitedTI topics here with your current Cemetech topics.
TIBasic => TIBASIC
Author 
Message 

vanchagreen
Member
Joined: 20 Feb 2008 Posts: 136

Posted: 01 Mar 2010 09:22:56 pm Post subject: 


I'm trying to make a program that draws a slope field based on a differential equation. I can evaluate the equation quite easily, but am having trouble drawing the lines. Is there any way to draw a line based on slope rather than (x,y) coordinate pairs?
~vanchagreen 

Back to top 


wesley
Newbie
Joined: 05 May 2009 Posts: 45

Posted: 01 Mar 2010 09:29:25 pm Post subject: 


Sure, that wouldn't be too difficult. You've heard of the tangent line, right? Once you calculate the slope, simply use an arbitrary (x,y) pair to find an equation for the line tangent to the graph at the (x,y) point.
Once, you have the line, I guess you could draw it with restrictions using bounds.
Last edited by Guest on 01 Mar 2010 09:30:13 pm; edited 1 time in total 

Back to top 


vanchagreen
Member
Joined: 20 Feb 2008 Posts: 136

Posted: 01 Mar 2010 09:33:30 pm Post subject: 


The problem with the tangent line function is that it, unless I'm completely wrong, draws a line that continues till the end of the graph, which wouldn't work for a slope field, which needs small lines. 

Back to top 


wesley
Newbie
Joined: 05 May 2009 Posts: 45

Posted: 01 Mar 2010 09:40:45 pm Post subject: 


That's why I'm wondering if there's a way to control bounds from within a program. You can do it from the equation editor.
EDIT: By the way, what calculator model are you using?
Last edited by Guest on 01 Mar 2010 09:41:18 pm; edited 1 time in total 

Back to top 


meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49

Posted: 01 Mar 2010 09:57:59 pm Post subject: 


Can someone quickly refresh my mind on what a slope field is? I know that it is with all the little tick marks but can't remember what it is mapping out exactly. Like graph wise, I know the ticks are slopes. Wow, I'm confusing haha, hopefully that made sense somewhat. 

Back to top 


vanchagreen
Member
Joined: 20 Feb 2008 Posts: 136

Posted: 01 Mar 2010 10:12:46 pm Post subject: 


@Wesley: Sorry, I didn't see your first edit. And I don't know if there is a way to control bounds or not... As for my calculator model, I'm using a TI83+
@Meishe91: A slope field finds the integral(antiderivative) of a differential equation, graphically. 

Back to top 


wesley
Newbie
Joined: 05 May 2009 Posts: 45

Posted: 01 Mar 2010 10:22:37 pm Post subject: 


Ahah! You can use the Line() function. 

Back to top 


meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49

Posted: 01 Mar 2010 10:23:49 pm Post subject: 


Ya, thanks, I actually just checked my Calculus notes 'cause it was bugging me I couldn't remember haha. As for creating a program I only have an idea of how you could do it, though most likely very inefficient.
My idea is that, well first, have the user input the equation to make the field from. Then you would use some kind of loop (For( would work well I think) to check a series of points to fine the slopes. You could then have another loop inside that helps graph those lines with the Line( feature.
Like I said this is probably really inefficient and hard to program, though I will try later tonight if I have time to see if I can get it to work.
Last edited by Guest on 01 Jul 2010 09:29:42 am; edited 1 time in total 

Back to top 


vanchagreen
Member
Joined: 20 Feb 2008 Posts: 136

Posted: 01 Mar 2010 10:29:32 pm Post subject: 


@ Meishe and Wesley: My problem is graphing the lines properly with the line() function. As it only accepts (x,y) coordinate pairs, I don't see how I can get it to draw a line of a certain slope. Of course, I could just be overlooking something simple as well... 

Back to top 


meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49

Posted: 01 Mar 2010 10:41:44 pm Post subject: 


vanchagreen wrote:  @ Meishe and Wesley: My problem is graphing the lines properly with the line() function. As it only accepts (x,y) coordinate pairs, I don't see how I can get it to draw a line of a certain slope. Of course, I could just be overlooking something simple as well... 
Oh ok. Hmmmm...well the derivative gives you the slope so you could simply use the For( to check those points to get slope values for that xvalue. Easy enough I think. Now for making the lines...the inefficient part. The linear line equation, as I'm sure we all know, is y=mx+b so using another For( (where you are using this one for the b value) you could find for each line two points and store the points to A, B, C, D and plug those into the Line( command. I hope that makes sense, and hopefully you see why its inefficient.
Last edited by Guest on 01 Jul 2010 09:30:19 am; edited 1 time in total 

Back to top 


wesley
Newbie
Joined: 05 May 2009 Posts: 45

Posted: 01 Mar 2010 10:51:21 pm Post subject: 


Does it matter if you happen to know the derivative of the function? This would make it pretty easy. 

Back to top 


meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49

Posted: 01 Mar 2010 10:55:32 pm Post subject: 


Wesley wrote:  Does it matter if you happen to know the derivative of the function? This would make it pretty easy. 
Well that's what a slope field does. You have the derivative and plot those points (which are the slopes of the integral/antiderivative) and those give you the general image of the graph. Then you would have to solve for the integral and the value of C (what I learned it as), which is just that value that you have to account for. Once you have that then you can graph the integral.
Last edited by Guest on 01 Jul 2010 09:30:48 am; edited 1 time in total 

Back to top 


wesley
Newbie
Joined: 05 May 2009 Posts: 45

Posted: 01 Mar 2010 10:57:42 pm Post subject: 


Now, if you knew the derivative, I would suggest a double For loop to set up a table of the slope lines (you need to draw each line at a time while stepping through each x and y pair.
Now, I would recommend, for the calculator to only use 9 slope lines drawn across the screen and up and down (it fits more nicely). In order to find the x and y coordinates corresponding with the screen values, you could use the following:
Code: For(A,1,9
For(B,1,9
X = Xmin + B(Xmax  Xmin) / 10
Y = Ymax  A(Ymax  Ymin) / 10
End
End
This would give you each step to draw a line. 

Back to top 


meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49

Posted: 01 Mar 2010 11:03:11 pm Post subject: 


Wesley wrote:  Now, if you knew the derivative, I would suggest a double For loop to set up a table of the slope lines (you need to draw each line at a time while stepping through each x and y pair.
Now, I would recommend, for the calculator to only use 9 slope lines drawn across the screen and up and down (it fits more nicely). In order to find the x and y coordinates corresponding with the screen values, you could use the following:
Code: For(A,1,9
For(B,1,9
X = Xmin + B(Xmax  Xmin) / 10
Y = Ymax  A(Ymax  Ymin) / 10
End
End
This would give you each step to draw a line. 
That is basically what I was saying from the start...
Not exactly but ya.
Last edited by Guest on 01 Mar 2010 11:03:51 pm; edited 1 time in total 

Back to top 


wesley
Newbie
Joined: 05 May 2009 Posts: 45

Posted: 01 Mar 2010 11:09:40 pm Post subject: 


Then, building off of what I've shown earlier, we have an X value, so we could compute what our function is (assuming it's stored in a function, say Y1).
The next step would be how to draw the lines, right? Well, what if we set a sort of modularity within the function by using the trig functions? We could then take the inverse tangent of what the function Y1 returns.
Now, we have the hardest part to break down, the actual coordinates of the line. Now, I stored values in C and D before entering the loops. I had to fiddle with the constant in front to adjust the line size a bit, but that's all they are.
The line will have upper and lower bounds, with X and Y offsetting the values to position the lines correctly on the screen. We can then multiply our constants (which modify the length of the lines) by the cos(O) to find the highest X value, which will be similar for the Y's.
Notice that the second X and Y have a negative in front of the cos/sin, this is because the +X/+Y are the real modifiers of the correct positions, whereas the cos/sin are used to find where the slope is. Think back to trig where you fiddled with the unit circle and triangles.
Code: C = 0.0325(Xmax  Xmin)
D = 0.0325(Ymax  Ymin)
For(A,1,9
For(B,1,9
X = Xmin + B(Xmax  Xmin) / 10
Y = Ymax  A(Ymax  Ymin) / 10
M = Y1
O = tan1(M)
Line(Ccos(O)+X, Dsin(O)+Y, Ccos(O)+X, Dcos(O)+Y
End
End
EDIT: Of course you will have to use Sto (>) for assignment rather than "=". I was simply writing up some pseudocode of my code. Also, make sure you are in Radians, set in MODE.
Last edited by Guest on 01 Mar 2010 11:11:50 pm; edited 1 time in total 

Back to top 


vanchagreen
Member
Joined: 20 Feb 2008 Posts: 136

Posted: 01 Mar 2010 11:14:46 pm Post subject: 


A 9x9 slope field would be a bit too small, I think. In fact, I made a part of the program that sets the window variables, does the for() loops based on them (i.e. for(A,xmin,xmax,xscl)... ), it's drawing the line that I'm stuck on. How would I get a line out of: X = Xmin + B(Xmax  Xmin) / 10 , Y = Ymax  A(Ymax  Ymin) / 10 ? 

Back to top 


wesley
Newbie
Joined: 05 May 2009 Posts: 45

Posted: 01 Mar 2010 11:21:41 pm Post subject: 


vanchagreen wrote:  A 9x9 slope field would be a bit too small, I think. In fact, I made a part of the program that sets the window variables, does the for() loops based on them (i.e. for(A,xmin,xmax,xscl)... ), it's drawing the line that I'm stuck on. How would I get a line out of: X = Xmin + B(Xmax  Xmin) / 10 , Y = Ymax  A(Ymax  Ymin) / 10 ? 
Oh, I'm not talking about a 9x9 slope, but rather a 9 lines across by 9 lines down the entire screen. 

Back to top 


meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49

Posted: 01 Mar 2010 11:22:33 pm Post subject: 


vanchagreen wrote:  A 9x9 slope field would be a bit too small, I think. In fact, I made a part of the program that sets the window variables, does the for() loops based on them (i.e. for(A,xmin,xmax,xscl)... ), it's drawing the line that I'm stuck on. How would I get a line out of: X = Xmin + B(Xmax  Xmin) / 10 , Y = Ymax  A(Ymax  Ymin) / 10 ? 
Well what I was kind of saying is that the first For( gives you the xvalue. This would check for the slope. Then after you establish what m and x from y=mx+b you would use the second For( loop to establish b. For graphing the line you could then do something similar to adding a half to the xvalue in both ways to get a line for the field. I hope that made sense.
Last edited by Guest on 01 Jul 2010 09:31:14 am; edited 1 time in total 

Back to top 


wesley
Newbie
Joined: 05 May 2009 Posts: 45

Posted: 02 Mar 2010 12:12:56 am Post subject: 


I'm just curious. Does that meet your needs, or would you like further explanation/ideas? 

Back to top 


meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49

Posted: 02 Mar 2010 02:05:41 am Post subject: 


Ok. So this program is no where near perfect, I just don't have time to go though it and pick the bugs out. This is what I did though to accomplish a slope field effect. When I fix it I'll post the edit up.
Code: ClrDraw
Input Str1
For(X,Xmin,Xmax
expr(Str1→M
For(B,Ymin,Ymax
(X+.5)M+B→A
(X.5)M+B→C
Line(X+.5,A,X.5,C
End
End
Again, remember, this is not optomized or perfect. It is just to show the basic idea right now.
By the way, this code assumes you already have your window settings set. All you'd have to do is just retype them though if it doesn't fit right the first time.
Last edited by Guest on 02 Mar 2010 02:07:36 am; edited 1 time in total 

Back to top 



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 likeminded coders and tech and calculator enthusiasts via the sitewide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
© Copyright 20002014 Cemetech & Kerm Martian :: Page Execution Time: 0.031695 seconds.
