Question: Iterative scheme to get the catenary

Hi everyone,

I recently posted about a problem I had with an iterative scheme in 2 dimensions.. someone answered that and it worked perfectly:)

I've now moved on to a slightly more complicated version. It's in 3d but only the r and z values will be used in the iteration (trying to get the catenary)

so it's not as hard as the main problem that I'm building towards.

Basically, I'm having trouble converting the points to polar coordinates and assigning them each a [j] value, even though I've solved a similar problem at a different time.  I can't spot the problem, so if anyone could tell me why this isn't working I'd be very thankful.





G := (1/2)*RR[j-1]*(RR[j]-RR[j-1])^2/(ZZ[j]-ZZ[j-1])+(1/2)*RR[j]*(RR[j+1]-RR[j])^2/(ZZ[j+1]-ZZ[j]):

g := proc (x, y) options operator, arrow; x^3-3*x+y^3-3*y end proc:



SortedPts := sort(IP[1 .. -1], proc (A, B) options operator, arrow; evalb(A[1] < B[1] or A[1] = B[1] and A[2] < B[2] or A[1 .. 2] = B[1 .. 2] and A[3] < B[3]) end proc):

CylPts := proc (IP) options operator, arrow; [sqrt(P[1]^2+P[2]^2), arctan(P[2], P[1]), P[3]] end proc:

R := Vector(n+1, proc (j) options operator, arrow; CylPts[j][1] end proc):

GR := unapply(Gp, [RR, ZZ, j]); GZ := unapply(Gq, [RR, ZZ, j]); GRR := unapply(Gpp, [RR, ZZ, j]); GZZ := unapply(Gqq, [RR, ZZ, j])

ErrR := Vector(n+1, [0, 1]); ErrZ := Vector(n+1, [0, 1]); rho := 1.2; epsilon := 10.^(-5); while LinearAlgebra:-Norm(`<,>`(ErrR, ErrZ)) >= epsilon do for k from 2 to n do Rk := R[k]-rho*GR(R, Z, k)/GRR(R, Z, k); ErrR[k] := Rk-R[k]; R[k] := Rk; Zk := Z[k]-rho*GZ(R, Z, k)/GZZ(R, Z, k); ErrZ[k] := Zk-Z[k]; Z[k] := Zk end do end do

FinalPlot := pointplot3d({seq([R[l], T[l], Z[l]], l = 1 .. n+1)}, color = red); display(InitialPlot, FinalPlot)







Please Wait...