Dynamic Sin Program and Sound Wave Data

Program for the TI-89 that shows graphs of the form A sin (B(x - h)) + k as the parameters A, B, h, and k vary over a range specified by the user. The vertical range of the viewing window is automatically adjusted to include the maximum amplitude. The horizontal range of the viewing window does not change.

Listings follow for two sets of sound wave data generated by tuning forks and collected with a CBL. Data shows the change in pressure from normal Dp and the elapsed time t in milliseconds from the start of data collection.

               

               

Program Listing:

dynasin()
Prgm
Local a,a1,an,b,b1,bn,d,h,h1,hn,i,k,k1,kn,n,str0,str1,str2,str3,str4,str5,str6,str7,str8
"5"
® str0 : "2"® str1 : "-2"® str2
"1"
® str3 : "1"® str4 : "0"® str5
"0"
® str6 : "0"® str7 : "0"® str8
Lbl top
ClrHome
ClrIO
Dialog
Title "Dynamic SIN Graph"
Text ""
Text "Displays N graphs of A*sin(B(x-h))+k "
Text ""
Text "as one or more of the parameters A, B,"
Text ""
Text "h, and k varies over a specified range."
Text ""
Request " Number of graphs N",str0
Text ""
Text "Press alpha to turn off alpha lock."
Text ""
EndDlog
expr(str0)
® n
If ok=0
Goto drp
ClrIO
Dialog
Title "A*sin(B(x-h))+k parameters"
Text ""
Text "Press alpha to turn off alpha lock."
Text ""
Request " first A",str1
Request " last A",str2
Request " first B",str3
Request " last B",str4
EndDlog
If ok=0 : Goto drp
Dialog
Title "A*sin(B(x-h))+k parameters"
Text ""
Text "Press alpha to turn off alpha lock."
Text ""
Request " first h",str5
Request " last h",str6
Request " first k",str7
Request " last k",str8
EndDlog
If ok=0 : Goto drp
Dialog
Title "Dynamic A*sin(B(x-h))+k Settings"
Text ""
Text "Parameter First Last"
Text " A "&str1&" "&str2
Text " B "&str3&" "&str4
Text " h "&str5&" "&str6
Text " k "&str7&" "&str8
Text ""
EndDlog
If ok=0 : Goto top
Dialog
Title "TO EXIT"
Text ""
Text "Program will cycle graphs thru"
Text ""
Text "parameters in "&str0&" steps until the"
Text ""
Text "ESC key is pressed."
Text ""
Text "Press ESC to halt or to change"
Text ""
Text "parameters."
Text ""
EndDlog
If ok=0 : Goto drp
expr(str1)
® a1 : expr(str2) ® an
(a1-an)/n
® da
expr(str3)
® b1 : b1® b
expr(str4)
® bn : (b1-bn)/n® db
expr(str5)
® h1 : h1® h
expr(str6)
® hn : (h1-hn)/n® dh
expr(str7)
® k1 : k1® k
expr(str8)
® kn : (k1-kn)/n® dk
0
® ky
1.1*max(abs(a1),abs(an))
® a
max(k1,kn)+a
® ymax
min(k1,kn)-a
® ymin
a1
® a
-1
® d
1
®
FnOff
PlotsOff
While ky
¹ 264
ClrDraw
DrawFunc a*sin(b*(x-h))+k
"A="&string(round(a,2))
® str
PxlText str,5,0
"B="&string(round(b,2))
® str
PxlText str,15,0
"h="&string(round(h,2))
® str
PxlText str,25,0
"k="&string(round(k,2))
® str
PxlText str,35,0
For j,1,150
EndFor
If i>n Then
1
®
-d
® d
EndIf
i+1
®
a+d*da
® a : b+d*db® b
h+d*dh
® h : k+d*dk® k
getKey()
® ky
EndWhile
ClrHome
Dialog
Title "REPEAT"
Text ""
Text "To change parameters press ENTER"
Text "To end press ESC"
Text ""
EndDlog
If ok=1
Goto top
Lbl drp
DispHome
Stop
EndPrgm

Sound Wave Data First Set Listing:

t

Dp

 

t

Dp

 

t

Dp

0.1536

0.16145

 

7.9584

0.12165

 

15.6672

0.06205

0.4864

0.08195

 

8.1920

-0.01745

 

15.9008

-0.09705

0.7168

-0.05725

 

8.4256

-0.11685

 

16.1344

-0.19645

0.9504

-0.17655

 

8.6592

-0.23615

 

16.3680

-0.25605

1.1840

-0.21625

 

8.8928

-0.27595

 

16.6016

-0.33555

1.4176

-0.31565

 

9.1264

-0.29585

 

16.8352

-0.27595

1.6512

-0.27595

 

9.3600

-0.29585

 

17.0688

-0.25605

1.8848

-0.23615

 

9.5936

-0.19645

 

17.3024

-0.15665

2.1184

-0.17655

 

9.8272

-0.13675

 

17.5360

-0.03735

2.3520

-0.05725

 

10.0608

-0.01745

 

17.7696

0.04215

2.5856

0.02225

 

10.2944

0.10185

 

18.0032

0.16145

2.8192

0.12165

 

10.5280

0.16145

 

18.2368

0.24095

3.0528

0.22115

 

10.7616

0.28075

 

18.4704

0.28075

3.2864

0.26085

 

10.9952

0.30065

 

18.7040

0.32055

3.5200

0.30065

 

11.2288

0.28075

 

18.9376

0.24095

3.7536

0.26085

 

11.4624

0.26085

 

19.1712

0.18135

3.9872

0.20125

 

11.6960

0.12165

 

19.4048

0.08195

4.2208

0.10185

 

11.9296

0.02225

 

19.6384

-0.07715

4.4544

-0.03735

 

12.1632

-0.09705

 

19.8720

-0.13675

4.6880

-0.13675

 

12.3968

-0.21625

 

20.1056

-0.27595

4.9216

-0.23615

 

12.6304

-0.25605

 

20.3392

-0.31565

5.1552

-0.29585

 

12.8640

-0.31565

 

20.5728

-0.27595

5.3888

-0.27595

 

13.0976

-0.29585

 

20.8064

-0.27595

5.6224

-0.27595

 

13.3312

-0.21625

 

21.0400

-0.15665

5.8560

-0.17655

 

13.5648

-0.15665

 

21.2736

-0.07715

6.0896

-0.09705

 

13.7984

-0.01745

 

21.5072

0.02225

6.3232

-0.01745

 

14.0320

0.06205

 

21.7408

0.16145

6.5568

0.14155

 

14.2656

0.16145

 

21.9744

0.22115

6.7904

0.18135

 

14.4992

0.28075

 

22.2080

0.28075

7.0240

0.26085

 

14.7328

0.28075

 

22.4416

0.32055

7.2576

0.32055

 

14.9664

0.30065

 

22.6752

0.24095

7.4912

0.26085

 

15.2000

0.26085

 

22.9088

0.22115

7.7248

0.22115

 

15.4336

0.14155

 

23.1424

0.08195

 

Sound Wave Data Second Set Listing:

t

Dp

 

t

Dp

 

t

Dp

0.1536

0.26185

 

7.9616

0.16245

 

15.6704

-0.13575

0.4864

0.26185

 

8.1952

0.22215

 

15.9040

0.10285

0.7200

0.00345

 

8.4288

0.28175

 

16.1376

0.16245

0.9536

-0.25505

 

8.6624

0.16245

 

16.3712

0.26185

1.1872

-0.27495

 

8.8960

-0.13575

 

16.6048

0.26185

1.4208

-0.19545

 

9.1296

-0.27495

 

16.8384

0.02325

1.6544

-0.11585

 

9.3632

-0.23515

 

17.0720

-0.23515

1.8880

0.10285

 

9.5968

-0.17555

 

17.3056

-0.25505

2.1216

0.32155

 

9.8304

-0.03635

 

17.5392

-0.19545

2.3552

0.28175

 

10.0640

0.22215

 

17.7728

-0.13575

2.5888

0.06305

 

10.2976

0.34135

 

18.0064

0.08295

2.8224

-0.05625

 

10.5312

0.16245

 

18.2400

0.32155

3.0560

-0.21525

 

10.7648

0.02325

 

18.4736

0.26185

3.2896

-0.33455

 

10.9984

-0.11585

 

18.7072

0.08295

3.5232

-0.21525

 

11.2320

-0.29485

 

18.9408

-0.03635

3.7568

0.06305

 

11.4656

-0.31465

 

19.1744

-0.19545

3.9904

0.18235

 

11.6992

-0.07615

 

19.4080

-0.33455

4.2240

0.24195

 

11.9328

0.12265

 

19.6416

-0.21525

4.4576

0.28175

 

12.1664

0.20225

 

19.8752

0.04315

4.6912

0.08295

 

12.4000

0.28175

 

20.1088

0.16245

4.9248

-0.21525

 

12.6336

0.22215

 

20.3424

0.22215

5.1584

-0.29485

 

12.8672

-0.05625

 

20.5760

0.28175

5.3920

-0.21525

 

13.1008

-0.27495

 

20.8096

0.10285

5.6256

-0.15565

 

13.3344

-0.25505

 

21.0432

-0.19545

5.8592

0.02325

 

13.5680

-0.19545

 

21.2768

-0.27495

6.0928

0.30165

 

13.8016

-0.09605

 

21.5104

-0.21525

6.3264

0.30165

 

14.0352

0.16245

 

21.7440

-0.15565

6.5600

0.12265

 

14.2688

0.34135

 

21.9776

0.02325

6.7936

-0.01645

 

14.5024

0.22215

 

22.2112

0.28175

7.0272

-0.15565

 

14.7360

0.04315

 

22.4448

0.30165

7.2608

-0.33455

 

14.9696

-0.05625

 

22.6784

0.14255

7.4944

-0.25505

 

15.2032

-0.25505

 

22.9120

0.00345

7.7280

0.00345

 

15.4368

-0.33455

 

23.1456

-0.13575