Can anyone help with a little math problem?

S

stephenc

the following code fails with "invalid procedure call or argument". Can you
see why?

Sub test()
cosh = 1.5009
myAnswer = Atn(-cosh / Sqr(-cosh * cosh + 1)) + 2 * Atn(1)
MsgBox myAnswer
End Sub

It calculates the aCos (inverse cosine) of cosh, and uses the nonintrinsic
math formula given in Word 2003 help. cosh is normally variable but 1.509 is
typical for it.
 
S

stephenc

Just to add something here that I probably should have added prevously...

cos 1.5009 = 0.06984

to take part of the formula, when cosh = 1.5009 we get

sqr(-1.5009 * 1.5009 + 1) = sqr(-1.253)

That causes a problem as you cannot do root of a negative number.
 
J

Jean-Guy Marcil

stephenc was telling us:
stephenc nous racontait que :
the following code fails with "invalid procedure call or argument".
Can you see why?

Sub test()
cosh = 1.5009
myAnswer = Atn(-cosh / Sqr(-cosh * cosh + 1)) + 2 * Atn(1)
MsgBox myAnswer
End Sub

It calculates the aCos (inverse cosine) of cosh, and uses the
nonintrinsic math formula given in Word 2003 help. cosh is normally
variable but 1.509 is typical for it.

Right off the bat, let me state that I am terrible at maths.... but...
doesn't a negative number divided by another negative number always results
in a positive number?

Since cosh is positive to start with, why do you make it negative twice?
Finally, the Sqr function does not work with negative numbers. Indeed, what
two identical numbers multiplied with each other will result in a negative
number? Since you need a negative and a positive number to get a negative
number, you can never have a "negative" power.
I.e, ( -9 = -3*3 ), but -3 is not equal to 3...
So, if you modify your formula like this:
myAnswer = CStr(Atn(cosh / Sqr(cosh * cosh + 1)) + 2 * Atn(1))
then you should find happiness, no?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
S

stephenc

Hi Jean-Guy Marcil,
I have figured out what's going wrong. The Microsoft formula is actually
correct. The problem is that cosh must be in the range -1 to 1, as is the
rule with the aCos trig function. In that case, a negative root can never
happen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top