Jacobi elliptic function - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Jacobi elliptic function (/thread-9424.html) |
Jacobi elliptic function - salvomic - 11-02-2017 05:26 PM hi, here is a first version of a program to return Jacobi elliptic function and its parameters (see here for theory). This function is related to the Elliptic Integrals: see my version here in the Library. INPUT: Jacobi_fn(φ, m) where φ is the amplitude (φ=ASIN(x), where x is upper bound of Elliptic integral 1st kind expressed in other canonical form; the complete form has 0<=x<=1 or 0<=φ<=π/2); m=k^2 is the square of the eccentricity (0<=k<=1). RETURN a matrix where the first row present u (elliptic integral 1st kind in the sine integral –with φ– form), φ, m and the second row sn (amplitude sine), cn (amplitude cosine) and dn (delta amplitude) The Code: Code:
For now there is no control for over boundary values. Enjoy! Salvo Micciché RE: Jacobi elliptic function - salvomic - 10-17-2020 08:14 PM With G2 Software version 2.1.14433 (2020 01 21) both in CAS and Home, if ‹number format› in Home settings is set "Standard" and Angular mode is set to "RAD" I'm trying this input for my program: Code: jacobi_fn(asin(1),0.4^2) Code: jacobi_fn(ASIN(1),0.4^2) See the above attachment. If I set other format, like "Float 9" or another angular mode ("DEG" or GRAD), also with "Standard" setting the matrix shows ok. Is it a bug or a problem here? Am I missing something? Thanks for help. Salvo EDIT 1: if I input acos(1) instead of asin(1) the output is ok (but also that function become ACOS(1) in the display) and also with "Standard" format, however not if I put a number or e.g. π/2. EDIT 2: the view is ok if I traspose the generated matrix but not if I put manually in the input line the same matrix (not transposed) EDIT 3: in iOS I get two different output: in Home the "⌷" become an ellipsis sign (...); in CAS I get an error "Error in input": why? RE: Jacobi elliptic function - pinkman - 10-18-2020 07:51 AM In Home view and standard number format the result has to be shown (select it and press the soft key “Show”). Remember (or discover) that CAS and Home don’t share the same memory space, and that CAS solves calculations symbolically. Thus in CAS mode, it receives the variable names and doesn’t know how to interpret them. To create such programs for CAS, you should create a CAS program. But remember it will try to solve it symbolically, which is sometimes impossible with integrals. I also suggest you use the integral sign instead of the int function which is part of the CAS. To be synthetic: your program is designed to calculate numerical values, don’t use it with CAS. RE: Jacobi elliptic function - Albert Chan - 10-18-2020 03:27 PM (10-17-2020 08:14 PM)salvomic Wrote: EDIT 1: if I input acos(1) instead of asin(1) the output is ok (but also that function become ACOS(1) in the display) and also with "Standard" format, however not if I put a number or e.g. π/2. This suggest something is wrong with simplifying acos. I would try acos(0) though, since acos(0) = asin(1) = π/2 RE: Jacobi elliptic function - salvomic - 10-18-2020 03:35 PM hi @pinkman, you are right for the hints about the making of a CAS program and the use of the integral sign ∫ and so on, but I think also that the problem with the matrix output is the "ellipsis" (...) due to too long numbers in the second column, the fact is also this abbreviation is showed with a wrong symbol (⌷ instead of ...) both in CAS and in Home. I would like to know how to avoid it with "Standard" setting and if I try to change Standard" with other settings (like Float, SCI or ENG...) or simply put an instruction first to show the matrix to set some setting and then change it again, but how to do after a RETURN instruction? Thanks, Salvo RE: Jacobi elliptic function - salvomic - 10-18-2020 03:37 PM (10-18-2020 03:27 PM)Albert Chan Wrote: This suggest something is wrong with simplifying acos. also with ACOS(0) I get the same output. RE: Jacobi elliptic function - pinkman - 10-18-2020 04:18 PM (10-18-2020 03:35 PM)salvomic Wrote: hi @pinkman, Maybe a good solution is to use EDITMAT: Code:
No return statement is needed, as any program will automatically return the last calculation result. Also watch the Help entry for EDITMAT, you can set it to be read-only. RE: Jacobi elliptic function - salvomic - 10-18-2020 04:32 PM (10-18-2020 04:18 PM)pinkman Wrote: Maybe a good solution is to use EDITMAT: thanks, I'll try so. Salvo EDIT: however, maybe it is simpler to use ROUND(..., 6) to show the matrix with acceptable approximation... |