Giter Club home page Giter Club logo

math's People

Contributors

paulmasson 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

math's Issues

zeta for imaginary numbers > 80

Hi Paul, the zeta function returns NaN for complex numbers with Im>80. It seems that the factorial product overflows. Would this algorithm be suitable for Imaginary numbers > 80? This complex implementation of the zeta function has been my favorite and I would prefer to resolve this issue for plotting output values for imaginary inputs up to 1000. Thanks!

Implement surd(x,n)

Can you please implement surd(x,n) for x real number and n integer number

implement piecewise(...) function

It would be nice to have a piecewise() function.

piecewise() is often used in cumulative distribution functions and probability density functions.

Define betaRegularized

Can you add a betaRegularized function?
The beta()and gamma() functions already exists in math project.

function betaRegularized(z, a, b) {
  return (beta(z, a, b)*gamma(a + b))/(gamma(a)*gamma(b));
}

function betaRegularized(z0, z1, a, b) {
  return ((-beta(z0, a, b) + beta(z1, a, b))*gamma(a + b))/(gamma(a)*gamma(b));
}

Implement numerical Binomial/Multinomial functions

Does it make sense to implement a multinomial function derived from the gamma function:

$$Multinomial(x_1, x_2, x_3,...) := \frac{\Gamma(\sum_i x_i + 1)}{\prod_i \Gamma(x_i+1)} $$

Or is there a faster approach using existing functions?

weierstrassHalfPeriods(1.0,complex(0,2))

console.log(weierstrassHalfPeriods(1.0,complex(0,2)));

should return [1.30139... - 0.29912...*I, -0.29912... + 1.30139...*I} instead of

0: Object { re: 1.3013924813453168, im: -0.29912656788829045 }
1: Object { re: 2.3036583948098155, im: 0.7031393455731271 }

โ€‹

NUM09-J. Do not use floating-point variables as loop counters

My Java tool warns me about NUM09-J. Do not use floating-point variables as loop counters

One corresponding example in math.js is:

Should the floating-point iterations integer loop counter i not exceed a "configurated iteration limit" to be sure to stop the loop, for example if tolerance is choosen "too small"?

hypergeometric2F1 function: X-values close to -1 cause an eternal while-loop

Hi!
x-values close to -1, eg -0.9999999999999976 results in an eternal while-loop, See https://github.com/paulmasson/math/blob/master/src/functions/hypergeometric.js#L384

E.g:
const y = hypergeometric2F1(1, 0.5, 1.5, -1.0000000000000024);
which calls hypergeometric2F1(1, 0.5, 1.5, -0.9999999999999976);

Can be solved by a tolerance check on line 372?: if ( Math.abs(x+1)< tolerance ). Or a max number of iterations check?
https://github.com/paulmasson/math/blob/master/src/functions/hypergeometric.js#L372

Unit tests?

Do you have any unit tests available for the implemented functions?

sinIntegral(0)

console.log( sinIntegral(0.0)); doesn't evaluate to 0

coshIntegral script slows down browser

The coshIntegral script slows down the browser.
Is there some wrong call to coshIntegral?

<html>
<head>
<meta charset="utf-8">
<title>JSXGraph</title>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/distrib/jsxgraph.css"/>
<script src="https://cdn.jsdelivr.net/gh/paulmasson/[email protected]/build/math.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/distrib/jsxgraphcore.js"></script>

</head>
<body>
<div id="jxgbox" class="jxgbox"></div>
<script>
var board = JXG.JSXGraph.initBoard('jxgbox', {axis:true,boundingbox:[-2.75,6.05,2.75,-6.05]});
board.suspendUpdate();
var a = board.create('slider',[[-2.2,4.84],[2.2,4.84],[1,1,10]],{name:'a'});

function $f1(x) { try { return [re(coshIntegral(mul(a.Value(),x)))];} catch(e) { return Number.NaN;} }
function $f2(x) { try { return [im(coshIntegral(mul(a.Value(),x)))];} catch(e) { return Number.NaN;} }
board.create('functiongraph',[$f1, -2.0, 2.0],{strokecolor:'#5e81b5'});
board.create('functiongraph',[$f2, -2.0, 2.0],{strokecolor:'#e19c24'});


board.unsuspendUpdate();

</script>
</body>
</html>

Improve `harmonic`

Sorry I somehow missed #18.

Can the formula:
HarmonicNumber(n) == EulerGamma + PolyGamma(0, 1 + n)

be used in harmonic for non-integer arguments?

if ( !Number.isInteger(n) ) throw Error( 'Noninteger index for harmonic number' );

Also for 2 arguments:
HarmonicNumber(n, r) == -HurwitzZeta(r, 1 + n) + Zeta(r)

Rename exponential integral functions

Renaming expIntegral to expIntegralEi and expIntegralEn to expIntegralE would be clearer as to which function is which. This is in line with both Mathematica and SageMath.

Thanks to @axkr for pointing this out!

besselYZero(0.0, 1.0)

console.log(besselYZero(0.0, 1.0)) returns 2.3582698006047504

but should return 0.893577

WeierstrassP derivative and half periods

Now that the library has weierstrassP, it would be nice to have methods that return the derivative and half periods (like Mathematica's WeierstrassPPrime, WeierstrassHalfPeriodW1 , etc).

struveH(0,50.0)

Input

console.log(struveH(0,50.0))

returns

-1012.3484633626421

and should be

-0.085337674826119

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.