Ask Your Question

Vibap's profile - activity

2024-02-26 00:03:02 +0200 received badge  Popular Question (source)
2023-01-30 20:29:12 +0200 marked best answer Generating the non-fundamental solutions of Pell's equation

Hi. The topic of Pell's equation seems to be quite minor among coding sites so I've come to ask for help from professionals at here SageMath community.

https://mathsci.kaist.ac.kr/cms/wp-co...

def solve_pell (N , numTry = 100):
    cf = continued_fraction ( sqrt ( N ))
    for i in range ( numTry ):
        denom = cf.denominator ( i )
        numer = cf.numerator ( i )
        if numer ^2 - N * denom ^2 == 1:
            return numer , denom
    return None , None


solve_pell (21)

The code attached in the last page of the link above works really fine. It finds the fundamental solutions of Pell's equation and I've never seen any other shorter code than the code in the link.

I usually prefer to use the library codes than my self-made codes for the sake of efficiency. However if there aren't any relevant sources, I would have no other choices but make some new codes.

So my questions,

1. Are there any library functions, the libraries that are supported by Sage, regarding finding the non-fundamental solutions of Pell's equation?

2. If not, could you suggest some idea for the code which do the task we desire?

I've tried to make my own code by referring to the algorithm in a document from Wikipedia

however it seems to be using symbolic computations heavily of which I've never tried before. I would be glad for any kind of advice via commens and answers. Thanks.

2023-01-30 13:36:56 +0200 edited question Generating the non-fundamental solutions of Pell's equation

Generating the non-fundamental solutions of Pell's equation Hi. The topic of Pell's equation seems to be quite minor amo

2023-01-30 13:35:11 +0200 edited question Generating the non-fundamental solutions of Pell's equation

Generating the non-fundamental solutions of Pell's equation Hi. The topic of Pell's equation seems to be quite minor amo

2023-01-30 12:26:29 +0200 asked a question Generating the non-fundamental solutions of Pell's equation

Generating the non-fundamental solutions of Pell's equation Hi. The topic of Pell's equation seems to be quite minor amo

2022-09-07 07:46:14 +0200 received badge  Commentator
2022-09-07 07:46:14 +0200 commented answer The performance speed of "len(str(n))" method and "a^b % p" method in Sage

@JohnPalmieri: So thank you for referring me to the source code!!

2022-09-06 18:10:27 +0200 commented answer The performance speed of "len(str(n))" method and "a^b % p" method in Sage

@JohnPalmieri: modular function in my codes are slow but it gives an output anyway. However countlength function doesn't

2022-09-06 18:01:54 +0200 commented answer The performance speed of "len(str(n))" method and "a^b % p" method in Sage

Oh, that seems plausible! I will do experiment myself with your R = Integers(2**127 - 1); R(3)**10000000 method above.

2022-09-06 16:00:53 +0200 commented answer The performance speed of "len(str(n))" method and "a^b % p" method in Sage

Your source code link is really helpful. Could you help me where I can find a similar source code page with len(str(n))

2022-09-06 15:36:57 +0200 commented answer The performance speed of "len(str(n))" method and "a^b % p" method in Sage

Your source code link is really helpful. Could you help me where I can find a similar source code page like you've refer

2022-09-06 14:43:03 +0200 marked best answer The performance speed of "len(str(n))" method and "a^b % p" method in Sage

Hi.

Using the same Jupyter Notebook, I've found that identical codes between SageMath and Python turns out that the running time of SageMath shows up much faster than the same code written in Python.

Those codes are as follows.

import timeit

def modular():
    return 3**10000000 % (2**127-1)

def countlength():
    return len(str(3**10000000))



print(timeit.timeit(modular, number=1))
print(timeit.timeit(countlength, number=1))

In SageMath, the running time is less than 1 second for both functions. On the other hand, the running time for "modular' is 5 times slower in Python and for the "countlengh" function, there isn't even an answer from Python.

It makes me curious, what's the magic behind the speed of SageMath?

Recently I'm working on algorithm and coding optimization so any advice from a senior would be grateful.

Thanks.

2022-09-06 11:15:36 +0200 commented question The performance speed of "len(str(n))" method and "a^b % p" method in Sage

@MaxAlekseyev: I've tried by myself and indeed. Thank you for so useful tip.

2022-09-05 19:38:04 +0200 asked a question The performance speed of "len(str(n))" method and "a^b % p" method in Sage

The performance speed of "len(str(n))" method and "a^b % p" method in Sage Hi. Using the same Jupyter Notebook, I've f

2022-07-28 18:37:03 +0200 marked best answer How can I see the detail of embedded codes?

Hi. I want to learn how to make some efficient codes manually by referring to verified codes with quality like the ones embedded in Sage.

Is there any way that I can see the detail of the embedded codes like 'next_prime()', 'prime_pi(), 'prime_range()?

Thanks.

2022-07-28 18:36:57 +0200 marked best answer The performance speed of SageMath Cell

Hi. I'm thinking of embedding SageMath Cell into some personal webpage.

Does the calculation speed of SageMath Cell heavily depends on the performance or specs of personal computer?

If so, is there any way that I can improve the calculation speed of SageMath Cell server?

Thanks.

2022-07-28 08:38:16 +0200 marked best answer Comparing pari.numbpart() and sympy.partition()

Hi. I understand this question is not contained to SageMath, but I determined to post a question on this forum because I felt this place was the closest to where the experts do exist, regarding math algorithm questions.

If I test and compare the running time of pari.numbpart() and sympy.partition() as the following,

import timeit
import sympy 


def sy(n=10^4):
  sympy.partition(n)

def par(n=10^4):
   pari.numbpart(n)

print('Sympy   \t\t', timeit.timeit(sy, number=1))    
print('PARI    \t\t', timeit.timeit(par, number=1))

I usually see the result as pari.numbpart function running faster. However, I'm not sure whether pari.numbpart is generally faster than sympy.partition.

My question is, what functional approach do pari.numpart and sympy.partition adopt respectively?

There are not many options as long as I know, such as Hardy–Ramanujan–Rademacher and brute force over Young's diagram. If there is someone, I hope ze could let me know what algorithmic approach does each function has taken, and which function is generally faster than the other. Moreover, if possible, I would like to know the complexity time (Big O) of each function.

Thanks.

2022-07-28 08:38:16 +0200 received badge  Scholar (source)
2022-07-28 03:39:43 +0200 commented answer Comparing pari.numbpart() and sympy.partition()

Thanks. I'm newbie so I didn't know from where I could refer to the documentations! Btw, It seems that Hardy-Ramanujan-

2022-07-27 20:02:38 +0200 asked a question Comparing pari.numbpart() and sympy.partition()

Comparing pari.numbpart() and sympy.partition() Hi. I understand this question is not contained to SageMath, but I deter

2022-05-05 18:39:02 +0200 commented answer Continuing the calculation at Jupyter Notebook on another day

I will definitely check until what extent it works. Super thanks!!!

2022-05-02 15:35:31 +0200 commented answer Continuing the calculation at Jupyter Notebook on another day

I'm thinking of installing Linux soon. Thank you for introducing the method!!!

2022-05-02 15:31:40 +0200 received badge  Supporter (source)
2022-05-02 12:42:41 +0200 received badge  Student (source)
2022-05-02 12:03:38 +0200 edited question Continuing the calculation at Jupyter Notebook on another day

Continuing the calculation at Jupyter Notebook on another day I'm running a function at Jupyter Notebook which might cos

2022-05-02 12:01:42 +0200 received badge  Editor (source)
2022-05-02 12:01:42 +0200 edited question Continuing the calculation at Jupyter Notebook on another day

Continuing the calculation at Jupyter Notebook on another day I'm running a function at Jupyter Notebook which might cos

2022-05-02 11:59:17 +0200 commented answer How can I see the detail of embedded codes?

wow, so easy! This is why SageMath is the best!

2022-05-02 11:58:45 +0200 commented answer The performance speed of SageMath Cell

Super Thanks!

2022-05-02 11:51:29 +0200 asked a question Continuing the calculation at Jupyter Notebook on another day

Continuing the calculation at Jupyter Notebook in the other day I'm running a function at Jupyter Notebook which might c

2022-05-02 11:51:29 +0200 asked a question The performance speed of SageMath Cell

The performance speed of SageMath Cell Hi. I'm thinking of embedding SageMath Cell into some personal webpage. Does th

2022-05-02 11:51:29 +0200 asked a question How can I see the detail of embedded codes?

How can I see the detail of embedded codes? Hi. I want to learn how to make some efficient codes manually by referring t