TI-85 Program for Generating Slope Fields of Functions of Two Variables, Study notes of Calculus

The ti-85 program code for generating slope fields of functions of two variables. The program takes user inputs for function, x and y limits, number of horizontal and vertical line segments, and calculates the slope at each point to draw the line segments. It also includes a subroutine to scale down the vertical line segments if they are too large.

Typology: Study notes

Pre 2010

Uploaded on 08/27/2009

koofers-user-baq
koofers-user-baq 🇺🇸

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
TI-85 Program for Slope Fields - Functions of Two Variables (SLPF2)
Math 142 - Spring Semester 1996
Dr. Carruth
1. :.5C Reduction factor for portion of rectangles covered by line segments (C1).
2. :ClDrw Clear any drawing that might reside on the graphing screen.
3. :FnOff Unselect any functions (Y1-Y99) for graphing.
4. :Disp "Enter F(x,y)" Display the prompt to enter the function.
5. :InpSt FUNCTION Command InpSt for accepting function input as a string.
6. :StEq(FUNCTION,F) Command StEq converts the "string" function to a "real" function.
7. :Disp "Enter xMin" Display the prompt to enter the lower limit for x values.
8. :Input xMin Command Input accepts the input value for the variable xMin.
9. :Disp "Enter xMax" Display the prompt to enter the upper limit for x values.
10. :Input xMax Command Input accepts the input value for the variable xMax.
11. :Disp "Enter yMin" Display the prompt to enter the lower limit for y values.
12. :Input yMin Command Input accepts the input value for the variable yMin.
13. :Disp "Enter yMax" Display the prompt to enter the upper limit for y values.
14. :Input yMax Command Input accepts the input value for the variable yMax.
15. :Disp "Enter Nx" Display the prompt to enter the number of horizontal line segments to use.
16. :Input NX Command Input accepts the value Nx for the variable NX.
17. :Disp "Enter Ny" Display the prompt to enter the number of vertical line segments to use.
18. :Input NY Command Input accepts the value Ny for the variable NY.
19. :(xMax-xMin)/NXH Calculating the width of horizontal intervals and assigning it to the variable H.
20. :(yMax-yMin)/NYV Calculating the height of vertical intervals and assigning it to the variable V.
21. :1I Starting the I-loop by setting I=1 (first row).
22. :Lbl A Establishing a label for the subroutine (for Goto) to move up the rows.
23. :1J Starting the J-loop by setting J=1 (first column).
24. :Lbl B Establishing a label for the subroutine (for Goto) to move across the columns.
25. :xMin+(J-1)*H+H/2x Calculating the x-coordinate of the center of the (I,J) rectangle.
26. :yMin+(I-1)*V+V/2y Calculating the y-coordinate of the center of the (I,J) rectangle.
27. :FM Evaluating F(x,y) at the point (x,y) and assigning the value to the variable M (slope).
28. :y-M*C*H/2S Determining the y-coordinate of the left endpoint of the slope line segment (S).
29. :y+M*C*H/2Z Determining the y-coordinate of the right endpoint of the slope line segment (Z).
30. :x-C*H/2P Determining the x-coordinate of the left endpoint of the slope line segment (P).
31. :x+C*H/2Q Determining the x-coordinate of the right endpoint of the slope line segment (Q).
32. :If abs (Z-S)>C*V Checking to see if the difference in y-coordinates is too large (want C*V).
33. :Goto D If the difference in y-coordinates is too large, go to Lbl D to scale it down.
34. :Lbl E If the difference in y-coordinates is OK, plot the line segment joining (P,S) to (Q,Z).
35. :Line(P,S,Q,Z) Sketching the slope field line segment in the (I,J) rectangle.
36. :IS>(J,NX) Testing to see if J has reached NX. If not, add 1 to J. Otherwise skip the next step.
37. :Goto B J has been increased by 1 (next rectangle/column in Row I) - repeat subroutine B.
38. :IS>(I,NY) Testing to see if i has reached NY. If not, add 1 to I. Otherwise skip the next step.
39. :Goto A I has been increased by 1 (next row up) - repeat subroutine A for this row.
40. :Stop End of program. While it has been running, the slope field graph has been generated.
41. :Lbl D Subroutine to scale down the vertical portion of line segments if they are too large.
42. :y-V/2S Making the y-coordinates of the left endpoint lie on the upper or lower edges. *
43. :y+V/2Z Making the y-coordinates of the right endpoint lie on the upper or lower edges. *
44. :(S-y)/M+xP Rescaling the x-coordinate of left endpoint to keep the slope = M after adjusting S.
45. :(Z-y)/M+xQ Rescaling the x-coordinate of right endpoint to keep the slope = M after adjusting Z.
46: :Goto E Going back to sketching the slope field line segment in the (I,J) rectangle after rescaling.
If M is positive the left endpoint will lie near the lower edge, whereas if M is negative, the left endpoint will lie near the upper edge.
*
Note: The symbol represents STO on the calculator, but it appears as on the edit screen.
Note: This program may be transferred from my calculator to yours!
Note: If you set Nx>12 and/or Ny>8, be prepared for a slow graph generation!
Warning: When addressing the first question asked in class on Wednesday, March 13, 1996, it is not enough to reset the H/2 values in Steps
25-28 to adjust the x-coordinates of endpoints of slope field line segments. One must also adjust the rescaling of y-coordinates of
these endpoints both in the conditional statement in Step 29 and in Subroutine D. Otherwise, an accurate slope field will not be
generated by the program.
E:\WP51\MATH142\SLPF2.PRG
03/15/1996 10:10 A.M.

Partial preview of the text

Download TI-85 Program for Generating Slope Fields of Functions of Two Variables and more Study notes Calculus in PDF only on Docsity!

TI-85 Program for Slope Fields - Functions of Two Variables (SLPF2) Math 142 - Spring Semester 1996 Dr. Carruth

  1. :.5C Reduction factor for portion of rectangles covered by line segments (C1).
  2. :ClDrw Clear any drawing that might reside on the graphing screen.
  3. :FnOff Unselect any functions (Y1-Y99) for graphing.
  4. :Disp "Enter F(x,y)" Display the prompt to enter the function.
  5. :InpSt FUNCTION Command InpSt for accepting function input as a string.
  6. :StEq(FUNCTION,F) Command StEq converts the "string" function to a "real" function.
  7. :Disp "Enter xMin" Display the prompt to enter the lower limit for x values.
  8. :Input xMin Command Input accepts the input value for the variable xMin.
  9. :Disp "Enter xMax" Display the prompt to enter the upper limit for x values.
  10. :Input xMax Command Input accepts the input value for the variable xMax.
  11. :Disp "Enter yMin" Display the prompt to enter the lower limit for y values.
  12. :Input yMin Command Input accepts the input value for the variable yMin.
  13. :Disp "Enter yMax" Display the prompt to enter the upper limit for y values.
  14. :Input yMax Command Input accepts the input value for the variable yMax.
  15. :Disp "Enter Nx" Display the prompt to enter the number of horizontal line segments to use.
  16. :Input NX Command Input accepts the value Nx for the variable NX.
  17. :Disp "Enter Ny" Display the prompt to enter the number of vertical line segments to use.
  18. :Input NY Command Input accepts the value Ny for the variable NY.
  19. :(xMax-xMin)/NXH Calculating the width of horizontal intervals and assigning it to the variable H.
  20. :(yMax-yMin)/NYV Calculating the height of vertical intervals and assigning it to the variable V.
  21. :1I Starting the I-loop by setting I=1 (first row).
  22. :Lbl A Establishing a label for the subroutine (for Goto) to move up the rows.
  23. :1J Starting the J-loop by setting J=1 (first column).
  24. :Lbl B Establishing a label for the subroutine (for Goto) to move across the columns.
  25. :xMin+(J-1)*H+H/2x Calculating the x-coordinate of the center of the (I,J) rectangle.
  26. :yMin+(I-1)*V+V/2y Calculating the y-coordinate of the center of the (I,J) rectangle.
  27. :FM Evaluating F(x,y) at the point (x,y) and assigning the value to the variable M (slope).
  28. :y-MCH/2S Determining the y-coordinate of the left endpoint of the slope line segment (S).
  29. :y+MCH/2Z Determining the y-coordinate of the right endpoint of the slope line segment (Z).
  30. :x-C*H/2P Determining the x-coordinate of the left endpoint of the slope line segment (P).
  31. :x+C*H/2Q Determining the x-coordinate of the right endpoint of the slope line segment (Q).
  32. :If abs (Z-S)>CV Checking to see if the difference in y-coordinates is too large (want CV).
  33. :Goto D If the difference in y-coordinates is too large, go to Lbl D to scale it down.
  34. :Lbl E If the difference in y-coordinates is OK, plot the line segment joining (P,S) to (Q,Z).
  35. :Line(P,S,Q,Z) Sketching the slope field line segment in the (I,J) rectangle.
  36. :IS>(J,NX) Testing to see if J has reached NX. If not, add 1 to J. Otherwise skip the next step.
  37. :Goto B J has been increased by 1 (next rectangle/column in Row I) - repeat subroutine B.
  38. :IS>(I,NY) Testing to see if i has reached NY. If not, add 1 to I. Otherwise skip the next step.
  39. :Goto A I has been increased by 1 (next row up) - repeat subroutine A for this row.
  40. :Stop End of program. While it has been running, the slope field graph has been generated.
  41. :Lbl D Subroutine to scale down the vertical portion of line segments if they are too large.
  42. :y-V/2S Making the y-coordinates of the left endpoint lie on the upper or lower edges. *****
  43. :y+V/2Z Making the y-coordinates of the right endpoint lie on the upper or lower edges. *****
  44. :(S-y)/M+xP Rescaling the x-coordinate of left endpoint to keep the slope = M after adjusting S.
  45. :(Z-y)/M+xQ Rescaling the x-coordinate of right endpoint to keep the slope = M after adjusting Z. 46: :Goto E Going back to sketching the slope field line segment in the (I,J) rectangle after rescaling.

***** If M is positive the left endpoint will lie near the lower edge, whereas if M is negative, the left endpoint will lie near the upper edge.

Note: The symbol ^ represents STO ^ on the calculator, but it appears as ^ on the edit screen. Note: This program may be transferred from my calculator to yours! Note: If you set Nx>12 and/or Ny>8, be prepared for a slow graph generation!

Warning: When addressing the first question asked in class on Wednesday, March 13, 1996, it is not enough to reset the H/2 values in Steps 25-28 to adjust the x-coordinates of endpoints of slope field line segments. One must also adjust the rescaling of y-coordinates of these endpoints both in the conditional statement in Step 29 and in Subroutine D. Otherwise, an accurate slope field will not be generated by the program.

E:\WP51\MATH142\SLPF2.PRG 03/15/1996 10:10 A.M.