How does a system like Wolfram Alpha or Mathematica solve equations?

岁酱吖の 提交于 2020-05-22 16:09:13

问题


I'm building a web-based programming language partially inspired by Prolog and Haskell (don't laugh).

It already has quite a bit of functionality, you can check out the prototype at http://www.lastcalc.com/. You can see the source here and read about the architecture here. Remember it's a prototype.

Currently LastCalc cannot simplify expressions or solve equations. Rather than hard-coding this in Java, I would like to enhance the fundamental language such that it can be extended to do these things using nothing but the language itself (as with Prolog). Unlike Prolog, LastCalc has a more powerful search algorithm, Prolog is "depth-first search with backtracking", LastCalc currently uses a heuristic best-first search.

Before delving into this I want to understand more about how other systems solve this problem, particularly Mathematica / Wolfram Alpha.

I assume the idea, at least in the general case, is that you give the system a bunch of rules for manipulation of equations (like a*(b+c) = a*b + a+c) specify the goal (eg. isolate variable x) and then let it loose.

So, my questions are:

  • Is my assumption correct?
  • What is the search strategy for applying rules? eg. depth first, breadth first, depth first with iterative deepening, some kind of best first?
  • If it is "best first", what heuristics are used to determine whether it is likely that a particular rule application has got us closer to our goal?

I'd also appreciate any other advice (except for "give up" - I regularly ignore that piece of advice and doing so has served me well ;).


回答1:


I dealt with such questions myself some time ago. I then found this document about simplification of expressions. It is titled Rule-based Simplification of Expressions and shows some details about simplification in Mupad, which later became a part of Matlab.

According to this document, your assumption is correct. There is a set of rules for manipulation of expressions. A heuristic quality metric is is used as a target function for simplification.




回答2:


Wolfram alpha is developed by Mathematica

  • mathematica is stephen wolphram's brainchild. Mathematica 1.0 was released in 1988. mathematica is much like maple and they both rely heavily on older software libraries like LaPack.
  • The libraries that these programs are, based on, and often simply, legacy software. They've been around, and modified, for a very long time.

If you would like to know about the background programs running, sagemath is a free open source alternative; you could possible reverse engineer the solutions to your questions:

SageMath.org



来源:https://stackoverflow.com/questions/18727737/how-does-a-system-like-wolfram-alpha-or-mathematica-solve-equations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!