symbolic-math

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

Can we replace the 'Derivative' terms in sympy coming from the differentiation of sympy.Function variables?

五迷三道 提交于 2020-01-04 02:45:21
问题 When the following code is run Derivative(Ksi(uix, uiy), uix)) and Derivative(Ksi(uix, uiy), uiy)) terms appear: In [4]: dgN Out[4]: Matrix([ [-(x1x - x2x)*(-x1y + x2y)*((x1x - x2x)**2 + (-x1y + x2y)**2)**(-0.5)*Derivative(Ksi(uix, uiy), uix) + (-x1y + x2y)*(-(-x1x + x2x)*Derivative(Ksi(uix, uiy), uix) + 1)*((x1x - x2x)**2 + (-x1y + x2y)**2)**(-0.5)], [-(-x1x + x2x)*(-x1y + x2y)*((x1x - x2x)**2 + (-x1y + x2y)**2)**(-0.5)*Derivative(Ksi(uix, uiy), uiy) + (x1x - x2x)*(-(-x1y + x2y)*Derivative

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

Expanding math expression (expanding parentheses)

隐身守侯 提交于 2020-01-02 10:42:17
问题 I have a expression like this a*(b+c) and I have successfully parsed into an AST so it finally becomes: I'm trying to expand the expression it finally becomes a*b + a*c , but with no luck. I would like to know an algorithm to expand the expression, or maybe a library to do it, preferably for .NET. 回答1: In Symja you can use the Distribute() or Expand() function for your problem: package org.matheclipse.core.examples; import org.matheclipse.core.eval.ExprEvaluator; import org.matheclipse.core

Expanding math expression (expanding parentheses)

二次信任 提交于 2020-01-02 10:42:15
问题 I have a expression like this a*(b+c) and I have successfully parsed into an AST so it finally becomes: I'm trying to expand the expression it finally becomes a*b + a*c , but with no luck. I would like to know an algorithm to expand the expression, or maybe a library to do it, preferably for .NET. 回答1: In Symja you can use the Distribute() or Expand() function for your problem: package org.matheclipse.core.examples; import org.matheclipse.core.eval.ExprEvaluator; import org.matheclipse.core

Expanding math expression (expanding parentheses)

冷暖自知 提交于 2020-01-02 10:42:09
问题 I have a expression like this a*(b+c) and I have successfully parsed into an AST so it finally becomes: I'm trying to expand the expression it finally becomes a*b + a*c , but with no luck. I would like to know an algorithm to expand the expression, or maybe a library to do it, preferably for .NET. 回答1: In Symja you can use the Distribute() or Expand() function for your problem: package org.matheclipse.core.examples; import org.matheclipse.core.eval.ExprEvaluator; import org.matheclipse.core

SymPy and square roots of complex numbers

╄→гoц情女王★ 提交于 2020-01-02 04:07:06
问题 When using solve to compute the roots of a quadratic equation, SymPy returns expressions which could be simplified but I can't get it to simplify them. A minimal example looks like so: from sympy import * sqrt(-24-70*I) Here, SymPy just returns sqrt(-24-70*I) while Mathematica or Maple will answer with the equivalent of 5-7*I . I'm aware that there are two square roots, but this behavior entails that SymPy will, for example, return pretty complicated solutions from z = symbols("z") solve(z **

substitute the derivative of a function in a symbolic expression

佐手、 提交于 2020-01-01 12:08:18
问题 I have the same question as here. In Matlab the derivative of a function can be represented symbolically as >> syms t >> syms x(t) >> diff(x,t) ans(t) = D(x)(t) But how can I substitute in an expression if, say, I know the derivative. >> subs(ans,D(x)(t),3) Error: ()-indexing must appear last in an index expression. 回答1: Let's work through an example: syms t x(t) y f = x^2+y dfdt = diff(f,t) % returns 2*D(x)(t)*x(t) dxdt = diff(x,t) % returns D(x)(t) subs(dfdt,dxdt,3) which returns the 6*x(t)

Beautifying the output of Matlab aka human-readable form for output?

元气小坏坏 提交于 2019-12-25 02:49:10
问题 syms x y z; solve(x==y+1, y^2==z,z==9) ans = x: [2x1 sym] y: [2x1 sym] z: [2x1 sym] and now I want to see the results like Mathematica outputting {{x->-2,y->-3,z->9},{x->4,y->3,z->9}} for Solve[{x == y + 1, y^2 == z, z == 9}, {x, y, z}] . The workspace window and then variable editor shows me this but I still cannot see the real values stored there. How can I see the output of Matlab in human-readable form aka beautified form? 回答1: The documentation of solve states: When solving a system of