# /home/bill/Qnial/MY_NDFS/matrix derivative examples.ndf https://en.wikipedia.org/wiki/Vector_fields_in_cylindrical_and_spherical_coordinates Reminder - vector orientations ar VERTICAL unless modified by "_T" (transpose operator). # www.BillHowell.ca 27Mar2016 start f_matDerEx := 'matrix derivative examples.ndf' ; lq_matDerEx IS loaddefs link Qnial_mine f_matDerEx write link 'loading ' f_matDerEx ; #*********** # Reminder of debug setup... flag_break := o ; flag_check := o ; flag_debug := o ; # IF flag_break = l THEN Break ; ENDIF ; # IF flag_print = l THEN <... coding for printout ...> ; ENDIF ; program_break IS { IF flag_break = l THEN Break ; ENDIF ; } # Faults occur normally during searches, and must not stop execution! settrigger o ; # watch : awesome eQNial power!! X gets count 5; watch !x 'write ''X changed to: '' X' # #************************************************** # Setup IF not in "WRITE_PARENTHESIS_ALIGNED (EACH first symbols 0) THEN loaddefs (link Qnial_mine 'matrix operations - symbolic & real-valued.ndf') 0 ; loaddefs (link Qnial_mine 'matrix - symbolic reduction.ndf') 0 ; loaddefs (link Qnial_mine 'matrix - write with parenthesis aligned.ndf') 0 ; loaddefs (link Qnial_mine 'matrix derivatives in [cartesian, cylindrical, spherical] coordinates.ndf') 0 ; ENDIF; # Reminders : # from "matrix - write with parenthesis aligned.ndf" : # wpa IS write_parenthesis_aligned # from "mm-parenthesis aligned.ndf" : # mmwpa IS matrix_multiply_write_parenthesis_aligned # #********************** # Example1 write_expr_result IS OP expr_in { EACH write (link expr_in ' : ') (execute expr_in) '' } exampleRUVs IS { EACH write_expr_result 'RUV_converTable_crt_to_cyl' 'RUV_converTable_cyl_to_crt' 'RUV_converTable_inverse_cyl := mms RUV_converTable_cyl_to_crt RUV_converTable_crt_to_cyl' 'RUV_converTable_crt_to_sph' 'RUV_converTable_sph_to_crt' 'RUV_converTable_inverse_sph := mms RUV_converTable_sph_to_crt RUV_converTable_crt_to_sph' ; % ; EACH write_expr_result 'RUV_cyl := mms RUV_converTable_crt_to_cyl RF_cartesian' 'RUVcrt2 := mms RUV_converTable_cyl_to_crt RUV_cyl' 'RUV_sph := mms RUV_converTable_crt_to_sph RF_cartesian' 'RUVcrt3 := mms RUV_converTable_sph_to_crt RUV_sph' ; } exampleRFs IS { EACH write_expr_result 'Ronv_crt := 3 1 reshape ''x'' ''y'' ''z'' ' 'Ronv_cyl := 3 1 reshape ''r'' ''θ'' ''z'' ' 'Ronv_sph := 3 1 reshape ''ρ'' ''θ'' ''φ'' ' ; % ; EACH write_expr_result 'Ronv_cyl := RF_convert_crt_to_cyl Ronv_crt' 'Ronvcrt2 := RF_convert_cyl_to_crt Ronv_cyl' 'Ronv_sph := RF_convert_crt_to_sph Ronv_crt' 'Ronvcrt3 := RF_convert_sph_to_crt Ronv_sph' ; } #******************************************************* # 29Mar2016 fundamental_derivs is OK - perhaps re-check cylindrical later fundamental_derivs IS { EACH write '' '************************************' 'Cartesian coordinates : ' ' ' ; EACH write_expr_result 'Ronv_crt := 3 1 reshape ''x'' ''y'' ''z'' ' 'Ax Ay Az := Ronv_crt ' 'EACHLEFT wpa (Ronv_crt_deriv := dp_dt_cartesian Ronv_crt) 1' 'EACHLEFT wpa (Ronv_crt_deriv2 := dp2_dt2_cartesian Ronv_crt) 1' ; % ; EACH write '' '************************************' 'Cylindrical coordinates : ' ' ' ; EACH write_expr_result 'Ronv_cyl := 3 1 reshape ''r'' ''θ'' ''z'' ' 'Ar Atheta Az := RF_convert_cyl_to_crt Ronv_cyl ' 'EACHLEFT wpa (Ronv_cyl_deriv := dp_dt_cylindrical Ronv_cyl) 1' 'EACHLEFT wpa (Ronv_cyl_deriv2 := dp2_dt2_cylindrical Ronv_cyl) 1' ; % ; EACH write '' '************************************' 'Spherical coordinates : ' ' ' ; EACH write_expr_result 'Ronv_sph := 3 1 reshape ''ρ'' ''θ'' ''φ'' ' 'Arho Atheta Aphi := RF_convert_sph_to_crt Ronv_sph ' 'EACHLEFT wpa (Ronv_sph_deriv := dp_dt_spherical Ronv_sph) 1' ; } # RESULTS for spherical derivative : EACHLEFT wpa (Ronv_sph_deriv := dp_dt_spherical Ronv_sph) 1 : (+ (* ( dp[dt : ρ*sin(θ)*cos(φ)] - ρ*sin(θ)*sin(φ)*dp[dt : θ] - ρ*cos(θ) *dp[dt : φ]*sin(θ)) ρh ) (* ( dp[dt : ρ*sin(θ)*sin(φ)] + ρ*sin(θ)*cos(φ)*dp[dt : θ] - ρ*cos(θ) *dp[dt : φ]*cos(θ)) θh ) (* ( dp[dt : ρ*cos(θ) ] + ρ*sin(θ)*cos(φ)*dp[dt : φ]*sin(θ) + ρ*sin(θ)*sin(φ)*dp[dt : φ]*cos(θ)) φh ) ) # Compare this to "official expression" from wiki (file "matrix derivatives in [cartesian, cylindrical, spherical] coordinates.ndf") : 5) dp[dt : A] = ρh*{ dp[dt : Aρ] - Aθ*dp[dt : θ] - Aφ*dp[dt : φ]*sinθ } + θh*{ dp[dt : Aθ] + Aρ*dp[dt : θ] - Aφ*dp[dt : φ]*cosθ } + φh*{ dp[dt : Aφ] + Aρ*dp[dt : φ]*sinθ + Aθ*dp[dt : φ]*cosθ } # This is the same as for the wiki-page, where : Ar Atheta Az := RF_convert_cyl_to_crt Ronv_cyl : +---------+ |r*cos(θ) | +---------+ |r*sin(θ) | +---------+ |z | +---------+ #**************************** # Chapter4 - simplified form of dereivatives in spherical coordinates # RFp - PARTICLE reference frame : # string_split_by_string_with_sub S1 S2 S3 splits S3 at each point that S1 occurs, # and puts in S2 in place of S1 # Derivative - zero out terms, remove from derivatives : # The following expressions are for RFp coordinates (particle reference frame) chapter4_spherical_particle IS { EACH write '' '************************************' 'Spherical coordinates, fundamental expresssion for derivative : ' '(this is a reduction of "fundamental_derivs"...) ' ' ' ; Ronv_sph := 3 1 reshape 'ρ' 'θ' 'φ' ; Arho Atheta Aphi := RF_convert_sph_to_crt Ronv_sph ; EACHLEFT wpa (Ronv_sph_deriv := dp_dt_spherical Ronv_sph) 1 ; % ; EACH write '' '************************************' 'Chapter 4 simplification, RFp - PARTICLE reference frame : ' ' ' ; Ronv_sph_deriv := first Ronv_sph_deriv ; %For Chapter 4, noting that [phi,sin(phi),cos(phi)] are constant ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : φ]' '0' Ronv_sph_deriv ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : ρ*sin(θ)*sin(φ)]' 'dp[dt : ρ*sin(θ)]*sin(φ)' Ronv_sph_deriv ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : ρ*sin(θ)*cos(φ)]' 'dp[dt : ρ*sin(θ)]*cos(φ)' Ronv_sph_deriv ; %For Chapter 4, noting that [POIo, POIp] are a constant distance from the line of the particle trajectory ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : ρ*sin(θ)]' '0' Ronv_sph_deriv ; %For Chapter 4, noting that dp[dt : ρ*cos(θ)] is the negative of particle velocity ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : ρ*cos(θ)]' '-Vonv(particle)' Ronv_sph_deriv ; EACH write ' ' 'Ronv_sph_deriv : ' Ronv_sph_deriv ; Ronv_sph_deriv_cleaned := mm_symbolic_reduction Ronv_sph_deriv ; EACH write ' ' 'Ronv_sph_deriv_cleaned : ' Ronv_sph_deriv_cleaned ; Ronv_sph_deriv_cleaned EACHLEFT wpa 1 ; } c4sp IS chapter4_spherical_particle # RESULTS Ronv_sph_deriv_cleaned EACHLEFT wpa 1 = (+ (* ( 0*cos(φ) - ρ*sin(θ)*sin(φ)*dp[dt : θ] - ρ*cos(θ)*0*sin(θ) ) ρh ) (* ( 0*sin(φ) + ρ*sin(θ)*cos(φ)*dp[dt : θ] - ρ*cos(θ)*0*cos(θ) ) θh ) (* ( -Vonv(particle) + ρ*sin(θ)*cos(φ)*0*sin(θ) + ρ*sin(θ)*sin(φ)*0*cos(θ)) φh ) ) Manually removed zeroed terms (modified program doesn't do this for the general case) : Ronv_sph_deriv_reduced = (+ ( - ρ*sin(θ)*sin(φ)*dp[dt : θ] *ρh ) ( + ρ*sin(θ)*cos(φ)*dp[dt : θ] *θh ) ( - Vonv(particle) *φh ) ) By taking φ = constant = 0, sin(φ) = 0, cos(φ) = 1 : Ronv_sph_deriv_final = (+ ( + ρ*sin(θ)*dp[dt : θ] *θh ) ( - Vonv(particle) *φh ) ) # WRONG - ?????????????????? # From : "/home/bill/Projects/Lucas - Universal Force/Howell - Background math for Lucas Universal Force, Chapter 4.odt" # sub-sub-section "dp[dt : Rpcv(POIo,t) ]" : 1) dp[dt : Rpcv(POIo,t)] = -Vonv(particle) # sub-sub-section "dp[dt : Rpcs(POIo,t) ] = dp[dt : |Rpcv(POIo,t)|]" : 1) dp[dt : Rpcs(POIo,t)] = dp[dt : |Rpcv(POIo,t)| ] = -Vons(particle)*cos(Opca(POIo,t)) #**************************** # Chapter4 - simplified form of dereivatives in spherical coordinates # RFp - PARTICLE reference frame : # The following expressions are for RFo coordinates (observer reference frame) # IMPORTANT - The "standard" relations for spherical coordinate derivatives are NOT set up for the RFo basis # that I use in the file "Howell - Background math for Lucas Universal Force, Chapter 4.odt". In order to # apply the standard formulation to the "old POIo" (point of interest), it would be necessary to center (RFo) # on the "old POIo" and focus on the particle itself as the "new POIo". That would be trickey/messy? .... # ???????!!?????? chapter4_spherical_observer IS { EACH write '' '************************************' 'Spherical coordinates, fundamental expression for derivative : ' '(this is a repeat of "fundamental_derivs"...) ' ' ' ; Ronv_sph := 3 1 reshape 'ρ' 'θ' 'φ' ; Arho Atheta Aphi := RF_convert_sph_to_crt Ronv_sph ; EACHLEFT wpa (Ronv_sph_deriv := dp_dt_spherical Ronv_sph) 1 ; % ; EACH write '' '************************************' 'Chapter 4 simplification, RFo - OBSERVER reference frame : ' ' ' ; Ronv_sph_deriv := first Ronv_sph_deriv ; %For Chapter 4, noting that [phi,sin(phi),cos(phi)] are constant ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : φ]' '0' Ronv_sph_deriv ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : ρ*sin(θ)*sin(φ)]' 'dp[dt : ρ*sin(θ)]*sin(φ)' Ronv_sph_deriv ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : ρ*sin(θ)*cos(φ)]' 'dp[dt : ρ*sin(θ)]*cos(φ)' Ronv_sph_deriv ; %For Chapter 4, noting that [POIo, POIp] are a constant distance from the line of the particle trajectory ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : ρ*sin(θ)]' '0' Ronv_sph_deriv ; %For Chapter 4, noting that dp[dt : ρ*cos(θ)] is the negative of particle velocity ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : ρ*cos(θ)]' 'Vonv(particle)' Ronv_sph_deriv ; %For Chapter 4, noting that dp[dt : θ] = 0 in the OBSERVER reference frame (RFo) ; Ronv_sph_deriv := link string_split_by_string_with_sub 'dp[dt : θ]' '0' Ronv_sph_deriv ; EACH write ' ' 'Ronv_sph_deriv : ' Ronv_sph_deriv ; Ronv_sph_deriv_cleaned := mm_symbolic_reduction Ronv_sph_deriv ; EACH write ' ' 'Ronv_sph_deriv_cleaned : ' Ronv_sph_deriv_cleaned ; Ronv_sph_deriv_cleaned EACHLEFT wpa 1 ; } c4so IS chapter4_spherical_observer # RESULTS Ronv_sph_deriv_cleaned EACHLEFT wpa 1 : (+ (* ( 0*cos(φ) - ρ*sin(θ)*sin(φ)*0 - ρ*cos(θ)*0*sin(θ) ) ρh ) (* ( 0*sin(φ) + ρ*sin(θ)*cos(φ)*0 - ρ*cos(θ)*0*cos(θ) ) θh ) (* ( Vonv(particle) + ρ*sin(θ)*cos(φ)*0*sin(θ) + ρ*sin(θ)*sin(φ)*0*cos(θ)) φh ) ) Manually removed zeroed terms (modified program doesn't do this for the general case) : Ronv_sph_deriv_reduced : Vonv(particle)*φh # WRONG - ???????????????? # enddoc