symbolic-computation

symbolic matrix multiplication by Ryacas

99封情书 提交于 2021-02-08 03:38:59
问题 I define two matrices mat1 and mat2 in Sym class which is suitable for Ryacas symbolic computation: library(Ryacas) x <- Sym("x") mat1 <- List( List(x, 2), List(x^3, x)) and mat2 <- List( List(x, x), List(3, 6 * x)) now the question is how I can have the symbolic multiplication of these two matrices by Ryacas package? Thank you in advance. 回答1: Try this: > mat1 * mat2 expression(list(list(x^2 + 6, x^2 + 12 * x), list(x^4 + 3 * x, x^4 + 6 * x^2))) 来源: https://stackoverflow.com/questions

Modulo 2 arithmetics in SymPy

心已入冬 提交于 2020-01-15 03:47:10
问题 I'm working on transformation polynomial systems over GF(2^N) to GF(2). In a process of transformation I need to do lots of modulo 2 computations like summing and multiplying matrices. So is there way to sum and multiply matrices using modulo 2 arithmetics in Sympy? 回答1: I've had luck with sympy's trunc() function: from sympy import * var('x:z') y=25*x+12 z=trunc(y,2) # z=x 来源: https://stackoverflow.com/questions/21660852/modulo-2-arithmetics-in-sympy

Unexpected result on solving some inequality in Matlab symbolic computation

为君一笑 提交于 2020-01-05 04:09:27
问题 Please consider this example. I would like to solve x^3 - 2x > 0. I try the following commands: syms x; f = @(x) x^3-2*x; solve(f(x)>0,x) and Matlab returns this ans = solve([0.0 < x^3 - 2.0*x], [x]) which is not what I expect. Therefore I use solve(f(x)+x>x,x) which returns ans = Dom::Interval(2^(1/2), Inf) Dom::Interval(-2^(1/2), 0) Can someone explain that why solve works successfully only in the second case? 回答1: Try adding the Real option to solve : solve(f(x)>0,x,'Real',1) ans = Dom:

How do you install Symbolic C++ on Visual Studio 2010?

喜欢而已 提交于 2020-01-04 05:35:11
问题 I have Symbolic C++ (the version that can integrate with V, there is no documentation on how to install it. I got it from this website and it has examples of how it work: http://issc.uj.ac.za/symbolic/symbolic.html Does anyone have any idea on how to install this to use with my projects in Visual Studio? 回答1: Maybe a late answer, but may still be useful for others. For *nix systems: There are two versions: [1] Tarball that do not need to be installed in your system: http://issc.uj.ac.za

SymPy, simplification / substitution using known patterns or sub-expressions

与世无争的帅哥 提交于 2020-01-03 08:43:07
问题 I have the following expression: from sympy import pi, sin, cos, var, simplify var('j,u,v,w,vt,wt,a2,t,phi') u0 = v*a2*sin(pi*j/2 + pi*j*t*phi**(-1)/2) + pi*vt*a2*cos(pi*j/2 + pi*j*t*phi**(-1)/2)*j*phi**(-1)/2 + pi*w*a2*cos(pi*j/2 + pi*j*t*phi**(-1)/2)*j*phi**(-1) Which can be simplified: print simplify(u0) #a2*(pi*j*vt*cos(pi*j*(phi + t)/(2*phi)) + 2*pi*j*w*cos(pi*j*(phi + t)/(2*phi)) + 2*phi*v*sin(pi*j*(phi + t)/(2*phi)))/(2*phi) Given the sub-expressions: bj = pi*j*(phi + t)/(2*phi) cj = j

subs(sinc(K), K, 0) where K is symbol will return NaN. Shouldn't it be 1?

扶醉桌前 提交于 2019-12-24 01:39:25
问题 MATLAB sinc(0) will return 1 as it should. But sinc(K) of some symbol K for which a value of zero is substituted will return NaN. The following code illustrates the above: sinc(0) % calculate sinc of 0, this will return 1 K = sym('K'); % define symbol K % try to substitute value 0 for K in sinc(K), this will return NaN subs(sinc(K), K, 0) Can I force sinc to return 1 in the symbolic case (without knowing the value of K in advance)? MATLAB Version: 8.0.0.783 (R2012b) Symbolic Math Toolbox

symbolic computation in C++

不羁岁月 提交于 2019-12-21 03:41:02
问题 I need to do analytical integration in C++. For example, I should integrate expressions like this: exp[I(x-y)] , I is an imaginary number. How can I do this in C++? I tried GiNaC but it can just integrate polynomials. I also tried SymbolicC++. It can integrate functions like sine , cosine or exp(x) and ln(x) , but it is not very powerful. For example, it can not integrate x*ln(x) which can be easily obtained by use of Mathematica or by integration by parts. Are there any other tools or

Issue with Matlab solve function?

大城市里の小女人 提交于 2019-12-20 03:22:11
问题 The following command syms x real; f = @(x) log(x^2)*exp(-1/(x^2)); fp(x) = diff(f(x),x); fpp(x) = diff(fp(x),x); and solve(fpp(x)>0,x,'Real',true) return the result solve([0.0 < (8.0*exp(-1.0/x^2))/x^4 - (2.0*exp(-1.0/x^2))/x^2 - (6.0*log(x^2)*exp(-1.0/x^2))/x^4 + (4.0*log(x^2)*exp(-1.0/x^2))/x^6], [x == RD_NINF..RD_INF]) which is not what I expect. The first question: Is it possible to force Matlab's solve to return the set of all solutions? (This is related to this question.) Moreover,

Why doesn't Rebol 3 honor quoted function parameters that are parenthesized?

最后都变了- 提交于 2019-12-17 18:46:37
问题 The DO dialect uses series of category PAREN! for precedence, and will usually boil away the underlying parentheses structure prior to invoking a function. However, it used to be possible in Rebol 2 to specify in a function's definition that you wanted it to suppress evaluation of parentheses at the callsite. You did this by using a "literal word" apostrophe mark on a parameter: evaluated: func [param] [probe param] non-evaluated: func ['param] [probe param] >> evaluated (1 + 2) 3 >> non

Dealing with piecewise equations returned by sympy integrate

不羁岁月 提交于 2019-12-10 12:34:17
问题 In sympy I have an integral which returns a Piecewise object, e.g. In [2]: from sympy.abc import x,y,z In [3]: test = exp(-x**2/z**2) In [4]: itest = integrate(test,(x,0,oo)) In [5]: itest Out[5]: ⎧ ___ ⎪ ╲╱ π ⋅z │ ⎛ 1 ⎞│ π ⎪ ─────── for │periodic_argument⎜──────────────, ∞⎟│ ≤ ─ ⎪ 2 │ ⎜ 2 ⎟│ 2 ⎪ │ ⎝polar_lift (z) ⎠│ ⎪ ⎪∞ ⎪⌠ ⎨⎮ 2 ⎪⎮ -x ⎪⎮ ─── ⎪⎮ 2 ⎪⎮ z ⎪⎮ ℯ dx otherwise ⎪⌡ ⎪0 ⎩ I would like to extract just the first branch of this piecewise equation, in other words, I would like to be able to