American Citizen on Mon, 14 Oct 2024 18:50:52 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: question on the apply function, when the return values > 1


Loïc:

Your suggested solution works correctly for me.

My naive

 ? concat(apply(x->[130*x,ellordinate(e,130*x)],L))
%9 = [650, [16900, -16900], 1040, [33800, -33800], ...

does not concatenate as I wanted, it took both ordinates as a vector and concatenated that.

Your solution gave me what I needed

[[650, 16900], [650, -16900], [1040, 33800], [1040, -33800], etc...


On 10/14/24 01:59, Loïc Grenié wrote:
On Mon 14 Oct, 2024, at 09:10, Aurel Page wrote:
Dear Randall,

On 14/10/2024 01:44, American Citizen wrote:
> I am using the x-coordinates to an elliptic curve and want to use the
> apply() function to return the points on the curve. I know the curve,
> c and the x-coordinates, L. However when using the ellordinate(E,x)
> function, usually 2 values for y are returned, not one.
>
> ? c=[0,0,0,16900,0]
> %25 = [0, 0, 0, 16900, 0]
>
> ? e=ellinit(c);
>
> ? L=[5, 8, 117, 1/5, 1/8, 1/117, 9/13, 13/9, 49/128, 65/72, 72/65,
> 128/49, 968/14625, 1568/5329, 1805/3481, 2080/3969, 3481/1805,
> 3969/2080, 5329/1568, 14625/968]
> %27 = [5, 8, 117, 1/5, 1/8, 1/117, 9/13, 13/9, 49/128, 65/72, 72/65,
> 128/49, 968/14625, 1568/5329, 1805/3481, 2080/3969, 3481/1805,
> 3969/2080, 5329/1568, 14625/968]
>
> ?
> apply(x->[[130*x,ellordinate(e,130*x)[1]],[130*x,ellordinate(e,130*x)[2]]],L)
> %28 = [[[650, 16900], [650, -16900]], [[1040, 33800], [1040, -33800]],
> [[15210, 1875900], [15210, -1875900]], [[26, 676], [26, -676]],
> [[65/4, 4225/8], [65/4, -4225/8]], [[10/9, 3700/27], [10/9,
> -3700/27]], [[90, 1500], [90, -1500]], [[1690/9, 84500/27], [1690/9,
> -84500/27]], [[3185/64, 502775/512], [3185/64, -502775/512]],
> [[4225/36, 409825/216], [4225/36, -409825/216]], [[144, 2328], [144,
> -2328]], [[16640/49, 2298400/343], [16640/49, -2298400/343]],
> [[1936/225, 1289816/3375], [1936/225, -1289816/3375]], [[203840/5329,
> 326034800/389017], [203840/5329, -326034800/389017]], [[234650/3481,
> 246925900/205379], [234650/3481, -246925900/205379]], [[270400/3969,
> 302915600/250047], [270400/3969, -302915600/250047]], [[90506/361,
> 30670796/6859], [90506/361, -30670796/6859]], [[3969/16, 282303/64],
> [3969/16, -282303/64]], [[346385/784, 212504825/21952], [346385/784,
> -212504825/21952]], [[950625/484, 928887375/10648], [950625/484,
> -928887375/10648]]]
>
> What I would like to see is this
>
> %28 = [[650, 16900], [650, -16900], [1040, 33800], [1040, -33800],
> [15210, 1875900], [15210, -1875900], [26, 676], [26, -676], [65/4,
> 4225/8], [65/4, -4225/8], [10/9, 3700/27], [10/9, -3700/27], [90,
> 1500], [90, -1500], [1690/9, 84500/27], [1690/9, -84500/27], [3185/64,
> 502775/512], [3185/64, -502775/512], [4225/36, 409825/216], [4225/36,
> -409825/216], [144, 2328], [144, -2328], [16640/49, 2298400/343],
> [16640/49, -2298400/343], [1936/225, 1289816/3375], [1936/225,
> -1289816/3375], [203840/5329, 326034800/389017], [203840/5329,
> -326034800/389017], [234650/3481, 246925900/205379], [234650/3481,
> -246925900/205379], [270400/3969, 302915600/250047], [270400/3969,
> -302915600/250047], [90506/361, 30670796/6859], [90506/361,
> -30670796/6859], [3969/16, 282303/64], [3969/16, -282303/64],
> [346385/784, 212504825/21952], [346385/784, -212504825/21952],
> [950625/484, 928887375/10648], [950625/484, -928887375/10648]]
>
> Is this possible when using apply() ?
You can simply call concat on the output.

     Depending on the list L, ellordinate might output a result with less than two
  coordinates. To be on the safe side, I would also suggest to change the
  function that is applied to L:

{
concat(
    apply(x->
        apply(y->
            [130*x,y],
            ellordinate(e, 130*x)
        ),
        L
    )
)
}

   (You can also use 130*L and change both the 130*x in x).

       Hope this helps,

            Loïc