symbolic-math

computer algebra soft to minimize the number of operations in a set of polynomials

好久不见. 提交于 2019-12-11 06:08:02
问题 I have systems of polynomials, fairly simple polynomial expressions but rather long to optimize my hand. Expressions are grouped in sets, and in a given set there are common terms in several variables. I would like to know if there is a computer algebra system, such as Mathematica, Matlab, or sympy, which can optimize multiple polynomials with common terms to minimize number of operations. It would be also great if such system can minimize the number of intermediate terms to reduce number of

Python integration using both scipy and sympy

我的未来我决定 提交于 2019-12-11 05:48:59
问题 I want to have a custom python function which: Takes a mathematical expression f(x) , bounds of the integral x1,x2 and desired tolerance tol Uses sympy.integrate(y, x) to check if it has analytical/symbolic solution, if it does then returns the result using sympy.integrate(y, (x,x1,x2).evalf()) If it doesn't have an analytical solution out of the sympy then it uses scipy.integrate.quad or other numerical functions to calculate the integral. The reason is that with this method it will be

Using fzero: Undefined function or method 'isfinite' for input arguments of type 'sym'

半世苍凉 提交于 2019-12-11 04:50:32
问题 I use matlab for symbolic calculations. After long calculations I've got a function of x, which is the combination of bessel functions and I want to find it's zeros. For that purpose I use fzero function in Matlab. But while it works perfectly for single bessel functions, it wont work for the mine one. >> fzero(@(x)besselj(0,x), 3.5) ans = 2.4048 >> fzero(@(x)DELTA_xi, 3.5) ??? Undefined function or method 'isfinite' for input arguments of type 'sym'. Error in ==> fzero at 333 elseif

How to solve a symbolic system of equations in Matlab

☆樱花仙子☆ 提交于 2019-12-11 04:47:19
问题 I know it has to be a stupid error,but I really can't solve a system of this type: b = a2*cos(q1 + q2) + a1*cos(q1) a2*sin(q1 + q2) + a1*sin(q1) d1 + d4 + q3 >> solve(b,[q1,q2,q3,q4]) Warning: The solutions are parametrized by the symbols: z1 = C_ > In solve at 190 ans = a1: [1x1 sym] d1: [1x1 sym] d4: [1x1 sym] q1: [1x1 sym] q2: [1x1 sym] q3: [1x1 sym] q4: [1x1 sym] basically I want my program to see a1,d1,d4 as parameters and q1,q2,q3,q4 as variables. that's why I call solve(b,[q1,q2,q3,q4]

Force evaluate index expression before passing to sum()

南楼画角 提交于 2019-12-11 03:32:20
问题 I want to write an (somehow) enhanced sum function which takes a number of indices at once, but I cannot understand how to get it work. Here is what I currently have: (%i1) nsum(indexes, expr) := if indexes = [] then expr else nsum(rest(indexes), sum(expr, first(indexes),1, N)) $ (%i2) nsum([i,j], i+j), nouns; sum: index must be a symbol; found intosym(first(indexes)) #0: nsum(indexes=[k,j],expr=k+j) I think this could be fixed by forcing Maxima expand first(indexes) into a symbol before

MATLAB R2012b - Passing arrays and ints into evalin(symengine,expression)

风流意气都作罢 提交于 2019-12-10 23:55:22
问题 I'm attempting to generate the Laguerre polynomials, and then evaluate them elementwise over a coordinate array. Presently my code looks something like: [X,Y] = meshgrid(x_min:mesh_size:x_max,y_min:mesh_size:y_max); const_p=0; const_l=1; %At present these two values don't really matter, any integer will do coord_r = sqrt(X.^2 + Y.^2) lag_input = num2str(coord_r.^2) u_pl = evalin(symengine,['orthpoly::laguerre(',num2str(const_p),',',num2str(const_l),',',lag_input,')']); However, that returns

How to simplify a symbolic and numeric mixed expression in Matlab

这一生的挚爱 提交于 2019-12-10 23:29:40
问题 I have a symbolic and numeric mixed expression: (3145495418313256125*sin(11334310783410932061962315977/17437937757178560512000000000)*cos(theta))/85568392920039424 where theta is a symbolic variable. I want to simplify this expression such that all the numeric numbers and their math operation results are changed to double. 回答1: In terms of data types, you can't mix floating point and symbolic values. However, you can use variable precision arithmetic so that the values are represented in

Error while evaluating the function convolution

只谈情不闲聊 提交于 2019-12-10 22:22:54
问题 This is my first attempt to write anything in matlab, so please, be patient. I am trying to evaluate the solution of the following ODE: w'' + N(w, w') = f(t) with the Cauchy conditions w(0) = w'(0) = 0. Here N is a given nonlinear function, f is a given source. I also need the function where G is the solution of the following ODE: where G(0) = G'(0) =0, s is a constant, and My try is as follows: I define N , f , w and G : k = 1000; N = @(g1,g2) g1^2 + sin(g2); f = @(t) 0.5 * (1 + tanh(k * t))

SymPy could not compute the eigenvalues of this matrix

拜拜、爱过 提交于 2019-12-10 19:15:52
问题 I want to compute the second eigenvalue of a Laplacian matrix to check if the corresponding graph is connected or not, but when I try to use SymPy's eigenvals , a lot of times it happens that it throws an error MatrixError: Could not compute eigenvalues for Matrix([[1.00000000000000, 0.0, 0.0, 0.0, -1.00000000000000, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 1.00000000000000, 0.0, 0.0, 0.0, -1.00000000000000, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.00000000000000, 0.0, 0.0, 0.0, 0.0, 0.0, -1.00000000000000,

Handling Symbolic Matrices in R as in Matlab

丶灬走出姿态 提交于 2019-12-10 18:05:23
问题 I am failing to appropriately work with a Symbolic Matrix in R, with both rSymPy and Ryacas. In Matlab this is easy. I am looking for suggestions how to do this in R and get a similar output as in Matlab . To do this in Matlab I need the 'Symbolic Toolbox'. In this example I wish to generate a Symbolic transition probability matrix "P", which is say 5 x 5, and has elements P11, P12,..., P55. I then want to use this matrix for multiplication (with itself and other matrices) and potentially