# Tag Info

7

Nick Alger gives a nice explanation. Here is another one, possibly slightly simpler because it avoids the "should stay roughly the same" part. Let's say you want to compute the derivative of any matrix function $X=X(C)$ with regard to entry $C_{ij}$: $$\frac{\partial X}{\partial C_{ij}}.$$ In other words, you ask how the matrix $X$ changes as you change ...

6

Given that $u \frac{\tau^2}{2} \ll 1$, one way of tackling the numerical oscillations, even before the actual term emerges, is a Taylor approximation in $u$ of the sine term (Thanks to Kirill for the full series): $$\sin(\underbrace{x_5 + x_6 \tau}_{u_0} + \underbrace{u \frac{\tau^2}{2}}_{\Delta u}) = \sin(x_5 + x_6 \tau) + \sum_{n=1}^N \frac{(-1)^{\lfloor ... 4 This integral has a closed analytic solution. The trick is to write$$\frac{1}{x^3+ ax + 2a} = \frac{A}{x-x_1} + \frac{B}{x-x_2} + \frac{C}{x-x_3}$$by a method called partial fraction decomposition. The values x_i are the roots of the polynomial in the denominator. As your polynomial only has third degree, an analytic formula for the roots exists (aka "... 4 You have to write your second order equation as a system of two first order equations. Let y' = v, then your equation$$ y'' + \omega^2 y = 0 $$becomes$$ \begin{pmatrix} y' \\ v' \end{pmatrix} = \begin{pmatrix} v \\ -\omega^2 y \end{pmatrix} = \begin{pmatrix} 0 & 1 \\ -\omega^2 & 0 \end{pmatrix} \begin{pmatrix} y \\ v \end{pmatrix} $$If you ... 4 Let \mathbf{\theta} be a Gaussian random vector with mean \mathbf{\mu} and covariance matrix \mathbf{\Sigma}_\mathbf{\theta}. Let \mathbf{p}_\theta denote the joint PDF. Let J_\mathbf{\theta} be the objective function, as its negative logarithm:$$J_\mathbf{\theta}=-ln(\mathbf{p}_\theta)$$By taking the partial derivatives w.r.t. \theta_d and ... 3 As you may know:$$ \int x^y \, dx = \dfrac{x^{y+1}}{y+1},$$with y \neq 1. If you want to plot the function  \dfrac{x^{y+1}}{y+1} for a specific y using Matplotlib, here is the answer: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D x = np.linspace(-4, 4, 30) y = np.linspace(-4, 4, 30) def func(x, y, ... 2 We know that$$C C^{-1} = I$$If we perturb C a little bit, by a matrix X, and recompute the inverse, the result should stay roughly the same. In symbols:$$(C + X) \left(C^{-1} + \underbrace{\frac{\partial C^{-1}}{\partial C}\cdot X}_{\text{matrix}}\right) \approx I,$$where "\frac{\partial C^{-1}}{\partial C}\cdot X" is the first order correction to C^... 2 I would either interpolate the samples of u_0 or do a curve-fit, so as to obtain an approximate u_0(\eta) that is easy to integrate analytically. The choice of interpolation or fitting methods depends on what you know about u_0(\eta). For example, if it is a band-limited signal, and the sample frequency is greater than the Nyquist rate, then ... 1 @federicopolini is right in his answer: Introduce$$ c= \sqrt{a}, d=\sqrt{b} $$and your optimization problem will now read as follows:$$ \min (x-c^2)^2+(y-d^2)^2 $$subject to the constraints$$ c+d = 2, \\ c\ge 0,\\ d\ge 0. $$The inequality constraints are important to ensure that you get a solution that makes sense. Now, you can eliminate d=... 1 From a comment: I suggest you to set \sqrt{a}:=c and \sqrt{b}:=d and then pass the problem in the variables c,d to whatever computational software you are using. I would avoid those non-smooth square roots in the constraints at all costs if it's possible. The general idea (from a very philosophical standpoint; this feels more like a comment than an ... 1 In essence, you are asking whether you have values for a function h'(r) at points r_i, you can obtain an approximation of h(r). The answer is of course yes: If you connect the points (r_i,h'(r_i)) by a piecewise linear curve, then you can integrate that to obtain a piecewise quadratic approximation of h(r). You can be more accurate if you connect ... 1 I think the easiest way may simply be an outer loop over the outer integral, while interatively increasing the inner one. So you basically do a midpoint rule for the outer integral, and remember the value of your inner integral from the last step. pseudocode: double dx = 1e-12; double inner_int =0.0; double outer_int =0.0; for(double x = 0.0; x<=1.0;x+=... 1 The idea is that each \vec{y}_k depends on \vec{w}. Therefore for the first equation, simply apply the chain rule for each \vec{y}_k and sum them up. Componentwise one has:$$\left(\frac{dL}{d\vec{w}}\right)_{i}=\sum_{k,\alpha}{\left(\frac{dQ}{d\vec{y}_k}\right)_{\alpha}\left(\frac{\partial \vec{y}_k}{\partial \vec{w}}\right)_{i\alpha}} \tag{*} Maybe ...

1

You can simplify your code by removing redundant checks in if statements. You can also pull out the valueDx which is constant in the loop: double e = 0.0; double simpsonsRule = 0.0; double valueHolder = 0.0; valueN = 2; valueA = 0; valueB = (Math.PI)/2; valueDx = (valueB-valueA)/valueN; simpsonsRule = 1.0 + Math.PI/2; for(int i = 2; i<=valueN ; i++){ ...

1

The following is not valid C: return(sqrt(data[]+1)+0.25); I think what you want is: float f(float data[], int n) { float fx = 0.0; for(int i=0;i<n;i++){ fx += sqrt(data[i]+1)+0.25; } return fx; } where the integer input n is the size of your data array. Edit On re-reading the question I think what you want is the following function: ...

Only top voted, non community-wiki answers of a minimum length are eligible