Is there any in-built API for solving complex math problems like integration and differentiation

StackOverflow https://stackoverflow.com/questions/3728507

  •  03-10-2019
  •  | 
  •  

문제

I need to implement an algorithm which has intensive mathematical calculation. Is there already support in java for this? Or are there any 3rd party vendors who provide this support?

도움이 되었습니까?

해결책

JavaCalc might be relevant to your needs

Goal
The main goal of this project is to develop a symbolic library for Java that can handle regular algebraic expressions as well as standard calculus functions. Specifically, the library should support:

• Parsing standard algebraic expressions (syntax tree) from a string.
• Simplifying algebraic expressions (factoring, common denominator, trigonometric identities, etc).
• Applying symbolic standard calculus functions (differentiation, integration) to algebraic expressions.
• Common calculus tools (Taylor series, limits, numerical approximations).
• Graphing tools (using swing).
• If time permits, differential equation support (symbolic solver, Euler's approximation, Laplace transform).

다른 팁

There is no built in functions that address such needs, however you can check a library like commons-math

I hope this helps.

If you have a web app and want a REST API served over HTTP, check out SaturnAPI. You can write your own Matlab and Octave scripts and host it there. Then from your web app, you can make simple HTTP POST requests with input data to execute the scripts. Then you can retrieve the HTTP response data as the script output. Below is an example of integration you can fork. You can also search for Matlab and Octave examples online that suit your needs and use it on SaturnAPI.

%%%%%%%%%%%%%%%%%%%%%%%%%% Integrating Differential Equations %%%%%%%%%%%%%%%%%%%%%%%%%%
% (GNU License)
% SaturnAPI has built-in functions for solving nonlinear differential equations of the form
%
%     dx
%     -- = f (x, t)
%     dt
%
% with the initial condition
%
%     x(t = t0) = x0
%
% For SaturnAPI to integrate equations of this form, 
% you must first provide a definition of the function f(x,t). 
% Do this by entering the function body directly in the API script. 
% The example script below defines the right-hand side function xdot
% for an interesting pair of nonlinear differential equations. 
% It computes the integral and prints the last term to be sent as the HTTP response data. 
% SaturnParams is an array containing the initial condition
% For instance, SaturnParams='[1 ; 2]'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function xdot = f (x, t)

  r = 0.25;
  k = 1.4;
  a = 1.5;
  b = 0.16;
  c = 0.9;
  d = 0.8;

  xdot(1) = r*x(1)*(1 - x(1)/k) - a*x(1)*x(2)/(1 + b*x(1));
  xdot(2) = c*a*x(1)*x(2)/(1 + b*x(1)) - d*x(2);

endfunction

x0 = SaturnParams;
t = linspace (0, 50, 200)';
x = lsode ("f", x0, t);

printf("%f", x(length(x)));

Disclosure: I worked on SaturnAPI

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top