Giter VIP home page Giter VIP logo

pws_chakravala's Introduction

PWS_chakravala

Generates the fundamental solution to Pell's equation and creates a class and several functions for performing calculations in $Z[\sqrt{d}]$ or $Z/nZ[\sqrt{d}]$.

The fundamental solution

Calculates the fundamental solution using the chakravala method. Example usage:

>>> smallest_solution_Pell(34)
[35,6]
>>> 35**2 - 34*6**2
1

Plot the solutions

enables you to easily make a scatter plot of the solutions, using the MatPlotLib module. Type

>>>plot(100) 

to plot the smallest solutions of the first 100 values of d. Optional arguments are: Xscale (integer, default 1000) that determains the size of the plot, and logaritmic (boolean, default False) that determains whether the axes are logarithmic or not.

$Z[\sqrt{d}]$

Given a,b,d and f, represents the number $a+b\sqrt{d}$ with coefficients a,b in $Z/fZ$ (a,b in Z if f isn't given). Can multiply and add two numbers with the same d and f. Prints a given number. Calculates the order of a solution mod f: the smallest power such that f divides the b-value.

Example usage:

>>> alpha = ZfZsqrtd(35,6,34,17)
>>> print(alpha)
1+6sqrt{34} (mod 17)
>>> print(alpha*alpha)
1+12sqrt{34} (mod 17)
>>> print(orde(alpha,17))
17

License

PWS_chakravala is released under the MIT License.
Copyright (c) 2015 Pim Spelier

pws_chakravala's People

Contributors

pimsp avatar antonvanes avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.