(15C) Triangle, Square, and Sawtooth Waves - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (15C) Triangle, Square, and Sawtooth Waves (/thread-20950.html) (15C) Triangle, Square, and Sawtooth Waves - Eddie W. Shore - 12-04-2023 08:24 PM Registers Used: R1 = amplitude (A) R2 = period (P) Load A and P in R1 and R2 and then load x in the x stack. X must be non-negative or an error occurs (Error 0). Step | Key Code | Key Triangle Wave Code: ```001 | 42, 21, 11 |  LBL A 002 | 43, _5, _8 |  CF 8 003 | 43, 30, _2 |  TEST 2 (x<0?) 004 | __, __, 11 |  √x 005 | __, __, _2 |  2 006 | __, __, 20 |  × 007 | __, 43, 26 |  π 008 | __, __, 20 |  × 009 | 45, 10, _2 |  RCL÷ 2 010 | __, __, 23 |  SIN 011 | __, 43, 23 |  SIN^-1 012 | __, __, _2 |  2 013 | __, __, 20 |  × 014 | 45, 10, _1 | RCL÷ 1 015 | __, 43, 26 |  π 016 | __, __, 10 |  ÷ 017 | __, 43, 32 | RTN``` Square Wave Code: ```018 | 42, 21, 12 |  LBL B 019 | 43, _5, _8 |  CF 8 020 | 43, 30, _2 |  TEST 2 (x<0?) 021 | __, __, 11 |  √x 022 | __, __, _2 |  2 023 | __, __, 20 |  × 024 | 45, 10, _2 |  RCL÷ 2 025 | __, 43, 44 |  INT 026 | __, __, _1 |  1 027 | __, __, 16 |  CHS 028 | __, __, 34 |  x<>y 029 | __, __, 14 | y^x 030 | 45, 20, _1 | RCL× 1 031 | __, 43, 32 | RTN``` Sawtooth Wave Code: ```032 | 42, 21, 13 | LBL C 033 | 43, _5, _8 |  CF 8 034 | 43, 30, _2 |  TEST 2 (x<0?) 035 | __, __, 11 |  √x 036 | 45, 10, _2 |  RCL÷ 2 037 | __, 42, 44 |  FRAC 038 | 45, 20, _1 | RCL× 1   039 | __, 43, 32 | RTN``` Examples Let P = 2, A = 1 X = 1 Triangle: 0.0000 Square: -1.0000 Sawtooth: 0.5000 X = 2.5 Triangle: 1.0000 Square: 1.0000 Sawtooth: 0.2500 X = 4.8 Triangle: 0.4000 Square: 1.0000 Sawtooth: 0.4000