https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17097754782014-02-19T11:11:39ZRuby Issue Tracking SystemRuby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=452792014-02-19T11:11:39Zumair.amjad (Umair Amjad)umair.amjad@confiz.com
<ul></ul><p>Please guide how can I contribute, I have code written on my local.</p> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=453772014-02-22T05:20:43ZAnonymous
<ul><li><strong>Priority</strong> changed from <i>5</i> to <i>Normal</i></li></ul><p>Hi Umair,</p>
<p>You should attach a .patch file and wait for feedback.</p> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=454332014-02-23T08:55:25Zzzak (zzak _)
<ul><li><strong>Category</strong> set to <i>lib</i></li><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li><li><strong>Assignee</strong> set to <i>zzak (zzak _)</i></li><li><strong>Target version</strong> set to <i>2.2.0</i></li></ul><p>If you're using subversion you can use the <code>svn diff</code> or <code>svn di</code> command to output a patch, and then just upload the file. For example:</p>
<p><code>svn diff lib/mathn.rb > my-patch-to-mathn.diff</code></p>
<p>You can read more about <code>svn diff</code> in the <a href="http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.diff.html" class="external">svnbook</a></p>
<p>Bonus points, when requesting a feature please try to give as many details as possible about your feature:</p>
<ol>
<li>What is your proposed change?</li>
<li>Why would people use it? (use cases)</li>
<li>Why should this be added to ruby?</li>
</ol>
<p>Are just a few of the questions you could try to answer. We have some more detailed documentation <a href="https://github.com/ruby/ruby/blob/trunk/doc/contributing.rdoc#how-to-request-features" class="external">on contributing.rdoc</a></p> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=480952014-07-27T21:28:47Zzzak (zzak _)
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li></ul><p>Its been 5 months without any feedback, so I'm closing this.</p>
<p>If you have any specific questions about how to contribute, please feel free to reply or email the list <a href="mailto:ruby-core@ruby-lang.org" class="email">ruby-core@ruby-lang.org</a> or email me personally at <a href="mailto:zzak@ruby-lang.org" class="email">zzak@ruby-lang.org</a></p>
<p>May the Ruby be with you..</p> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=498562014-11-09T06:34:59Zmartin_vahi (Martin Vahi)martin.vahi@softf1.com
<ul><li><strong>File</strong> <a href="/attachments/4855">the_code.rb</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/4855/the_code.rb">the_code.rb</a> added</li><li><strong>File</strong> <a href="/attachments/4856">run_demo.bash</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/4856/run_demo.bash">run_demo.bash</a> added</li></ul><p>Well, I have the same wish, except that I also have a demo code available.</p>
<p>A speed optimized demo can be downloaded from</p>
<pre><code>http://longterm.softf1.com/2014/demos/2014_11_08_ruby_factorial_proposal/the_code.rb
</code></pre>
<p>and run by</p>
<pre><code>http://longterm.softf1.com/2014/demos/2014_11_08_ruby_factorial_proposal/run_demo.bash
</code></pre>
<p>For 100000.factorial the speed difference is literally roughly 20-fold (not just 20%).</p> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=498572014-11-09T07:54:20Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li></ul> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=498742014-11-10T18:38:48Zgogotanaka (Kazuki Tanaka)mail@tanakakazuki.com
<ul></ul><p>I like your propose. But I'd be glad if <code>Math.gamma(x)</code> could make sense for you : )</p>
<p><a href="http://www.ruby-doc.org/core-2.1.4/Math.html#method-c-gamma" class="external">http://www.ruby-doc.org/core-2.1.4/Math.html#method-c-gamma</a></p>
<p>Even if we'er gonna add new method, except <code>mathn</code> might be better.<br>
Because <code>mathn</code> became deprecated. <a href="https://bugs.ruby-lang.org/issues/10169" class="external">#10169</a></p>
<p>Thanks, gogo.</p> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=499282014-11-13T07:01:27Zmartin_vahi (Martin Vahi)martin.vahi@softf1.com
<ul></ul><p>I wasn't aware of the existence of the gamma function before reading Your comment. I guess I got a bit smarter due to Your comment. Thank You for that. :-)</p>
<p>According to some sources, including the</p>
<pre><code>http://mathworld.wolfram.com/GammaFunction.html
</code></pre>
<p>it seems to me that the gamma function is an approximation. I think that a clean solution for functions that are based on approximations should always have a maximum error size as a second argument. For example,</p>
<pre><code>sin(x)
</code></pre>
<p>is actually calculated through series and is never absolutely correct. Therefore the</p>
<pre><code>sin(x)
cos(x)
gamma(x)
etc...
</code></pre>
<p>should be</p>
<pre><code>sin(x,absolute_value_of_max_error=<some default value>)
cos(x,absolute_value_of_max_error=<some default value>)
gamma(x,absolute_value_of_max_error=<some default value>)
etc...
</code></pre>
<p>The IEEE_754</p>
<pre><code>https://en.wikipedia.org/wiki/IEEE_floating_point
</code></pre>
<p>determines some "default" error "size" through its rounding. Due to the exponent mechanism of the IEEE_754, the same property that gives</p>
<pre><code>fd_big=(9**99).to_f
puts "No difference detected." if fd_big == (fd_big+1.to_f)
</code></pre>
<p>there is no single minimum approximation-result-changing value for the error size. Therefore, to find a clean solution for the proper implementation of the gamma/sin/cos/etc. function(s), further work has to be done and that's probably going to be pretty complex and time consuming. However, it is a fact that the current Math.gamma(x) implementation is flawed, because it gives IEEE_754 "infinity" for Math.gamma(10000). That probably limits cryptography related experiments.</p>
<p>The good news is that it seems (at least to me) that dependency wise factorial of integers is very general. Even some forms of the gamma(x) formulae depend on factorials of integers. That's why it seems to me that the proposed</p>
<pre><code>Fixnum.factorial
Bignum.factorial
</code></pre>
<p>do not clutter the stdlib. That is to say, as of my current comment, I stick with my initial proposal.</p>
<p>Well, one way or the other, I still thank You all for Your answers and efforts. :-)</p> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=692682018-01-05T21:00:26Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>2.2.0</i></del>)</li></ul> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=700512018-01-31T07:18:02Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li><li><strong>Assignee</strong> changed from <i>zzak (zzak _)</i> to <i>hsbt (Hiroshi SHIBATA)</i></li></ul><p>mathn.rb has been removed at Ruby 2.5.0 [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: It might be better to make Mathn class deprecated (Closed)" href="https://bugs.ruby-lang.org/issues/10169">#10169</a>]</p> Ruby master - Feature #9528: mathn.rb libraryhttps://bugs.ruby-lang.org/issues/9528?journal_id=700892018-01-31T13:43:15Zmartin_vahi (Martin Vahi)martin.vahi@softf1.com
<ul></ul><p>Given that my proposal is more general than the obsoleted mathn.rb,<br>
would it be helpful, if I filed a new Feature Request that would<br>
suggest an addition of a new class to the Ruby stdlib?</p>
<p>For example, the function apply_binary_operator might be<br>
wrapped to a class named "Math_optimizations" and<br>
the watershed concatenation algorithm would be the default<br>
heuristic for the</p>
<pre><code class="ruby syntaxhl" data-language="ruby"> <span class="no">Math_optimizations</span><span class="p">.</span><span class="nf">apply_binary_operator</span>
</code></pre>
<p>The heuristic might be later changed by adding<br>
an optional 4. argument to the function call.<br>
The signature would look like:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"> <span class="k">def</span> <span class="nc">Math_optimizations</span><span class="o">.</span><span class="nf">apply_binary_operator</span><span class="p">(</span>
<span class="n">x_identity_element</span><span class="p">,</span><span class="n">array_in</span><span class="p">,</span>
<span class="n">func_operator_that_might_be_noncommutative</span><span class="p">,</span>
<span class="n">heuristic</span><span class="o">=</span><span class="s2">"watershed_concatenation"</span><span class="p">)</span>
</code></pre>