Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

implement sympy as plugin (CAS-System) #384

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

pointhi
Copy link
Contributor

@pointhi pointhi commented Jul 9, 2015

I implemented a Computer Algebra System as plugin, using SymPy.

current Features:

  • calculation of simple equations like: 1+2*3/5, sin(1), sqrt(2),...
  • solving of equations with one unknow variable: 15*a+3=30, sin(3)=x*2,...
  • solving of simple integrals: integral of sin(x) dx, integrate e^2*x dx,...

TODO:

  • graphical output of functions
  • add possibility to insert most SymPy Commands and output them with correct formating

Because I have to use MathML for formating, I changed the answere system to work more similare linke the results (to allow different key-value pairs). Now Answers could contain html-code, or simple text. I think we should improve the answere system in the future, to allow things like thumbnails,...

@dalf
Copy link
Contributor

dalf commented Jul 11, 2015

Whaou, nice !

Some notes :

  • perhaps add sympy in requirements.txt
  • chrome has removed the mathml support, one workaround : https://github.com/mathjax/MathJax
  • (10*1.1) eur in usd works in google (I know that's suppose to include in sympy in an engine)

We need a way to have engine without HTTP request (perhaps sympy parsing is done after all requests and slow down the global response time).

@dalf
Copy link
Contributor

dalf commented Jul 11, 2015

Another thing : cos(4*x)+sin(2*x)=1 has more than one results, and the global width is too large (the results are hidden by the suggestions).

Perhaps add a line break between the results ?

@dalf
Copy link
Contributor

dalf commented Jul 11, 2015

One more thing : there is no timeout

a equation like cos(x)^2+sin(2*x+pi)=tan(1) can easily create a DOS.

@pointhi
Copy link
Contributor Author

pointhi commented Jul 11, 2015

yes, but I don't know how to do it properly (From what I found out, there is no clear way in python to handle timeouts of functions): http://eli.thegreenplace.net/2011/08/22/how-not-to-set-a-timeout-on-a-computation-in-python/

@pointhi
Copy link
Contributor Author

pointhi commented Sep 16, 2015

ok, I found out using signals would be working for sympy, but we cannot use them in threads: ValueError: signal only works in main thread.

I tried to implement https://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in-python, but I didn't got it working. Any other idea?

@Cqoicebordel
Copy link
Contributor

I would recommand that you try to do it the hard way :
Create a new thread containing the solve(), and if it's still alive 10s later (or whatever the time is set in pref), you kill it (if it's still alive, it didn't return the solution and killed itself).
It's not classy, but should work.
Look at https://docs.python.org/release/2.7/library/multiprocessing.html and the answer with 25 votes in your link.

@ibrokemypie
Copy link

any updaye? looks like an awesome idea

@dimqua
Copy link
Contributor

dimqua commented Sep 25, 2018

Any chance it will be merged any time soon?

@schwukas
Copy link

I'll give this one a bump. I think this would be a nice extra especially for users switching from popular search engines to searx. Is it only the review that is missing or does it actually need extra code? I would certainly try to help, but I'm not very proficient when it comes to threads in python,

@tbergeron
Copy link

I really wish this could be integrated. Whenever I have to do quick maths I used to type it in the browser bar and any search engine would return the results but now I have to start the good old calculator app (or worse! use my BRAIN! hehehe)

Is there any reason it's taking so long to get integrated? Is there anything we could do about it? Having complex calculation support would be great but I don't believe it's needed for a first step towards integrating arithmetic into the engine.

@return42
Copy link
Contributor

return42 commented Apr 8, 2020

I really wish this could be integrated.

In order not to end up in a dead end, we should first consider how best to embed such tools into the search syntax. See my comment at PR1146.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants