Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
Hi there all.
I have an equation as part of a long algorithm a * cos (A) + (b-f) sin (A) - p * cos^2(A) = 0 The solution of which I need is A = 0 I have variables for a,b,f&p entered in cells (say a1,a2,a,3,a4) the angle (A) could be between 0,90 Now then the result for say if a=1430 b=1651 f=7984 & p=600 would be close to 7.5124035 (although that answer actually returns 0.00076703 and not 0) I had originally thought it would be enough to run the equation in a spreadsheet with the variables in a box and then run the calculation 900 times and vlookup the nearest to 0 bu0t have found that even withthe number setting set to no decimal places I need at least 4 decimal places. That would mean I would need to run the calculation 900*900*900&^*&% alot of times. I could round the number but then I'm likely to get more than one answer. Is there an easier way of doing this acurately without resorting to lookup closest match??? cheers Nobby |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() YOU SAY ANGLE a IS BETWEEN 0 AND 90 THEN SAY THE SOLUTION FOR A= 1431 IS................ can you clarify, please -- robert111 ------------------------------------------------------------------------ robert111's Profile: http://www.excelforum.com/member.php...o&userid=31996 View this thread: http://www.excelforum.com/showthread...hreadid=568952 |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
I used Goal Seek and came up with an answer of A = 0.131116 which is in radians and this converts to 7.512403516 degrees using =DEGREES(0.131116). Ken Johnson |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Would this work for you? It returns an answer in Degrees:
This needed about 4 loops. (I used 'x for your angle) 7.51240351575601 Sub TestiT() Dim a, b, f, p a = 1430 b = 1651 f = 7984 p = 600 Debug.Print Find_x(a, b, f, p) End Sub Function Find_x(a, b, f, p) Dim x As Double Dim t As Double Dim j As Long x = 0 t = 1 Do While x < t t = x x = x + (Cos(x) * (a - p * Cos(x)) + (b - f) * Sin(x)) / _ (a * Sin(x) + Cos(x) * (f - b - 2 * p * Sin(x))) Loop '// x is in Radians '// If Degrees is desired then x = WorksheetFunction.Degrees(x) Find_x = x End Function -- HTH. :) Dana DeLouis Windows XP, Office 2003 "nobbyknownowt" wrote in message ... Hi there all. I have an equation as part of a long algorithm a * cos (A) + (b-f) sin (A) - p * cos^2(A) = 0 The solution of which I need is A = 0 I have variables for a,b,f&p entered in cells (say a1,a2,a,3,a4) the angle (A) could be between 0,90 Now then the result for say if a=1430 b=1651 f=7984 & p=600 would be close to 7.5124035 (although that answer actually returns 0.00076703 and not 0) I had originally thought it would be enough to run the equation in a spreadsheet with the variables in a box and then run the calculation 900 times and vlookup the nearest to 0 bu0t have found that even withthe number setting set to no decimal places I need at least 4 decimal places. That would mean I would need to run the calculation 900*900*900&^*&% alot of times. I could round the number but then I'm likely to get more than one answer. Is there an easier way of doing this acurately without resorting to lookup closest match??? cheers Nobby -- nobbyknownowt |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
A slight change reduces the number of Trig functions from 6 to 4.
In Radians: Function Find_x(a, b, f, p) Dim x As Double Dim t As Double Dim j As Long x = 0 t = 1 Do While x < t t = x x = x + (a + (b - f) * Tan(x) - p * Cos(x)) / _ (f - b + a * Tan(x) - 2 * p * Sin(x)) Loop Find_x = x End Function -- HTH. :) Dana DeLouis Windows XP, Office 2003 "Dana DeLouis" wrote in message ... Would this work for you? It returns an answer in Degrees: This needed about 4 loops. (I used 'x for your angle) 7.51240351575601 Sub TestiT() Dim a, b, f, p a = 1430 b = 1651 f = 7984 p = 600 Debug.Print Find_x(a, b, f, p) End Sub <snip |
#6
![]() |
|||
|
|||
![]()
Hello all, thanks for taking the time and trouble to reply.
robert111 a=1431 A=? Sorry, poor choice of identifiers. a stemmed from a measurement while A was shortened from Alpha. Ken can goal seek work automatically as part of an algoritm? Dana . Sounds like just what I need, but what do i do with the code? Sorry but my limited excel knowledge stumps me. Where do I put it? on theworksheet via view code or in a macro and then can I run it automatically as part of an algorithm. Ideally I want to find the angle then use that angle as part of the next calculation. Heres hoping Nobby |
#7
![]() |
|||
|
|||
![]()
Can anyone help???
Help I have kindly been given this code. Sub TestiT() Dim a, b, f, p a = 1430 b = 1651 f = 7984 p = 600 Debug.Print Find_x(a, b, f, p) End Sub Function Find_x(a, b, f, p) Dim x As Double Dim t As Double Dim j As Long x = 0 t = 1 Do While x t t = x x = x + (a + (b - f) * Tan(x) - p * Cos(x)) / _ (f - b + a * Tan(x) - 2 * p * Sin(x)) Loop Find_x = x End Function But not told what to do with it in order to get the result on a worklsheet. Any advice will help me move onto the next step of the worksheet Tanks Nobby |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
simplyfy and help on errors | Excel Discussion (Misc queries) |