# Calculating Semitones in an octave Classic List Threaded 3 messages Open this post in threaded view
|

## Calculating Semitones in an octave

 Hi guys, To find frequency using semitones value from A=440Hz We have, f = 2^(n/12)*440 //where n is the semitone value Now, to find semitone value for A=432Hz from 440Hz It is 432 = 2^(n/12)*440 I came up with 2^n=0.92668 Although have no clue how to calculate this in octave rather got an error saying "2^(n)=0.92668 parse error:   invalid left hand side of assignment" Someone, please shed light on this part Regards, Harish -- Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
 On Wed, Jan 29, 2020 at 12:04 PM Andrew Janke <[hidden email]> wrote: On 1/29/20 11:53 AM, harish3679 wrote: > Hi guys, > > To find frequency using semitones value from A=440Hz > > We have, f = 2^(n/12)*440 //where n is the semitone value > > Now, to find semitone value for A=432Hz from 440Hz > > It is 432 = 2^(n/12)*440 > > I came up with 2^n=0.92668I think this is wrong it should be :2^(n/12)=432/440and take the log2 of that:n/12=log2(432/440)n=12*log2(432/440)n = -0.31767  > > Although have no clue how to calculate this in octave rather got an error > saying > > "2^(n)=0.92668 > parse error: > >   invalid left hand side of assignment" > > Someone, please shed light on this part > > > Regards, > Harish > You can't write arbitrary equations in Octave and have them figure it out. The "=" sign is an assignment operation, and you need to have a single variable on the left hand side. So re-work your equation so that n is by itself on the left hand side. I think this means taking the base-2 logarithm of both sides, and ending up with: n = log2(0.92688) And that you can run in Octave: >> log2(0.92668) ans =   -1.098568597196845e-01 Cheers, Andrew -- DAS 