SR-boost.scm 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #| -*-Scheme-*-
  2. Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
  3. 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
  4. 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Massachusetts
  5. Institute of Technology
  6. This file is part of MIT/GNU Scheme.
  7. MIT/GNU Scheme is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11. MIT/GNU Scheme is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with MIT/GNU Scheme; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
  18. USA.
  19. |#
  20. ;;;; Special Relativity -- Boosts
  21. (define (make-4tuple ct space)
  22. (up ct (ref space 0) (ref space 1) (ref space 2)))
  23. (define (4tuple->ct v)
  24. (ref v 0))
  25. (define (4tuple->space v)
  26. (up (ref v 1) (ref v 2) (ref v 3)))
  27. (define (proper-time-interval 4tuple)
  28. (sqrt (- (square (4tuple->ct 4tuple))
  29. (square (4tuple->space 4tuple)))))
  30. (define (proper-space-interval 4tuple)
  31. (sqrt (- (square (4tuple->space 4tuple))
  32. (square (4tuple->ct 4tuple)))))
  33. (define* ((general-boost beta) xi-p)
  34. (let ((gamma (expt (- 1 (square beta)) -1/2)))
  35. (let ((factor (/ (- gamma 1) (square beta))))
  36. (let ((xi-p-time (4tuple->ct xi-p))
  37. (xi-p-space (4tuple->space xi-p)))
  38. (let ((beta-dot-xi-p (dot-product beta xi-p-space)))
  39. (make-4tuple
  40. (* gamma (+ xi-p-time beta-dot-xi-p))
  41. (+ (* gamma beta xi-p-time)
  42. xi-p-space
  43. (* factor beta beta-dot-xi-p))))))))
  44. #|
  45. (- (proper-space-interval
  46. ((general-boost (up 'vx 'vy 'vz))
  47. (make-4tuple 'ct (up 'x 'y 'z))))
  48. (proper-space-interval
  49. (make-4tuple 'ct (up 'x 'y 'z))))
  50. #| 0 |#
  51. |#
  52. ;;; It is inconvenient that the general boost as just defined does not
  53. ;;; work if $\bfbeta$ is zero. An alternate way to specify a boost is
  54. ;;; through the magnitude of $v/c$ and a direction:
  55. ;;; this one works for zero v/c ...
  56. ;;; direction is a unit 3-vector, v/c is the speed, a number.
  57. (define* ((general-boost2 direction v/c) 4tuple-prime)
  58. (let ((delta-ct-prime (4tuple->ct 4tuple-prime))
  59. (delta-x-prime (4tuple->space 4tuple-prime)))
  60. (let ((betasq (square v/c)))
  61. (let ((bx (dot-product direction delta-x-prime))
  62. (gamma (/ 1 (sqrt (- 1 betasq)))))
  63. (let ((alpha (- gamma 1)))
  64. (let ((delta-ct
  65. (* gamma (+ delta-ct-prime (* bx v/c))))
  66. (delta-x
  67. (+ (* gamma v/c direction delta-ct-prime)
  68. delta-x-prime
  69. (* alpha direction bx))))
  70. (make-4tuple delta-ct delta-x)))))))
  71. #|
  72. (let ((beta (up (/ 'v^x :c) (/ 'v^y :c) (/ 'v^z :c))))
  73. (- ((general-boost2 (up 1 0 0) 0) (up 'u0 'u1 'u2 'u3))
  74. (up 'u0 'u1 'u2 'u3)))
  75. #|(up 0 0 0 0) |#
  76. |#
  77. ;;;----------------------------------------------------------------
  78. ;;; extended rotations
  79. ;;; Boosts are linear functions of incremental vectors.
  80. ;;; To be parallel we take rotations to functions as well
  81. ;;; rather than as multipliers.
  82. (define* ((extended-rotation R) xi-p)
  83. (make-4tuple
  84. (4tuple->ct xi-p)
  85. (R (4tuple->space xi-p))))
  86. #|
  87. ;;; Check of the relation between boosts and rotations.
  88. (let ((beta (up 'bx 'by 'bz))
  89. (xi (make-4tuple 'ct (up 'x 'y 'z)))
  90. (R (compose
  91. (rotate-x 'theta)
  92. (rotate-y 'phi)
  93. (rotate-z 'psi)))
  94. (R-inverse (compose
  95. (rotate-z (- 'psi))
  96. (rotate-y (- 'phi))
  97. (rotate-x (- 'theta)))))
  98. (- ((general-boost beta) xi)
  99. ((compose (extended-rotation R-inverse)
  100. (general-boost (R beta))
  101. (extended-rotation R))
  102. xi)))
  103. #|
  104. (up 0 0 0 0)
  105. |#
  106. |#