Sorted independent finance guides are full of helpful information on everyday money matters.

TI-84+ and Casio (fx-CG 50) Micropython: Simplifying A sin x + B cos x To r sin (x + θ)

TI-84+ and Casio (fx-CG 50) Micropython:  Simplifying  A sin x + B cos x To r sin (x + θ)

Introduction

Simplify the expression:

(I)   a * sin x + b * cos x

to an expression that involves only one trigonometric function. 

The first task is to multiply the expression by √(a^2 + b^2)/√(a^2 + b^2). (refer to Source)  This results as:

(II) a* √(a^2 + b^2)/√(a^2 + b^2) * sin x + b * √(a^2 + b^2)/√(a^2 + b^2) * cos x

Refer to the triangle diagram below and it will should become clear why it is desirable to multiply by √(a^2 + b^2)/√(a^2 + b^2). 

With:

(III)
 √(a^2 + b^2) * a/√(a^2 + b^2) * sin x +  √(a^2 + b^2) * b/√(a^2 + b^2) * cos x
=  √(a^2 + b^2) * cos θ * sin x +  √(a^2 + b^2) * sin θ * cos x
=  √(a^2 + b^2) * (cos θ * sin x +  sin θ * cos x)

With the use of the trigonometric identity:
sin(x + y) = sin x * cos y + cos x * sin y

This becomes:
(IV)
 =  √(a^2 + b^2) * sin(x + θ)

Let’s make some observations.

1.  The angle θ dependents on what quadrant the point (a,b) is. 

2.  Taking into consideration of where the point (a,b) is and the expression √(a^2 + b^2), the task of finding the coefficients of reduced formula for a * sin x + b* cos x can be achieved by calculating a rectangular to polar conversion of the point (a,b). 

Hence: (IV) becomes:

(V)
 a * sin x + b * cos x =  r * sin(x + θ)

where
r = √(a^2 + b^2)  = abs(a + bi)
θ = atan(b/a) = atan2(b,a) = arg(a + bi)

TI 84 Plus Program:  SCTOSIN

“EWS 2018-11-12”
a+bi
Disp “A*sin(X)+B*cos(X)”, “=R*sin(X+θ)”
Prompt A,B
abs(A+B*i)→R
angle(A+B*i)→θ
Disp R,”sin(X+”, θ, “)”

Casio Micropython (fx-CG 50) Script scotosin.py

import math
print(“a*sin(x)+b*cos(x)”)
print(“=r*sin(x+t)”)
a=float(input(“a:”))
b=float(input(“b:”))
r=math.sqrt(a**2+b**2)
t=math.atan2(b,a)
print(” “)
print(r)
print(“*sin(x+”)
print(t,”)”)

Examples
(Radians mode assumed)

Example 1:
4 * sin x + 2 * cos x = 4.472135955 * sin(x + 0.463647609)

Input:
a = 4
b = 2

Output:
r = 4.472135955
θ = 0.463647609

Example 2:
3 * sin x – 5 * cos x = 5.803951895 * sin(x – 1.030376827)

Input:
a = 3
b = -5

Output:
r = 5.803951895
θ = -1.030376827

Source:
Dugopolski, Mark  Trigonometry Addison Wesley: Boston 2003 pp 211-212  ISBN 0-201-70338-6

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.