Showing posts with label coordinate theory. Show all posts
Showing posts with label coordinate theory. Show all posts

Sunday, March 5, 2017

HP Prime: Parabolic Cylindrical Coordinates



HP Prime:  Parabolic Cylindrical Coordinates




(This is post # 700! Yay!   Thank you for sticking with me on this wonderful journey!)

The Formulas

The relationship and conversion factors between parabolic cylindrical coordinates (μ, v, ϕ) and rectangular coordinates (x, y, z) are as follows:

x = 1/2 * (μ^2 – v^2)
y = μ * v
z = z

μ = √(x + √(x^2 + y^2))
v = y / μ
z = z
(note the sequence)

where μ ≥ 0

Derivation

The formulas to find the rectangular coordinates are given.  We can derive the formulas for the parabolic cylindrical coordinates by the following:

Obviously the z coordinate remains the same in both systems.

Assume μ ≠ 0.  Then:
y = μ * v
v = y / μ

With substitution and simplification:
x = 1/2 * (μ^2 – v^2)
2*x = μ^2 – v^2
2*x = μ^2 – (y^2/μ^2)
2*x*μ^2 = μ^4 – y^2
0 = μ^4 – (2*x)*μ^2 – y^2

We have a quadratic equation in terms of μ^2.  Since μ≥0, only the positive root is considered:
μ^2 = ( 2*x + √(4*x^2 + 4*y^2) ) /2
μ^2 = ( 2*x + 2*√(x^2 + y^2) )/2
μ^2 = x + √(x^2 + y^2)
μ = √( x + √(x^2 + y^2) )

HP Prime Program PCC2REC (Parabolic Cylindrical to Rectangular)

EXPORT PCC2REC(μ,v,z)
BEGIN
// 2017-02-27 EWS
// Parabolic Cylindrical
// to Rectangular
// μ≥0
LOCAL x:=1/2*(μ^2-v^2);
LOCAL y:=μ*v;
RETURN {x,y,z};
END;

HP Prime Program REC2PBC (Rectangular to Parabolic Cylindrical)

EXPORT REC2PCC(x,y,z)
BEGIN
// 2017-02-27 EWS
// Rectangular to
// Parabolic Cylindrical
// μ≥0
LOCAL μ:=√(x+√(x^2+y^2));
LOCAL v:=y/μ;
RETURN {μ,v,z};
END;

Example

μ = 2, v = 3, z = 1
Result:  x = -2.5, y = 6, z = 1

  
Source:
P. Moon and D.E. Spencer.  Field Theory Handbook:  Including Coordinate Systems Differential Equations and Their Solutions.  2nd ed. Springer-Verlag:  Berlin, Heidelberg, New York.  1971.  ISBN 0-387-02732-7

This blog is property of Edward Shore, 2017.

HP Prime: Parabolic Coordinates



HP Prime:  Parabolic Coordinates



The Formulas

The relationship and conversion factors between parabolic coordinates (μ, v, ϕ) and rectangular coordinates (x, y, z) are as follows:

x = μ * v * cos ϕ
y = μ * v * sin ϕ
z = 1/2 * (μ^2 – v^2)

ϕ = atan(y/x)
v = √( -z + √(x^2 + y^2 + z^2))
μ = √( 2*z + v^2)
(note the sequence)

where μ ≥ 0 and v ≥ 0

Derivation

The formulas to find the rectangular coordinates are given.  We can derive the formulas for the parabolic coordinates by the following:

Assume that μ > 0 and v > 0 (neither are zero).  Then:

x = μ * v * cos ϕ  
y = μ * v * sin ϕ
x / y = (μ * v * cos ϕ)/( μ * v * sin ϕ)
x / y = 1 / tan ϕ
y / x = tan ϕ
ϕ = atan (y / x)

Express μ in terms of z:

z = 1/2 * (μ^2 – v^2)
2 * z = μ^2 – v^2
μ^2 = 2*z + v^2

Since μ is positive, only the positive square root is considered:
μ = √(2*z + v^2)

Can we find an expression for v?  If we can, we have found our formulas:

x = μ * v * cos ϕ

Square both sides:
x^2 = μ^2 * v^2 * cos^2 ϕ    (I)

Note that for a given variable w, cos(atan w) = 1 / √(w^2 + 1)
In this case, w = y/x or:
cos^2 ϕ
= (cos (atan ϕ))^2
= √(1 / ((y/x)^2 + 1))^2
= 1 / ((y/x)^2 + 1)
= x^2 / x^2 * 1 / ((y/x)^2 + 1)
= x^2 / (x^2 + y^2)

Back to (I):
x^2 = μ^2 * v^2 * cos^2 ϕ    (I)
‘x^2 = (2*z + v^2) * v^2 * x^2 / (x^2 + y^2)

Assuming x≠0, divide both sides by x^2:
1 = (2*z + v^2) * v^2 * 1 / (x^2 + y^2)
1 = (2*z*v^2 + v^4) * 1/(x^2 + y^2)
0 = 1/(x^2 + y^2) * v^4 + (2*z)/(x^2 + y^2) * v^2 – 1

Here we have a quadratic equations in the form of Av^4 + Bv^2 + C = 0 where:
A = 1/(x^2 + y^2)
B = (2*z)/(x^2 + y^2)
C = -1

The solution is v^2 = (-B + √(B^2 – 4*A*C)/(2*A).  Remember that v > 0, so only positive roots will be considered.  Then:
-B/(2*A)  = -(2*z)/(x^2 + y^2) * (x^2 + y^2)/2 = -z


And:
B^2 – 4*A*C = (4*z^2 + 4*(x^2 + y^2))/(x^2 + y^2)^2
√( B^2 – 4*A*C) = 2 * √(x^2 + y^2 + z^2)/(x^2 + y^2)
√( B^2 – 4*A*C)/(2*A) = √(x^2 + y^2 + z^2)

Hence:
v^2 = -z + √(x^2 + y^2 + z^2)
v = √(-z + √(x^2 + y^2 + z^2))

HP Prime Program PBC2REC (Parabolic to Rectangular)

EXPORT PBC2REC(u,v,φ)
BEGIN
// Parabolic to Rectangular
// u≥0, v≥0, 0≤φ<2π
// EWS 2017-02-28
LOCAL x:=u*v*COS(φ);
LOCAL y:=u*v*SIN(φ);
LOCAL z:=1/2*(u^2-v^2);
RETURN {x,y,z};
END;

HP Prime Program REC2PBC (Rectangular to Parabolic)

EXPORT REC2PBC(x,y,z)
BEGIN
// Rectangular to Parabolic
// u≥0, v≥0, 0≤φ<2π
// EWS 2017-02-28
LOCAL φ:=ATAN(y/x);
LOCAL v:=√(−z+√(x^2+y^2+z^2));
LOCAL u:=√(2*z+v^2);
RETURN {u,v,φ};
END;

Examples (angles are in radians)

μ = 1, v = 3, ϕ = 0.4
Result:  x ≈ 2.76318, y ≈ 1.16826, z = -4

x = 1.69042, y = 7.9006. z = -2.76432
Result:  μ ≈ 2.40311, v ≈ 3.36208, ϕ ≈ 1.36000

Source:
P. Moon and D.E. Spencer.  Field Theory Handbook:  Including Coordinate Systems Differential Equations and Their Solutions.  2nd ed. Springer-Verlag:  Berlin, Heidelberg, New York.  1971.  ISBN 0-387-02732-7

This blog is property of Edward Shore, 2017.

Symmetric Quartic Equation - Python

Symmetric Quartic Equation - Python Note: The code is programmed with a TI-84 Evo. No modules are used, so the scripts should be adopt...