arrays,matlab,vector,matrix,calculus

For two arbitrary lines (e.g. line 1 and line 2) do: RGB_dist(x(1,:), x(2,:)) if you want all the combinations then check out pdist2. If you don't have the stats toolbox (i.e. no pdist2) then use nchoosek to create all possible pairs of rows: I = nchoosek(1:size(x,1),2); D = RGB_dist(x(I(:,1),:), x(I(:,2),:))...

You can use the pracma library, such as: library(pracma) dummy <- function(x) { z <- x[1]; y <- x[2] rez <- (z^2)*(y^3) rez } grad(dummy, c(1,2)) [1] 16 12 hessian(dummy, c(1,2)) [,1] [,2] [1,] 16 24 [2,] 24 12 ...

sql,database,algebra,relational,calculus

This is the translation to SQL for your formula that starts with {S|∃ D ∈ Doctor (∃ C ∈ Duty (D.Doc_id = C.Doc_id ^ (etc..) ) ) } SELECT * FROM S WHERE EXISTS (SELECT * FROM Doctor D WHERE EXISTS (SELECT * FROM Duty C WHERE (D.Doc_id = C.Doc_id)...

use sympy >>> from sympy import symbols, diff >>> x, y, z = symbols('x y z', real=True) >>> f = 4*x*y + x*sin(z) + x**3 + z**8*y >>> diff(f, x) 4*y + sin(z) + 3*x**2 ...

Change 3x to 3*x. (This may be the smallest answer-length-to-question-length ratio I've seen in a long time ;-)...

Here is a simple numerical approach based upon your formula above. You could improve upon this: derivativeOf takes a function fn and an x-coordinate x and returns a numerical approximation of derivative of fn at x: func derivativeOf(fn: (Double)->Double, atX x: Double) -> Double { let h = 0.0000001 return...

c++,algorithm,math,calculus,cybernetics

I integral part is just summation also multiplied by some constant. Analogue integration is done by nonlinear gain and amplifier. Digital integration of first order is just: output += input*dt; second order is: temp += input*dt; output += temp*dt; dt is the duration time of iteration loop (timer or what...

Assuming that the (x,y) grid is uniform, you can approximate the integral by a 2D-Riemman sum as follows: result = sum(z(:))*delta_x*delta_y; where delta_x, delta_y are the grid spacings in the x and y directions. In your case these can be computed as delta_x = 2*pi/numel(x); %// or 2*pi/(numel(x)-1) delta_y =...

Well David,you can convert this function into one trigonometric function by multiplying and dividing it by √(1^2 + 8) i.e, 3. So your function becomes like this I = 3*(1/3 cos(wt) + √8/3 sin(wt)) = 3* sin(wt + atan(1/√8)) Now, you can easily say its maximum value is I =...

machine-learning,integration,neural-network,implementation,calculus

My personal opinion it is not possible to feed into NN enough rules for integrating. Why? Because NN are good for linear regression ( AKA approximation ) or logical regression ( AKA classification ). Integration is neither of them. It is calculation task according to some strict algorithms. So from...

See plotting functions and expressions in the Gadfly manual. For your example, something like plot([x->x^2+1, x->(x-4)+(x+3)], -2, 2) should do the trick using anonymous functions. It's not currently possible to do this with multivariate functions as far as I'm aware....

local function Rotate(X, Y, alpha) local c, s = math.cos(math.rad(alpha)), math.sin(math.rad(alpha)) local t1, t2, t3 = X[1]*s, X[2]*s, X[3]*s X[1], X[2], X[3] = X[1]*c+Y[1]*s, X[2]*c+Y[2]*s, X[3]*c+Y[3]*s Y[1], Y[2], Y[3] = Y[1]*c-t1, Y[2]*c-t2, Y[3]*c-t3 end local function convert_rotations(Yaw, Pitch, Roll) local F, L, T = {1,0,0}, {0,1,0}, {0,0,1} Rotate(F, L, Yaw)...

javascript,math,canvas,calculus

As your code is not time bound (in order for real-time frequency to work) you need to first define how much width represents one cycle (@ 1 Hz, or one second if you will). Lets say the whole canvas width represents one cycle then we can do this: var period...

c,math,calculator,integral,calculus

y = 10.0 - (12.0 + (float)x) / 4.0; Followed by y = y+1; This makes sense else you have y uninitialized which leads to undefined behavior because the value of y is undeterminate. During declaration you can initialize y and use += operator. Like float y = 0;...

You're then looking for Math.ceil(), not Math.round() Math.ceil(value/ 5000.0) * 5000.0 Compare also nearest integer function with floor and ceiling functions...

math,wolfram-mathematica,series,calculus

This should be close: inner[i_, gamma_, k_] := Sum[(-1)^(el[1])/el[1]! Product[(-1)^(el[z] - el[z - 1])/(el[z] - el[z - 1])! ,{z, 2, i}], Evaluate[Sequence @@ ({{el[1], k, gamma}}~Join~Table[ { el[ii], el[ii - 1], gamma }, {ii, 2, i}])]] With[{gamma = 3, k = 1}, Sum[ inner[i, gamma, k], {i, gamma - 1}]]...

c,math,recursion,calculus,derivative

I would implement it like this: double derivative(double (*f)(double), double x0, int order) { const double delta = 1.0e-6; double x1 = x0 - delta; double x2 = x0 + delta; if (order == 1) { double y1 = f(x1); double y2 = f(x2); return (y2 - y1) / (x2...