As APC said, there are no built-in functions for this. But you can use the WolframAlpha API from PL / SQL:
declare v_equation varchar2(32767) := '(3.5/(1+x))+(3.5/(1+x)^2)+(3.5/(1+x)^3)+(3.5/(1+x)^4)+(100/(1+x)^4)=101.55'; v_escaped_url varchar2(32767); v_uri httpuritype; v_xml xmltype; v_count number := 1; begin --Escape the URL. --I used chr(38) for ampersand, in case your IDE think it a substitution variable v_escaped_url := 'http://api.wolframalpha.com/v2/query?appid=EQGHLV-UYUEYY9ARU'||chr(38)||'input=' ||utl_url.escape(v_equation, escape_reserved_chars => true) ||chr(38)||'format=plaintext'; --Create an HTTPURIType, and get the XML v_uri := httpuritype.createUri(v_escaped_url); v_xml := v_uri.getXML; --Complex solutions while v_xml.existsNode('/queryresult/pod[@title="Complex solutions"]/subpod['||v_count||']') = 1 loop dbms_output.put_line(v_xml.extract('/queryresult/pod[@title="Complex solutions"]/subpod['||v_count||']/plaintext/text()').getStringVal()); v_count := v_count + 1; end loop; --Real solutions v_count := 1; while v_xml.existsNode('/queryresult/pod[@title="Real solutions"]/subpod['||v_count||']') = 1 loop dbms_output.put_line(v_xml.extract('/queryresult/pod[@title="Real solutions"]/subpod['||v_count||']/plaintext/text()').getStringVal()); v_count := v_count + 1; end loop; end; /
Results:
x = -1.00006-0.996229 i x = -1.00006+0.996229 i x = -1.99623 x = 0.0308219
There are many potential drawbacks to this approach. It will be very slow, and the API is not free. My example works because I used my free developer, but it is only good for a small number of calls.
Jon heller
source share