Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 2.63 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2. (defun start () ;defining domain and range
  3. (defparameter *fdomain-min* 1)
  4. (defparameter *fdomain-max* 5)
  5. (defparameter *frange-min* 2)
  6. (defparameter *frange-max* 6)
  7. (defparameter *gdomain-min* 2)
  8. (defparameter *gdomain-max* 8)
  9. (defparameter *grange-min* 0)
  10. (defparameter *grange-max* 3)
  11.  
  12. ;defining variables (will change)
  13. (defparameter *fx* 0)
  14. (defparameter *gx* 0)
  15. (defparameter *fog* 0)
  16. (defparameter *gof* 0)
  17. ;defining functions
  18. ;(defun fx ()
  19. ; (progn  (if (< *fx* 1) "none"
  20. ;           (if (> *fx* 5) "none"
  21. ;             (- 7 *fx*)))
  22. ;         (setf *fx* (+ *fx* 1))))
  23. ;(defun gx ()
  24. ; (progn (if (< *gx* 2) "none"
  25. ;        (if (> *gx* 8) "none"
  26. ;          (- (* 1/2 *gx*) 1)))
  27. ;        (setf *gx* (+ *gx* 1))))
  28. (defun fx-nosetf (x)
  29.   (if (< x 1) "none"
  30.       (if (> x 5) "none"
  31.           (- 7 x))))
  32. (defun gx-nosetf (x)
  33.   (if (< x 2) "none"
  34.       (if (> x 8) "none"
  35.           (- (* 1/2 x) 1))))
  36. (defun fog (x)
  37.  (if (or (equal (gx-nosetf x) "none") (equal (fx-nosetf (gx-nosetf x)) "none")) "none"
  38.      (fx-nosetf (gx-nosetf x))))
  39. (defun gof (x)
  40.  (if (or (equal (fx-nosetf x) "none") (equal (fx-nosetf (fx-nosetf x)) "none")) "none"
  41.      (gx-nosetf (fx-nosetf x))))
  42. ;(defun fog ()
  43. ;  (if (or (equal (fx-nosetf *fog*) "none") (equal (gx-nosetf *fog*) "none")) "none"
  44. ;    (progn
  45. ;      (fx-nosetf (gx-nosetf *fog*))
  46. ;      (setf *fog* (+ *fog* 1)))))
  47. ;(defun gof ()
  48. ;  (if (or (equal (fx-nosetf *gof*) "none") (equal (gx-nosetf *gof*) "none")) "none"
  49. ;    (progn
  50. ;      (gx-nosetf (fx-nosetf *gof*))
  51. ;      (setf *gof* (+ *gof* 1)))))
  52. ;defining table function
  53.  
  54. (defun table (x) (format t "~5t~a ~15t~a, ~25t~a ~35t~a, ~45t~a ~55t~a, ~65t~a ~75t~a, ~85t~a, ~95t~a~%"
  55.                               "x" x "fx" (fx-nosetf x) "gx" (gx-nosetf x) "fog" (fog x) "gof" (gof x)))
  56. (table 0)
  57. (table 1)
  58. (table 2)
  59. (table 3)
  60. (table 4)
  61. (table 5)
  62. (table 6)
  63. (table 7)
  64. (table 8)
  65. (table 9)
  66. (table 10)
  67. ;now must answer questions
  68. (princ "#3 is included in table")
  69. (princ "#4 see table, notice when x= 6, 7, 8, that there is value for gx but not for gof")
  70. (princ "#5 plotted, lie on straight line, you can tell from table because the decrease is the same")
  71. (princ "#6 the domain of f o g is [4,8] and the range [1,3]")
  72. (princ "#7, the equations are f(x)=-x+7 and g(x)=1/2x-1")
  73. (princ "yes, table values match up, while boolean values limit domain/range appropriately")
  74. (princ "yes, the graphs are consistent")
  75. (princ "f(g(x)) would be -(1/2x-1)+7, so -1/2x+1+7, so -1/2+8")
  76. (princ "I learned a ton of stuff about lisp :D, but i also learned more about how to use my calculator, and about the domain and ranges of composition functions")
  77. )