TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Algebra.js – Build, display, and solve algebraic equations

132 点作者 nicolewhite将近 10 年前

14 条评论

nicolewhite将近 10 年前
Hello HN,<p>I was learning JavaScript by completing challenges on CoderByte[0], where one of the hard challenges was to find the point where two lines intersect. The lines were defined by two sets of points, and you had to return your answers as rationals, not floats. The challenge isn&#x27;t timed, so I got a little carried away: ended up making a Fraction class, Equation class, etc. This first iteration could only solve linear equations, but I decided to expand it out into a library that could solve higher order polynomials and manipulate expressions.<p>On a related note, solving cubics is actually kind of hard. This guy Cardano[1] figured it out[2] in the 1500s, but his solution was incomplete because he wasn&#x27;t aware of imaginary numbers at the time. I then found you could solve cubics with some trig[3] and decided to go that route. Anyway, hope you enjoy, and of course I am interested in your feedback.<p>[0] <a href="http:&#x2F;&#x2F;coderbyte.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;coderbyte.com&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Gerolamo_Cardano" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Gerolamo_Cardano</a><p>[2] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Cubic_function#Cardano.27s_method" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Cubic_function#Cardano.27s_met...</a><p>[3] <a href="http:&#x2F;&#x2F;www.nickalls.org&#x2F;dick&#x2F;papers&#x2F;maths&#x2F;cubic1993.pdf" rel="nofollow">http:&#x2F;&#x2F;www.nickalls.org&#x2F;dick&#x2F;papers&#x2F;maths&#x2F;cubic1993.pdf</a>
评论 #10065055 未加载
kevin将近 10 年前
This is so well done! There are so many little touches here that delights me like the keyboard shortcuts for jumping right in and the LaTeX support. Even though this started off as a learning project for you, know that this is probably better than 95% of the API documentation I read from more professional development teams.<p>Jason Long&#x27;s Cayman Theme was unfamiliar to me until I saw your citation. Kudos to your good taste.<p>Documentation is pretty good. It probably skews more towards developers with experience using other libraries, but I think that&#x27;s fine for a first version. If you want to kick it up some more, I&#x27;d love to see more practical examples that might inspire me to use it out in the wild. Also, it took me awhile to figure out what to do with the keyboard shortcut. Something more explicit or even a small screencast would be nice.<p>I see that you also work on the RNeo4j library, which looks super cool. Queueing that up in the future to play with...since R is a much better place for me to feed that graphing library data. Thank you so much for sharing this!
评论 #10063265 未加载
joeyrobert将近 10 年前
This seems like a good start towards a symbolic math library like SymPy[0] for JavaScript. There&#x27;s lots of cool client-side applications for such a library, something like Mathway[1] or WolframAlpha[2] that doesn&#x27;t need to hit a server to do the symbolic computation.<p>[0] <a href="http:&#x2F;&#x2F;www.sympy.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.sympy.org&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;mathway.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mathway.com&#x2F;</a><p>[2] <a href="http:&#x2F;&#x2F;www.wolframalpha.com&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.wolframalpha.com&#x2F;</a>
dharmatech将近 10 年前
Nice work Nicole! :-)<p>I work on a similar library for C# (Symbolism [1]).<p>Consider allowing for variable elimination in sets of equations. (See this problem for an example: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;dharmatech&#x2F;a14d1a29a7d4c0728d37" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;dharmatech&#x2F;a14d1a29a7d4c0728d37</a>)<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;dharmatech&#x2F;Symbolism&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dharmatech&#x2F;Symbolism&#x2F;</a>
评论 #10062236 未加载
davmar将近 10 年前
this looks really neat and it must have been a lot of fun to build!<p>it&#x27;s not a feature request because I don&#x27;t have a use case for this quite yet, but how complex would it be to parse a string that contains a formula? for example, it seems useful to be able to load equations by just sending the string &quot;2x - 3 = 4&quot; to a function.<p>that sounds like a fun problem to solve as well. maybe useful to the library too. just a thought! great work on this library and thanks for publishing.
评论 #10064152 未加载
fibo将近 10 年前
I also created an algebra npm package, it implements what I learned at Algebra first year course at Università Degli Studi di Genova: <a href="http:&#x2F;&#x2F;g14n.info&#x2F;algebra&#x2F;" rel="nofollow">http:&#x2F;&#x2F;g14n.info&#x2F;algebra&#x2F;</a>
评论 #10064190 未加载
artartart将近 10 年前
There are powerful tools out there that can do this type of computation and more in a breeze. I have personally worked on SaturnAPI [0], which is a RESTful API for Matlab&#x2F;Octave. You can build your own APIs to do almost any calculation imaginable. If anyone needs to solve equations, definitely give it a shot. You can solve all sorts of equations, linear and non-linear [1].<p>[0] <a href="https:&#x2F;&#x2F;saturnapi.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;saturnapi.com&#x2F;</a><p>[1] <a href="http:&#x2F;&#x2F;www.mathworks.com&#x2F;help&#x2F;symbolic&#x2F;equation-solving.html" rel="nofollow">http:&#x2F;&#x2F;www.mathworks.com&#x2F;help&#x2F;symbolic&#x2F;equation-solving.html</a>
1arity将近 10 年前
the API is really clear and aesthetic. the whole work seems self contained. it is just awesome. im excited to think about an addition for matrices and combinatorics and calculus as well. this deserves to become like a Magma for js. unlike quite a lot of Shown HN this already seems complete, even the documentation, so aside from hoping it expands I feel there isnt much missing to point out. maybe a calculator graphical interface to produce expressions? oh and defnitely big num support!
评论 #10064163 未加载
clebio将近 10 年前
So it&#x27;s like an early-stage CAS written in Javascript?<p>E.g. Sage math (<a href="http:&#x2F;&#x2F;www.sagemath.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.sagemath.org&#x2F;</a>)
评论 #10062051 未加载
ahmacleod将近 10 年前
Nice work. I&#x27;ve built roughly half of this before, but your API is cleaner and the docs really tie it together.
CaiGengYang将近 10 年前
Hi does anyone know how to download Algebra.js ?<p>I clicked the &quot;Download .min.js&quot; tab on the Algebra.js.org page but was given this error message :<p><a href="http:&#x2F;&#x2F;algebra.js.org&#x2F;javascripts&#x2F;algebra.min.js" rel="nofollow">http:&#x2F;&#x2F;algebra.js.org&#x2F;javascripts&#x2F;algebra.min.js</a>
1arity将近 10 年前
it would be cool to have<p><pre><code> new CompoundExpression( &quot;x^2 - xy + 5&quot; ) </code></pre> or even<p><pre><code> new PolishSquarefree(&quot;+&quot;)(&quot;+&quot;)(&quot;^&quot;)(&quot;x&quot;)(2)(&quot;-xy&quot;)(5) </code></pre> or even<p><pre><code> new Polish(&quot;+&quot;)(&quot;-&quot;)(&quot;^&quot;)(&quot;x&quot;)(2)(&quot;.&quot;)(&quot;x&quot;)(&quot;y&quot;)(5)</code></pre>
maxwelljoslyn将近 10 年前
Hey, this is cool! Great work.
liammclennan将近 10 年前
Great project. Please add support for quintic equations.
评论 #10064966 未加载