Code Monkey home page Code Monkey logo

fermat's People

Contributors

jordanrl avatar peter279k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fermat's Issues

Create Polar Coordinate Object and Generalize Coordinate Handling

There is currently a CartesianCoordinate class, however it is fairly unintegrated with other parts of the library. Additionally, a PolarCoordinate class in needed to complete #14 as it is the easiest way to implement things such as pow().

This will involve formalizing the CoordinateInterface, making an abstract Coordinate class, creating the new PolarCoordinate class, and correctly utilizing the existing classes to allow for smooth transition between other classes in the library and coordinates.

Increase trig operations to more "arbitrary" precision

Related to #15 it would be nice to somehow uncap the precision of the trig operations. In order for this to happen there needs to be a way of getting several constants, namely e and pi, to "arbitrary" precision. I'm currently exploring the best way to implement this.

I think precision to 100 digits hits the vast majority of cases, so it might be okay to keep the constants for most cases and call a generator of some kind in the special cases where greater precision is required.

Complex Numbers Migration

Requires Algebra Expressions to be at v1.0 (due to the polynomial foil function being utilized in the multiply() implementation)

  • Fix and test divide()
  • Fix and test pow()
  • Fix and test sqrt()

Algebra Expressions Migration

  • Test coverage of at least 80%
  • Implementation of Exponential and Logarithmic Expressions
  • Implementation of add(), subtract(), and multiply()

Complex/imaginary numbers?

I thought that maybe it'd be nice if complex numbers are supported including their operations.

I've created this issue mainly because I wanted to check if it's actually something @JordanRL wants in this project. If so, I think I can get started on a PR.

Integration with spatie/ignition

The exceptions in Fermat already provide/contain the information needed for spatie/ignition. Providing integration with the solution aspect of spatie/ignition should be fairly simple.

Provide Base Documentation for all Features in v2.0

There are some areas of the documentation that still do not exist, even though the associated code is tested and considered stable. This documentation needs to be created and deployed so that it is available for developers to reference.

Classes `ImmutableVector` and `MutableVector` have invalid signatures

Currently, both ImmutableVector and MutableVector implement the VectorInterface, but don't implement any of its methods nor are declared abstract. Either remove the classes altogether, mark them as abstract, create the methods from VectorInterface or remove implements VectorInterface from the signatures.

Better Export/Import & String Conversion Options

Allow options for printing and exporting in more formats:

  • Grouping
    • Control of grouping: 100,000,000 vs 100000000
      • Export/Print
      • Import
    • Control of grouping size: 100,000,000 vs 1,0000,0000
      • Export/Print
      • Import
    • Control of grouping delimiter: 100,000,000 vs 100.000.000
      • Export/Print
      • Import
  • Radix
    • Control of radix character: 3.14159 vs 3,14159
      • Export/Print
      • Import

Provide DocBlocks For All Items (Roster Integration)

Providing the DocBlock comments for all items allows the documentation generated by Roster to be more complete and helpful, particularly where the descriptions or examples are given.

  • Add DocBlock for all items
  • Add descriptions where appropriate
  • Add examples where appropriate

Add number collections for group number manipulation

Add a type for number collections that allows for working on groups of numbers together. Operations:

  • Add
  • Subtract
  • Multiply
  • Divide
  • Power
  • Exponentiate
  • Normal Distribution From Collection
  • Poisson Distribution From Collection
  • Exponential Distribution From Collection

Increase precision of arithmetic operations to 2^32-1 digits

Arithmetic operations are really only limited by the BCMath library in precision, so with the proper redesign a few method signatures, this could easily be increased to the 2^32-1 digits that BCMath supports.

The main reason I shied away from doing this for the initial release is that the trig functions can really only be accurate to the number of decimal places that the constants are available at. However, it is probably more of an edge case to need trig functions to > 100 digits than it is to need arithmetic operations to > 100 digits.

Ensure All Change Risk Anti-Pattern Scores Below 20

The Scrutinizer report for the current codebase has several methods with a high CRAP score. These methods need to be refactored to be simplified, or they need to be more well tested.

  • IntegerMathTrait::isPrime()
  • RoundingProvider::round()
  • RandomProvider::randomInt()

Add calculus provider

Create a calculus provider that can, at the very least, compute the integral over a range (both definite and indefinite) given that the integrand is provided.

Increase Performance on Trig Functions

Currently the inverse trig functions average around 50 operations per second, and the normal trig functions around 600-700. Current performance: (NOTE: the numerical values depend on the system and are only relevant in comparison to future numbers generated on my development box.)

Function Ops/Sec Equivalent md5() Hashes
sin() 657 12590
cos() 745 11079
tan() 208 39622
sec() 703 11744
csc() 618 13353
cot() 160 51400
----- --- ----
arcsin() 45.3 182144
arccos() 42.6 193546
arctan() 36.5 226051
arcsec() 54.2 152068
arccsc() 58.6 140874
arccot() 33.8 244096

Current bottlenecks are primarily:

  • Dependence on Bernoulli Number generation (extremely slow to calculate, need implementation based on D. Harvey et. al. binary algorithm)
  • Dependence on compound and iterative calls to other expensive functions (such as natural log)
  • Lack of shortcuts for easier to calculate values (i.e., values within the bounds and scale of the native functions)
  • Implemented mainly as Maclauren/Taylor series (slower converging)

Extend the 'Native' Calculation Mode to Bypass All Functions

The native calculation mode has been available since v1.1.0, however it only controls the behavior of arithmetical operations. None of the trigonometry or exponential methods take advantage of this setting currently, and these are some of the heaviest functions within the entire library.

Though their would eventually see benefit from the mode setting, once the operation had been reduced to a series of multiply, divide, add, and subtract operations, this is fundamentally unnecessary if the program has indicated it is alright with accepting the limitations of int and floats in PHP. The purpose of this setting is to allow a program to use this library as a common fluent interface for math itself, instead of arbitrary precision.

  • Make basic trig functions mode aware
  • Make inverse trig functions mode aware
  • Make hyperbolic trig functions mode aware
  • Make exponentials and logs mode aware
  • Make pow and sqrt mode aware

Automate Workflow For Changelog Tracking

Currently there is stuff that slips through, and the processes that I have in place are not very organized. This results in changes being made without corresponding tickets, or extremely lazy PR's that don't probably explain or track what is being merged and why.

By adopting some workflows that actually formalize all of this, it makes it easier for the changelog to be accurate, it encourages me to properly ticket and document what is being updated, and most importantly it makes it easier for others to contribute changes if anyone ever wishes to do so.

Add subfactorial() method to Decimals

Is your feature request related to a problem? Please describe.
In combinatorics, derangements for a set of a given size can be given using the subfactorial method. This method appears in other places, including some probability distributions.

Describe the solution you'd like
The implementation is fairly straightforward:

function subfactorial($n) {
  return floor( factorial($n)/$e + 0.5 ); // For $n > 0
}

Describe alternatives you've considered
This function is fairly simple, and so could easily be implemented by consumers of the library, but it seems an easy candidate for an implementation

Remove Dependency on Base Conversion Library

The current base conversion library is a bit overkill for what this library needs, and it also presents some problems when it comes to keeping the library up to date with current versions of PHP.

To solve this, add a small BaseConversionProvider.

  • Add BaseConversionProvider
  • Update base conversion to happen JIT when output is requested
  • Update getValue() calls inside calculations to explicitly call NumberBase::Ten to avoid calculation errors when an object's base is not 10.

Allow a mode that uses only native math functions and operators

Despite the fact that Fermat was originally conceived of as an arbitrary precision expansion to the bcmath library (originally only because there was no way to do logs or trigonometry in bcmath), the PHP landscape has changed.

The ext-stats extension no longer exists for any supported versions of PHP, meaning that there aren't any decently complete stats options in PHP. Additionally, some of the other features such as a fraction type, matrix math, complex & imaginary numbers, and base conversion are not at all dependent on precision.

Thus, there is a real use for Fermat as nothing but a more complete math library that only worries about precision to the extent that other functions in PHP do.

In these cases, where the developer using the library wants the features of Fermat without the precision, a native implementation that is unconcerned with losing precision during arithmetic would likely be at least an order of magnitude faster.

To support this use case, there should be an option or supported development pattern that uses only native PHP functions to perform all math operations.

Add control of rounding modes

Similar to the calculation modes, it might be useful to create a run-time configuration for rounding modes to affect the behavior of the round() and roundToScale() methods.

Possible Rounding Modes Include:

  • Implementation
    • Deterministic Modes
      • Ceil
      • Floor
      • Half Up
      • Half Down
      • Half Even
      • Half Odd
      • Half To Zero
      • Half To Infinity
    • Non-Deterministic Modes
      • Random Tie-Break
      • Alternating Tie-Break
      • Stochastic (this is particularly useful for Machine Learning applications)
  • Unit Tests
  • Integration
  • Regression
  • Documentation

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.