• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

target value - circular reference - iteration

kornbrot

New Member
i am trying to solve a set of variables with a circular reference and a target value.


a = "input value"

phi = "variable"

t = "variable"

x(a,t,phi)

y(a,t,phi)

b(a,x,y,z)

z(b,t)

((x^2 + y^2)/a^2)-(z^2/B^2)!=1

i have managed to solve either the last givrn formula or the circular reference (b dependent on z <=> z demendent on b) but never both.

is there a reasonable way of doing this?

regards,

kornbrot
 
Kornbrot


Firstly, Welcome to the Chandoo.org Forums


What is the application ?


What is
Code:
((x^2 + y^2)/a^2)-(z^2/B^2)!=1

Is it a condition that must be satisfied ?
 
hello,

thanks for the welcome.

the in the far future, when all is done, i hope it to become part of a spreadsheet that automatically writes an inputfile for a FEM program from a few given input values.

the quoted formula is a condition tat must be satisfied. it defines the shape of the model...

regards,

kornbrot
 
i have sofar used a


do

x(a,t,phi)

y(a,t,phi)

b(a,x,y,z)

z(b,t)

loop until f(a,b,x,y,z)=1


but the problem is that the circular reference with b and z never works out.

regards
 
Can you tell us more about the application/function your trying to perform/calculate?


It looks sort of like a 3D ellipse formula which you want to animate as a wild guess ?
 
it should (if everithing goes well) be a cooling tower shape...

it's part of a term paper i need to write for uni.

atm i am running a code that seems to get stuck in a endless loop:


Dim x As Double

Dim y As Double

Dim z As Double

Dim t As Double

Dim b As Double

Dim a As Double

Dim phi As Double

Dim w As Double

Dim bnew As Double


a = Range("c3").Value

phi = "0"

t = 0.01

z = 1

Do

Do Until (bnew - b <= 0.0001) Or (b - bnew <= 0.0001)

bnew = b

x = a / Cos(t) * Cos(phi)

y = a / Cos(t) * Sin(phi)

b = z / (Sqr((x ^ 2 + y ^ 2) / a ^ 2 - 1))

z = -b * Tan(t)

Loop


t = t + 0.01

Loop Until (x ^ 2 + y ^ 2) / a ^ 2 - z ^ 2 / b ^ 2 = "1"


regards,

kornbrot
 
I wasn't too far off

I'll have a look/think tomorrow

Unless someone else tackles it in between
 
Hi ,


I do not know the actual results you expect from this procedure ; at present , it is going into an infinite loop because the values of "b" and "bnew" are at their default initialized value of 0.


Since both are 0 , the conditions (bnew - b <= 0.0001) Or (b - bnew <= 0.0001) are fulfilled , and the rest of the statements ( which calculate the values of x , y , b and z ) are never executed.


The outer DO ... LOOP is being executed again and again because the end condition will also never become true. I do not know whether you mean to compare the mathematical result with "1" or it is unintentional.


Stepping through the code using F8 will show you this.


Can you initialise some of the values and check it out ?


Narayan
 
the expected (and important) result for b ist about 68. have put in initial values for b an removed the outer loop, because that should be fulfilled anyway with the circular reference/iteration b <=> z bein fulfilled.

what i need now is a way to implement the termination criteria. is there a way of saying: "Loop Until z = "close to"-b * Tan(t) Or t > 360" or maybe "Loop Until z = -b * Tan(t) +- 0.01 Or t > 360"?


Dim x As Double

Dim y As Double

Dim z As Double

Dim t As Double

Dim b As Double

Dim a As Double

Dim phi As Double

Dim w As Double

Dim bnew As Double


a = Range("c3").Value

phi = 0

t = 0.0001

b = 70 Do

znew = z

x = a / Cos(t) * Cos(phi)

y = a / Cos(t) * Sin(phi)

z = -b * Tan(t)

b = z / (Sqr((x ^ 2 + y ^ 2) / a ^ 2 - 1))

t = t + 0.00000001

Loop Until z = -b * Tan(t) Or t > 360


Range("c4") = b

Range("c10") = x

Range("c11") = y

Range("c12") = z

Range("c13") = t

Range("c14") = bnew
 
Hi ,


The end condition can be ( z + b * tan(t) ) <= 0.01 or whatever is the tolerance you are looking for.


Just by the way , what is the starting value in C3 ?


Another minor point is , what is "phi" ? With a value of 0 , which does not change through the repeated executions , cos(phi) = 1 , which means this does not contribute to the various formulae ; sin(phi) being 0 also does not contribute much.


Narayan
 
phi is the angle around the tower so it shouldn't have any influence with the tower being rotationally symmetric. the starting value for a is 45.

kornbrot


EDIT: and with x^2 + y^2 it results to cos(x)^2 + sin(x)^2 = 1 it doesn't.
 
Hi ,


Are you sure about your equations ?


C4 always ends up with a value of -70 ( or rather the same as the starting value of "b" ) , C10 is always 45 ( or rather the same as the starting value of "a" ).


Narayan
 
it are defenetly the formulas in the paper i'm working from.

i get very similar values to yours.

i'll go through the paper yet another time and see wether i find something i missed the previous times.

thanks a lot for your help.
 
Back
Top