• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Hons-and-memoization
      • Events
      • History
      • Parallelism
      • Programming
      • Start-here
      • Real
      • Debugging
      • Miscellaneous
        • Term
        • Ld
        • Hints
        • Type-set
        • Ordinals
        • ACL2-customization
        • With-prover-step-limit
        • With-prover-time-limit
        • Set-prover-step-limit
        • Local-incompatibility
        • Set-case-split-limitations
        • Subversive-recursions
        • Specious-simplification
        • Defsum
        • Oracle-timelimit
        • Thm
        • Defopener
        • Gcl
        • Case-split-limitations
        • Set-gc-strategy
        • Default-defun-mode
        • Top-level
        • Reader
        • Ttags-seen
        • Adviser
        • Ttree
        • Abort-soft
        • Defsums
        • Gc$
        • With-timeout
        • Coi-debug::fail
        • Expander
        • Gc-strategy
        • Coi-debug::assert
        • Sin-cos
          • Fast-compute-series
          • Compute-series
            • Truncated-integer-sin/cos-table
            • Truncated-integer-sin/cos-table-fn
            • Fast-compute-sin
            • Truncated-integer-sin
            • Truncated-integer-cos
            • Fast-compute-cos
          • Def::doc
          • Syntax
          • Subversive-inductions
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Sin-cos

    Compute-series

    Series approximation to SIN/COS.

    This function is used to calculate the following Maclaurin series. To compute SIN:

    x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + ...

    To compute COS:

    1- \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + ...

    Arguments:

    • x -- x
    • parity -- T to add the new term, NIL to subtract the new term.
    • ex -- x^{num}
    • fact -- num!
    • itr -- Number of iterations
    • ans -- Accumulated answer.

    Definitions and Theorems

    Function: compute-series

    (defun compute-series
           (x parity ex fact num itr ans)
           (declare (xargs :guard (and (rationalp x)
                                       (booleanp parity)
                                       (rationalp ex)
                                       (integerp fact)
                                       (> fact 0)
                                       (integerp num)
                                       (>= num 0)
                                       (integerp itr)
                                       (>= itr 0)
                                       (rationalp ans))))
           (if (zp itr)
               ans
               (compute-series x (not parity)
                               (* x x ex)
                               (* (+ 2 num) (+ 1 num) fact)
                               (+ 2 num)
                               (1- itr)
                               (if parity (+ ans (/ ex fact))
                                   (- ans (/ ex fact))))))