PDA

View Full Version : translating math formula into vba



mehdoush
07-18-2010, 08:55 AM
Hello,

Can someone plz help me translate this math formula into vba. Do see the attached file.

regards.

mehdoush
07-18-2010, 02:26 PM
help plz guys!

i'll be thankful.

Aussiebear
07-18-2010, 03:09 PM
How about you break down the equation into order of operation and maybe someone here will have a crack at this for you.


.... Just what does this equation do or would it be simpler to ask what does it not do?

p45cal
07-18-2010, 04:07 PM
Two things I don't understand with this formula (but I'm no mathematician):
1. What's inside the smaller of the two square root signs? Is it
WireCSA x 4 x 4 x pior:
WireCSA x 44 x pior anything else?

2. The summation symbol, ∑, what does it have to sum?

Is there anywhere else on the internet we can see this formula?

TrippyTom
07-18-2010, 04:24 PM
I think it may have to do with time travel or perhaps something about the airspeed velocity of an unladen swallow.

Aussiebear
07-19-2010, 04:37 AM
1. What's inside the smaller of the two square root signs? Is it
WireCSA x 4 x 4 x pior:
WireCSA x 44 x pior anything else?

The image has been misread by the OCR software I believe. There's something vaguely familiar about this formula..... I can't quite put my mind to it yet but a while ago I came across something similar.

At this point I believe that the sequence should read "WireCSA x 4 + Pi".



Is there anywhere else on the internet we can see this formula?

If I remember correctly, it may have something to do with trying to determine the correct cable size to carry a known current, however it was some time ago when I came across this subject.

In the mean time however, I'll settle for the unladen Swallow theory.

Aussiebear
07-19-2010, 04:59 AM
I need to give up drinking....

Lets see, 8 steps

1: Square root of (Wire Cross Section Area x 4 + Pi)
2: This Result plus (2 x Insulation)
3: This Result then divided by 2
4: This Result then Squared
5: Sigma Pi the Result
6: This Result then multiplied by 4
7: This Result then divided by Pi
8: Find the Square Root of the result.

mehdoush
07-19-2010, 10:39 AM
Thank you guys a lot for your help, it's all about calculating many wires into a sheath, in other words total estimated diameter (automotive industry), but my problem was how to translate it into vba lines you see.

those steps are totally correct:

1: Square root of (Wire Cross Section Area x 4 + Pi)
2: This Result plus (2 x Insulation)
3: This Result then divided by 2
4: This Result then Squared
5: Sigma Pi the Result
6: This Result then multiplied by 4
7: This Result then divided by Pi
8: Find the Square Root of the result.

but i ignore how to write them well in vba.
Someone plz help me ;)

p45cal
07-19-2010, 10:52 AM
everything but the Sigma Pi

What it eez?

Aussiebear
07-19-2010, 04:21 PM
Sigma should mean "sum" according to this Aussie's way of thinking.

So assuming Sum "Pi" + The "result at this point".

Since I was off target in relation to what I thought the function was about this may also be wrong.

p45cal
07-19-2010, 04:39 PM
come on mehdoush, it's your problem, given pen and paper, how would you carry out steps 4 and 5, especially 5?

rbrhodes
07-19-2010, 09:22 PM
Hey too much fun! Can't see why nobody tried?

Note: WireCSA is .25 and Insulation is also .25 in the formulas. I'm thinking is obvious where...


Assuming that it is Square the result (Step 4) then Sum (add) Pi (Step 5):

Formula:

=SQRT((((((((SQRT(0.25*4+PI()))+(0.25*2))/2)^2)+PI())*4)/PI()))


Option Explicit
Public Const pie = 3.14159265358979
Sub sheath()
Dim ans As Double
Dim WireCSA As Double
Dim Insulation As Double

WireCSA = InputBox("WireCSA?")
Insulation = InputBox("Insulation?")

' 1) (Square of Wire * 4 +pi)
' 2) + ins * 2
' 3) Above / 2

ans = (Sqr(WireCSA * 4 + pie) + (Insulation * 2)) / 2

'4) Above squared
ans = ans * ans

'5) Sigma pi
ans = pie + ans

'6) Above * 4
ans = ans * 4
'7) Above / pi
ans = ans / pie
'8) Square of above
ans = Sqr(ans)
Range("a1") = ans
End Sub


Sub sheath2()
' Same as above but one line
Dim ans As Double
Dim WireCSA As Double
Dim Insulation As Double
WireCSA = InputBox("WireCSA?")
Insulation = InputBox("Insulation?")

'Square then sum
ans = Sqr((((((((Sqr(WireCSA * 4 + pie)) + (Insulation * 2)) / 2) ^ 2) + pie) * 4) / pie))
Range("b1") = ans
End Sub




If 4 and 5 are reversed as in: Sum (add) Pi (Step 5) then Square the result (Step 4)

Formula:

=SQRT((((((((SQRT(0.25*4+PI()))+(0.25*2))/2)+PI())^2)*4)/PI()))


Sub sheath3()
'Sum then square

Dim ans As Double
Dim WireCSA As Double
Dim Insulation As Double

WireCSA = InputBox("WireCSA?")
Insulation = InputBox("Insulation?")

' 1) (Square of Wire * 4 +pi)
' 2) + ins * 2
' 3) Above / 2

ans = (Sqr(WireCSA * 4 + pie) + (Insulation * 2)) / 2

'5) Sigma pi
ans = pie + ans

'4) Above squared
ans = ans * ans

'6) Above * 4
ans = ans * 4
'7) Above / pi
ans = ans / pie
'8) Square of above
ans = Sqr(ans)
Range("a2") = ans
End Sub

Sub sheath4()
' Same as above, one line
Dim ans As Double
Dim WireCSA As Double
Dim Insulation As Double
WireCSA = InputBox("WireCSA?")
Insulation = InputBox("Insulation?")

'Sum then square
ans = Sqr((((((((Sqr(WireCSA * 4 + pie)) + (Insulation * 2)) / 2) + pie) ^ 2) * 4) / pie))
Range("b2") = ans
End Sub



Note: Could use the WorksheetFunction Pi() in here instead of constant...

Aussiebear
07-20-2010, 02:36 AM
and the answer is....?

rbrhodes
07-20-2010, 02:56 AM
and the answer is....?

Darned if I know!

I surmised it was the age old 'How many circles will fit in circle question" as I saw a lot of PI, but haviing never seen this equation before I just messed with it.

There are many sites dedicated to the question - none have anything like this formula - in fact most are just tables of proven Theorems (as opposed to M&M's or Eminem's...) and you use the tables to see what the answer is.

So if pie are indeed square (no! pie are round) then put the pie on the table? What about a laden swallow? The answer? What was the question?

Ah, I guess I should slow down on the drinking too!

Aussiebear
07-20-2010, 08:55 AM
...well in the mean time we'll hold the unladen swallow on suspicion of excessive velocity, and I'll get the next round of drinks!

mehdoush
07-20-2010, 10:49 AM
Thank you rbrhodes.
Thank you guys.
This helps.

Respect ;)

Aussiebear
07-20-2010, 05:46 PM
Respect ;)

Something about this doesn't feel "right"

mehdoush
07-21-2010, 10:34 AM
Aussiebear,

I guess i know what you mean : The Sum ∑ ; requires a do .. while statement, because everytime you'll add a wire diameter to another until calculating all diameters to get to have the sheath diameter.

Aussiebear
07-21-2010, 06:41 PM
That isn't what you initially asked for assistance in, now is it?

rbrhodes
07-21-2010, 09:47 PM
Hi Folks,

Actually...

It is, as I said earlier, to do with "How many circles fit in a circle?" (apparently unsolvable by formula as far as I've been able to find out).

However, the formula will determine 'How many circles will fit in a circle if you squish 'em?"

The original request was to translate the pictogram Formula into VBA.

As the pictogram was flawed their wasn't any chance to get it right.


What it is:

- Given a known area of wire aW and a known thickness of insulation tI

(of which there could be many of each)

1) Convert aW to Diameter
2) Add tI*2 and convert to Radius
3) Convert to new Area: aW+tI = An

3x) Repeat for all wire area & Insulation combos

4) for each An: Convert to something and sum:

((A1)*4)/Pi +((A2)*4)/Pi+((A3)*4)/Pi+...((An)*4)/Pi

5) Square root of the result for Diameter total: Dt

So when the pharmacist asks "what size?" you answer "Dt"