Sine Rule Function

Arithmetic, Decimals and Fractions, Prealgebra, Algebra I, Algebra II, Geometry, Trigonometry, Precalculus, Calculus, Discrete Math, Probability and Statistics, etc.
Forum Rules
By using the Wolfram Faculty Program Forum, you agree not to post any abusive, obscene, vulgar, slanderous, hateful, threatening, or sexually oriented material. Wolfram Faculty Program Forum administrators have the right to remove, edit, move or close any topic at any time should we see fit.

Personal Information: Posts in this forum may be viewed by non-members; however, the forum prohibits non-members from viewing your profile. Although your email address is hidden from both non-members and members, your account is initially configured to allow members to contact you via email through the forum. If you wish to hide your profile, or prohibit others from contacting you directly, you may change these settings by updating your profile through the User Control Panel.

Attachments: Attachments are not currently enabled on this forum. To share a file with others on this site, simply upload your file to the online storage service of your choice and include a link to the file within your post. If your school does not offer an online file storage and sharing service, the following sites provide free basic online file storage and sharing: Mozy, FilesAnywhere, Adrive, and KeepandShare.

Sine Rule Function

Postby Miles_Ford » Thu Apr 19, 2012 3:31 am

I've created a function to solve for a missing side or angle for a non-right angled triangle using the Sine Rule. The basic version works fine:
Code: Select all
SineRule[a_, A_, b_, B_] := N[Solve[a/Sin[A] == b/Sin[B], x][[1, 1, 2]]]

The students just enter in the unknown side or angle as x.

But, with this code the angle results are in radians which my students aren't familiar with. So I wrote this code to convert the radians to degrees if it's an angle they're looking for:
Code: Select all
SineRule[a_, A_, b_, B_] := If[a == x || b == x, N[Solve[a/Sin[A] == b/Sin[B], x]][[1, 1, 2]], N[Solve[a/Sin[A] == b/Sin[B], x][[1, 1, 2]] 180/\[Pi]]]

Now when I use this to solve a missing side it's fine.

But when I use it for an unknown angle it just splits the code back at me:
Code: Select all
If[24.5==x\[Or]16==x,N[Solve[24.5/sin(80 \[Degree])==16/sin(x),x]][[1,1,2]],N[(180 Solve[24.5/sin(80 \[Degree])==16/sin(x),x][[1,1,2]])/\[Pi]]]

Love some input on what I'm doing wrong here.
User avatar
Miles_Ford
 
Posts: 6
Joined: Thu Sep 08, 2011 2:48 am
Organization: St John's Anglican College
Department: Mathematics

Re: Sine Rule Function

Postby Miles_Ford » Thu Apr 19, 2012 4:25 am

Solved my own problem, needed === up in the If statement rather than ==.

The full working versions for the Sine Rule and Cosine Rule then are as follows:
Code: Select all
SineRule[a_, A_, b_, B_] :=
If[a === x || b === x, N[Solve[a/Sin[A] == b/Sin[B], x]][[1, 1, 2]],
  N[Solve[a/Sin[A] == b/Sin[B], x][[1, 1, 2]] 180/\[Pi]]]

Code: Select all
CosineRule[a_, b_, c_, C_] :=
If[C === x,
  N[Solve[c^2 == a^2 + b^2 - (2 a b Cos[C ]), x]][[2, 1, 2]] 180/\[Pi],
  N[Solve[c^2 == a^2 + b^2 - (2 a b Cos[C ]), x]][[2, 1, 2]] ]

Simply use x as the unknown.
User avatar
Miles_Ford
 
Posts: 6
Joined: Thu Sep 08, 2011 2:48 am
Organization: St John's Anglican College
Department: Mathematics


Return to Mathematics and Statistics (Primary/Secondary)

Who is online

Users browsing this forum: No registered users and 1 guest

cron