NASA Core Flight System (CFS) Command and Data Dictionary (CCDD) utility uses mXparser! Dear NASA - thank you for your t(h)rust 🙂
Best regards,
Mariusz Gromada
NASA Core Flight System (CFS) Command and Data Dictionary (CCDD) utility uses mXparser! Dear NASA - thank you for your t(h)rust 🙂
Best regards,
Mariusz Gromada
Thank you!
Mariusz Gromada
mXparser code:
Function s = new Function("s(n, x) = if( x >= 1, n, s(n+1, x + rUni(0,1) ) )"); Expression e = new Expression("avg( i, 1, 10000, s(0,0) )", s);
Result:
[mXparser-v.4.1.1] 2.7194
Best regards,
Mariusz Gromada
Best regards,
Mariusz Gromada
MathParser.org-mXparser is now available for various .NET frameworks
Enjoy 🙂
Best regards,
Mariusz Gromada
Using built-in random variable [Uni] from uniform continuous distribution over [0; 1] interval we sample two numbers (x,y) then check if point is inside the circle. Operation is repeated n-times, then proportion falling into circle is being measured. This is only 1/4 of the circle (positive x and positive y) with radius 1, so 4 times proportion should give estimation of pi.
Argument n = new Argument("n = 100000"); Expression e = new Expression("4 * sum(i, 1, n, if( [Uni]^2 + [Uni]^2 <= 1; 1; 0) ) / n", n); mXparser.consolePrintln("Res. : " + e.getExpressionString() + " = " + e.calculate());
[mXparser-v.3.0.0] Res. : 4 * sum(i, 1, n, if( [Uni]^2 + [Uni]^2 <= 1; 1; 0) ) / n = 3.14748
Best regards
If a rel b then applied epsilon is maximum from epsilon and ulp(b) : i.e. a eq b if a \in [b-eps; b+eps] inclusive
** Try 0.1 + 0.1 + 0.1 - it will give exact 0.3 🙂 **
By continuing to use the site, you agree to the use of cookies. more information
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.