Giter Site home page Giter Site logo

stla / pyweierstrass Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 61 KB

Weierstrass elliptic functions

Home Page: https://pyweierstrass.readthedocs.io/en/latest/

License: GNU General Public License v3.0

Python 100.00%
elliptic-functions python weierstrass

pyweierstrass's Introduction

pyweierstrass

Documentation Status

Some Weierstrass functions: p-function, sigma function, zeta function, and inverse p-function.

pip install pyweierstrass

pyweierstrass's People

Contributors

stla avatar

Watchers

 avatar  avatar  avatar

pyweierstrass's Issues

Incorrect half-periods formula leading to wrong sign for g3 when calculated from half-periods

  • The series for g2 in terms of G4 is quartic in omega1. When solving for omega1 in terms of g2 the result is thus only determined up to a quartic root of unity.
  • Because the result for omega1 can thus sometimes be incorrectly multiplied by +1, -1, +i, or -i, we can observe errors when trying to recalculate g2 and g3 from omega and the mistake manifests as giving the wrong sign for g3.
  • One solution is to include the series for g3 in terms of G6 to decide whether to multiply the periods by the imaginary unit or not, then the periods are defined up to a sign +/-1. In other words, the ratio g2/g3 is quadratic in the half-periods not quartic.
  • As the half periods are only defined up to a sign because of periodicity anyway this suffices and elliminates the problem of obtaining the wrong sign for g3 when calculating from omega.
  • By G4 and G6 we mean G4(1, tau), G6(1, tau) with G_2k(tau) = 2 * zeta(2*k) * E_2k(tau), with zeta the Riemann zeta function and E the Eisenstein series expressible in terms of theta functions
  • A single example of how the original method for calculating the half-periods can fail is given below as g3 takes the wrong sign:
# Input values of g2 and g3 are chosen
g2_num =  mpc(real='-73.4914329314137', imag='95.8413827483826')
g3_num =  mpc(real='54.2026055822565', imag='27.1486316597472')

# The values for g2 and g3 are then calculated from omega1 and omega2
# and the values for omega1 and omeg2 are themselves calculated from the original g2 g3
# This should return the original values but it returns -g3 instead
g_from_omega(*omega_from_g(g2_num, g3_num))

Output:
(mpc(real='-73.491432931413684', imag='95.841382748382628'),
 mpc(real='-54.202605582253817', imag='-27.14863165974365'))

So instead of doing this:
$\displaystyle g_{2} = \frac{15 G_{4}}{4 \omega_{1}^{4}}$
$\displaystyle \omega_{1} = \sqrt[4]{\frac{15G_{4}}{4g_{2}}}$

perhaps the following would work better:
$\displaystyle g_{2} = \frac{15 G_{4}}{4 \omega_{1}^{4}}$
$\displaystyle g_{3} = \frac{35 G_{6}}{16 \omega_{1}^{6}}$
$\displaystyle \frac{g_{2}}{g_{3}} = \frac{12 G_{4} \omega_{1}^{2}}{7 G_{6}}$
$\displaystyle \omega_{1} = \sqrt{\frac{7G_{6} g_{2}}{12G_{4} g_{3}}}$

I have been exploring this here: https://github.com/HeskethGD/Elliptic-Functions/tree/master/numerical_evaluation
There are some numerical tests and a suggested modification that implements the above.
Thanks again for your efforts on this.

ZeroDivisionError when g2 is 0

Hi !

When running _half_periods(0, 1) I get the following:

/path/pyweierstrass/pyweierstrass/weierstrass.py, line 80, in _half_periods
    j = 1728 / (1 - 27*g3*g3/g2cube)
ZeroDivisionError: division by zero

It seems that your implementation doesn't support curve with a zero j-invariant because of this. It is weird because when I try to add a check with simple if branch in case g2 is zero to set j = 0 it also complain about a zero division I don't get it honestly :')

I also found your other gists (this one) and it seems to work with g2 = 0 however it seems the half periods are not right (when g3 is not set to 1 the functions have period 1.53 which should not be the case...) .

Thanks for your work !

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.