symbolic-math

Matlab cannot compute an infinite integral?

走远了吗. 提交于 2020-01-23 17:38:47
问题 I am studying Stochastic calculus, and occasionally we need to compute an integral (from -infinity to +infinity) for some complex distribution. In this case, it was with the answer on the right. This is the code I put into Matlab (and I have the symbolic math toolbox), which Matlab simply cannot process: >> syms x t >> f = exp(1+2*x)*(1/((2*pi*t)^0.5))*exp(-(x^2)/(2*t)) >> int(f,-inf,inf) ans = -((2^(1/2)*pi^(1/2)*exp(2*t + 1)*limit(erf((2^(1/2)*((x*1i)/t - 2i))/(2*(-1/t)^(1/2))), x, -Inf)*1i

How to have square wave in Matlab symbolic equation

旧城冷巷雨未停 提交于 2020-01-20 07:04:34
问题 My project require me to use Matlab to create a symbolic equation with square wave inside. I tried to write it like this but to no avail: syms t; a=square(t); Input arguments must be 'double'. What can i do to solve this problem? Thanks in advance for the helps offered. 回答1: here are a couple of general options using floor and sign functions: f=@(A,T,x0,x) A*sign(sin((2*pi*(x-x0))/T)); f=@(A,T,x0,x) A*(-1).^(floor(2*(x-x0)/T)); So for example using the floor function: syms x sqr=2*floor(x)

How to have square wave in Matlab symbolic equation

。_饼干妹妹 提交于 2020-01-20 07:02:12
问题 My project require me to use Matlab to create a symbolic equation with square wave inside. I tried to write it like this but to no avail: syms t; a=square(t); Input arguments must be 'double'. What can i do to solve this problem? Thanks in advance for the helps offered. 回答1: here are a couple of general options using floor and sign functions: f=@(A,T,x0,x) A*sign(sin((2*pi*(x-x0))/T)); f=@(A,T,x0,x) A*(-1).^(floor(2*(x-x0)/T)); So for example using the floor function: syms x sqr=2*floor(x)

Can I change the formula of a symbolic function in MATLAB?

◇◆丶佛笑我妖孽 提交于 2020-01-16 19:17:51
问题 I have the following code: syms t x; e=symfun(x-t,[x,t]); In the problem I want to solve x is a function of t but I only know its value at the given t,so I modeled it here as a variable.I want to differentiate e with respect to time without "losing" x,so that I can then substitute it with x'(t) which is known to me. In another question of mine here,someone suggested that I write the following: e=symfun(exp(t)-t,[t]); and after the differentiation check if I can substitute exp(t) with the

Symbolic differentiation with Euler-Lagrange equation

Deadly 提交于 2020-01-15 03:58:25
问题 I'm trying to calculate Euler-Lagrange equations for a robotic structure. I'll use q to indicate the vector of the joint variables. In my code, I use syms t; q1 = sym('q1(t)'); q2 = sym('q2(t)'); q = [q1, q2]; to declare that q1 and q2 depend on time t . After I calculate the Lagrangian L (in this case it is a simple link with a rotoidal joint) L = (I1z*diff(q1(t), t)^2)/2 + (L1^2*M1*diff(q1(t), t)^2)/8 The problem is that when I try to differentiate L respect to q using diff(L, q) , I get

How to call a shadowed function in Octave?

人走茶凉 提交于 2020-01-15 02:54:49
问题 I want to modify the behaviour of the vpa function. For that I define my own function called vpa that calls the original vpa function and then does some more stuff. To call the original function from within my modified function I use y = builtin('vpa', varargin{:}); where varargin is a cell array of the function inputs, as usual. The problem is that the above produces a different result than calling the original vpa function. Minimal example, run on Octave 4.2.2: >> vpa([4 5], 20) ans = (sym)

Symbolic vs Numeric Math - Performance

六月ゝ 毕业季﹏ 提交于 2020-01-14 08:10:44
问题 Do symbolic math calculations (especially for solving nonlinear polynomial systems) cause huge performance (calculation speed) disadvantage compared to numeric calculations? Are there any benchmark/data about this? Found a related question: https://scicomp.stackexchange.com/questions/21754/symbolic-computation-vs-numerical-computation Another one: Computational Efficiency of Forward Mode Automatic vs Numeric vs Symbolic Differentiation 回答1: I am the individual who answered the Scicomp

Symbolic vs Numeric Math - Performance

北城余情 提交于 2020-01-14 08:09:05
问题 Do symbolic math calculations (especially for solving nonlinear polynomial systems) cause huge performance (calculation speed) disadvantage compared to numeric calculations? Are there any benchmark/data about this? Found a related question: https://scicomp.stackexchange.com/questions/21754/symbolic-computation-vs-numerical-computation Another one: Computational Efficiency of Forward Mode Automatic vs Numeric vs Symbolic Differentiation 回答1: I am the individual who answered the Scicomp

Make sure MATLAB does not recalculate symbolic expression

邮差的信 提交于 2020-01-11 07:14:10
问题 I am building (my first...) MatLab program, it needs to differentiate an equations symbolically and then use this solution many many times (with different numeric inputs). I do not want it to recalculate the symbolic differentiation every time it needs to put in a new set of numeric values. This would probably greatly add to the time taken to run this program (which - given its nature, a numeric optimiser, will probably already be hours). My question is how can I structure my program such

Solve finds wrong solution?

徘徊边缘 提交于 2020-01-07 05:23:46
问题 I have this equation in x and y: (x + y)^(1/2) - 6*y*(x + y)^5 - (x + y)^6 + (x - 1)/(2*(x + y)^(1/2)) = 0. Now I call the solver: R_c = @(y)solve((x + y)^(1/2) - 6*y*(x + y)^5 - (x + y)^6 + (x - 1)/(2*(x + y)^(1/2)), x, 'Real', true); which gives me the implicit solutions as a function of y. Now try R_c(.3) to find the explicit solution at y = 0.3. MATLAB's answer is: ans = 0.42846617518653978966562924618638 0.15249587894102346284238111155954 0.12068186494007759990714181154349 However, the