text
stringlengths
81
47k
source
stringlengths
59
147
Question: <p>How can I use matlab to solve the following Ordinary Differential Equations?</p> <p><strong>x''/y = y''/x = -( x''y + 2x'y' + xy'')</strong></p> <p>with two known points, such as t=0: x(0)= x0, y(0) = y0; t=1: x(1) = x1, y(1) = y1 ? It doesn't need to be a complete formula if it is difficult. A numerical...
https://stackoverflow.com/questions/23962549/matlab-solve-ordinary-differential-equations
Question: <p>Ive got a pair of differential equations that I've learnt how to solve:</p> <blockquote> <pre><code>dc/dt=r*c+c^2-c^3-b*c*u, du/dt=-g*u+(b*c*u)/2, </code></pre> </blockquote> <p>where r,b,g are constants (no assumption on r but b and g are positive). So my code to solve these are:</p> <pre><code>from s...
https://stackoverflow.com/questions/53525908/solving-a-pair-of-iterated-differential-equations
Question: <p>I am trying to make and ode solver using c++ and numerical methods (euler, heun and runge kutta). first i made and abstract class for ode solving requirements then i made a separate class for each solver inheriting from the ABClass. there is no problem with the code excpet it works only with first order di...
https://stackoverflow.com/questions/46874293/making-an-abstractodesolver-class-library-to-solve-differential-equations-numeri
Question: <p>I need to solve these 2 differential equations simultaneously. </p> <pre><code>dr^3/dt=(-3*D*Cs)/(ρ*r0^2 )*r*(1-C) dC/dt=((D*4π*r0*N*(1-C)*r)-(Af*C))/V </code></pre> <p>Note: dr^3/dt is the derivative of r^3 with respect to t</p> <p>The two equations resemble the change in particle radius (r) and conce...
https://stackoverflow.com/questions/58895739/solving-differential-equations-in-matlab
Question: <p>I am trying to solve this differential equation as part of my assignment. I am not able to understand on how can i put the condition for u in the code. In the code shown below, i arbitrarily provided </p> <pre><code>u = 5. 2dx(t)dt=−x(t)+u(t) 5dy(t)dt=−y(t)+x(t) u=2S(t−5) x(0)=0 y(0)=0 </code></pre...
https://stackoverflow.com/questions/50471374/solving-differential-equation-with-step-function
Question: <p>I have a Differential equations such as below in matlab format </p> <pre><code>syms x y m g r l J % x,y are variables, the others are constant 1: 0.5*m*(r^2*x^2+l^2*(Dx-Dy)^2+2*r*l*Dx*(Dx-Dy)*cos(y))+0.5*J*(Dx-Dy)^2=m*g* (l*sin(x-y)-r*(1-cos(x))); 2: J*(D2x-D2y)+l^2*(D2x-D2y)-r*l*(Dx)^2*sin(y)+r*l...
https://stackoverflow.com/questions/39295156/matlab-ode45-solves-differential-equations-with-two-variables-of-same-order
Question: <p>I want to solve a differential equation that has some "silence period" (I'm not sure whether it has a formal name or not, it means during this period that the system is static and not controlled by the differential equation).</p> <p>For example (see the figure), when a free-fall ball touches the ground, t...
https://stackoverflow.com/questions/57578402/how-to-solve-differential-equations-with-silence-period-using-differentialequat
Question: <p>I'm trying to solve complex coupled differential equations as follows.</p> <pre><code>import numpy as np from scipy.integrate import complex_ode def cae(z, A, params): A1, A2, A3 = A alpha, gamma, dbeta = params dA = [ -0.5*alpha*A1 + 1j*gamma*(np.abs(A1)**2 + 2*np.abs(A2)**2 + 2*np...
https://stackoverflow.com/questions/34627594/python-error-while-solving-complex-coupled-differential-equations
Question: <p>I am trying to solve a set of complicated differential equations in Python. These equations contain five functions (defined in the function 'ODEs' in the code below) that are functions of a variable n (greek name is eta--- I used n and eta interchangeably as variable names). These coupled differential equa...
https://stackoverflow.com/questions/66877010/solving-an-involved-set-of-coupled-differential-equations
Question: <p>I cannot write the program which is solving 2nd order differential equation with respect to code I wrote for <strong>y'=y</strong></p> <p>I know that I should write a program which turn a 2nd order differential equation into two ordinary differential equations but I don!t know how can I do in Python.</p> ...
https://stackoverflow.com/questions/56349229/solving-2nd-order-differential-equations-wrt-this-code
Question: <p>Is there a repository (or a web page) of all differential equations coded in DifferentialEquations.jl or at least ODE in OrdinaryDiffEq.jl?</p> <p>If there are no repositories, are there other sources, university classes, etc. where Julia code is used to solve differential equations and is available?</p> ...
https://stackoverflow.com/questions/77032222/julia-differential-equations-repositories
Question: <p>I am trying to solve RLC circuits using python. When there are no Cs and Ls, after calculating i got to a linear system of equations which i solved using <code>numpy.linalg</code>, e.g :</p> <pre><code>a + b = 1 a + c = 2 c - b = 1 </code></pre> <p>But now i need to solve this with differential elements in...
https://stackoverflow.com/questions/65201682/solving-system-of-differential-equations
Question: <p>I have a differential equation-</p> <pre><code>L'(x) = F1(x,L(x)) </code></pre> <p>Using ode45, I have obtained the solution for L(x). I have an array of values for L(x) denoted by L_val. Using this solution, I intend to solve another differential equation.</p> <pre><code>w'(x)=L(x)/x </code></pre> <p>How ...
https://stackoverflow.com/questions/64633010/solving-differential-equations-with-discrete-values-in-matlab-using-ode45
Question: <p>I am trying to solve a second order differential equation using finite difference method. In the following code I have a function to calculate the first derivative and the second derivative. I am creating a sparse matrix with one column and trying to solve it using <code>np.linalg</code>. However, the <cod...
https://stackoverflow.com/questions/76059170/solve-differential-equation-using-finite-difference-method
Question: <p>I am trying to use <code>pydelay</code> library to solve a system of delay differential equations. I have followed <a href="http://pydelay.sourceforge.net/" rel="nofollow">instructions</a> to setup my model. However, I ran into some errors and really appreciate any suggestions.</p> <p>Here is my code:</p>...
https://stackoverflow.com/questions/19104131/problems-using-python-to-solve-coupled-delay-differential-equations-ddes
Question: <p>I have <em>a huge set of <strong>coupled nonlinear integro-partial differential</strong> equations</em>. After a long while trying to simplify the equations and solve them at least semi-analytically I have come to conclude there has been left no way for me but an efficient numerical method. Finite element ...
https://stackoverflow.com/questions/18841528/a-python-library-for-solving-some-integro-differential-equations
Question: <p>I'm trying to solve a system of ordinary differential equations with Euler's method, but when I try to print velocity I get</p> <pre><code>RuntimeWarning: overflow encountered in double_scalars </code></pre> <p>and instead of printing numbers I get <code>nan</code> (not a number). I think the problem mig...
https://stackoverflow.com/questions/29870245/solve-a-system-of-differential-equations-using-eulers-method
Question: <p>I tried to solve system of two differential equations using <code>scipy.integrate.odient</code>. The results are far from my expectations as one can see from the plots I attached below.</p> <p>This is the system of ODEs:</p> <p><img src="https://i.sstatic.net/KIuEvcGy.png" alt="" /></p> <p>where alpha an...
https://stackoverflow.com/questions/78783282/solving-system-of-differential-equations-with-odient
Question: <p>I want to solve a system of differential equations using the RK4 method, like given below. <a href="https://i.sstatic.net/RJhmw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/RJhmw.png" alt="enter image description here" /></a></p> <p>So for this case, I've to solve 3 differential equations...
https://stackoverflow.com/questions/69273973/solving-a-large-system-of-coupled-differential-equations-using-rk4
Question: <p>Is this undoable? Say I have a complex system of differential equations that I want to have a live user-based input to them and then I want to plot the results in real time. It doesn't seem like javascript has the precision or mathematical dexterity. My initial thought was to use python with scipy for o...
https://stackoverflow.com/questions/16735309/solving-differential-equations-in-realtime-in-a-webapp
Question: <p>I have implemented following equations both with the Matlab own ODE solvers and with a very simple finite difference scheme. The latter works properly, while the ODE code does not produce suitable solutions. What I am doing wrong? These are a set of coupled implicit differential equations.</p> <pre><code> ...
https://stackoverflow.com/questions/79252262/solving-differential-equations-with-ode-solvers-and-finite-difference-in-matlab
Question: <p>I want to solve this differential equation: y′′+2y′+2y=cos(2x) with initial conditions:</p> <ol> <li><p>y(1)=2,y′(2)=0.5</p></li> <li><p>y′(1)=1,y′(2)=0.8</p></li> <li><p>y(1)=0,y(2)=1</p></li> </ol> <p>and it's code is:</p> <pre><code>import numpy as np from scipy.integrate import odeint import matplot...
https://stackoverflow.com/questions/49964702/python-initial-condition-in-solving-differential-equation
Question: <p>I have a system of differential equations like this</p> <p><code> dy/dt = f(t,y,y1,y2,....,yn,x), dy1/dt = f(t,y,y1,y2,..yn,x), . . . dyn/dt = f(t,y,y1,y2,..yn,x), x(t) = f(t,y1,y2,...yn,x) </code></p> <p>And I have the values y_i(0),x(0) If I had dx/dt then simply using scipy.integrate IVP I could solve...
https://stackoverflow.com/questions/61442582/how-to-solve-this-system-of-ivp-differential-equations
Question: <p>I'm trying to solve the following system of differential equations using scipy:</p> <pre><code>q1''(t) + M/L1 * q2''(t) + R1/L1 * q1'(t) + 1/(C1 * L1) * q1(t) = 0 q2''(t) + M/L2 * q1''(t) + R2/L2 * q2'(t) + 1/(C2 * L2) * q2(t) = 0 </code></pre> <p>I'm trying to use scipy.integrate.odeint to obtain a num...
https://stackoverflow.com/questions/30566994/solving-system-of-differential-equations-using-scipy
Question: <p>I would like to solve a system of network-based differential equations using python 3.6. The system of equations is as follows:</p> <pre><code>dx_i/dt = omega_i - epsilon_i * y_i * x_i - mu_i * x_i, dy_i/dt = epsilon_i * y_i * x_i - zeta_i * y_i - rho_i * y_i * z_i, dv_i/dt = c_i * y_i - gamma_i * v_...
https://stackoverflow.com/questions/57447343/i-would-like-to-solve-a-system-of-network-based-differential-equations-using-pyt
Question: <p>I am trying to solve the following set of coupled differential equations ( variables are p,n and psi) using the bvp solver in python :-</p> <pre><code>1. d2n/dx2-(d2psi/dx2)n-(dpsi/dx)(dn/dx)=k1 in domain 1 2. d2p/dx2+(d2psi/dx2)p+(dpsi/dx)(dp/dx)=k2 in domain 1 3. d2psi/dx2= k*(p-n) in domain 1 4. d2psi/...
https://stackoverflow.com/questions/62016035/solving-differential-equations-in-two-different-domains-using-the-bvp-solver-in
Question: <p>I want to find an elegant way of solving the following differential equation:</p> <pre><code>from sympy import * init_printing() M, phi, t, r = symbols('M phi t r') eq = Eq(-M * phi(t).diff(t), Rational(3, 2) * m * r**2 * phi(t).diff(t) * phi(t).diff(t,t)) </code></pre> <p><a href="https://i.sstatic.ne...
https://stackoverflow.com/questions/33340217/sympy-solve-a-differential-equation
Question: <p>I have a differential equation of the form:</p> <pre><code>xs'' = rhs * theta </code></pre> <p>to solve in Simulink, where <strong>xs</strong> and <strong>theta</strong> are variables and <strong>rhs</strong> is a numerical constant. So far, I've got this: <a href="https://i.sstatic.net/EzVLY.png" rel="n...
https://stackoverflow.com/questions/42350080/solve-differential-equation-with-two-variables-in-simulink
Question: <p>My task is to model a certain physical problem and use matlab to solve it's differential equations. I made the model but it seems far more complex than what I've learned so far so I have no idea how to solve this.</p> <p>The black color means it's a constant</p> <p><img src="https://i.sstatic.net/aRzfw.j...
https://stackoverflow.com/questions/57548600/how-to-solve-this-system-of-differential-equations-in-matlab
Question: <p>I think, this should be simple. I'm solving numerically a set of differential equations in R. When I do it one it is fine. However I need to test the set of differential equations for several groups of parameters, thus I am using a loop. The problem is that for all the set of parameters it shows the same v...
https://stackoverflow.com/questions/36941968/solving-differential-equations-in-a-loop-with-different-parameters-each-time-r
Question: <p>How can I solve nonlinear system of differential equations and get plot for this solution? The system is without initial conditions. For example,</p> <p>x'= (x + y)^2 - 1 y'= -y^2 - x + 1</p> Answer: <p><a href="https://reference.wolfram.com/language/tutorial/DSolveIntroduction.html" rel="nofollow">Intro...
https://stackoverflow.com/questions/37351824/solving-nonlinear-system-of-differential-equations-in-wolfram-mathematica
Question: <p>I am new to sympy and in the process of learning it. I was browsing through the documentation and questions in stack exchange regarding symbolically solving a system of differential equations with initial conditions using sympy. </p> <p>I have a simple system of ODE-s</p> <pre><code>( dV/dt ) = -( 1 / ...
https://stackoverflow.com/questions/26172733/syntax-for-solving-system-of-differential-equations-in-sympy
Question: <p><strong>The problem</strong></p> <p>I currently have a system of four equations. Two are second-order differential equations and two are first-order differential equations:</p> <p><a href="https://i.sstatic.net/IQtr6.png" rel="nofollow noreferrer">Four equations</a></p> <p>The initial conditions are:</p> <...
https://stackoverflow.com/questions/64372007/solving-a-system-of-first-order-differential-equations-and-second-order-differen
Question: <p>I am trying to solve a set of differential equations, but I have been having difficulty making this work. My differential equations contain an &quot;i&quot; subscript that represents numbers from 1 to n. I tried implementing a forloop as follows, but I have been getting this index error (the error message ...
https://stackoverflow.com/questions/66361935/using-a-forloop-to-solve-coupled-differential-equations-in-python
Question: <p>I am trying to solve a system of 6 differential equations using matlab. I created a set of 6 differential equations as follows in a function m file named as Untitled.m</p> <pre><code>function ydot=Untitled(z,y) ydot = zeros(6,1); %y(1)=A %y(2)=B %y(3)=C %y(4)=D %y(5)=P y(6)=T A=0.50265 k11=(333/106.7)*1....
https://stackoverflow.com/questions/21588348/solving-a-system-of-6-differential-equations-by-ode45-in-matlab
Question: <p>I want to use deSolve to solve coupled partial differential equations, and am trying to get used to the package by solving easy differential equations with ode. I know the solution to y' = sqrt(1-y^2) is sin(t + c), so I tested it with the starting conditions y(0) = 0 and y(0) = 1, expecting to get sin(t) ...
https://stackoverflow.com/questions/72897940/why-isnt-ode-in-r-solving-easy-differential-equations
Question: <p>This is more of a design question. I am involved with a project that requires us to solve a bunch of first order differential equations. I know the python has modules to this and we have been using those functions.</p> <p>However, we need the integrator to be fast, so we want to use adaptive step sizes ...
https://stackoverflow.com/questions/33988654/fortran-or-c-and-f2py-to-solve-differential-equations
Question: <p>I have a differential equation that is as follows:</p> <pre><code>%d/dt [x;y] = [m11 m12;m11 m12][x;y] mat = @(t) sin(cos(w*t)) m11 = mat(t) + 5 ; m12 = 5; m21 = -m12 ; m22 = -m11 ; </code></pre> <p>So I have that my matrix is specifically dependent on t. For some reason, I am having a super difficult ...
https://stackoverflow.com/questions/47231292/solving-coupled-nonlinear-differential-equations
Question: <p>I'm trying to solve a system of differential equations in python. I have a system composed by two equations where I have two variables, A and B. The initial condition are that A0=1e17 and B0=0, they change simultaneously. I wrote the following code using ODEINT:</p> <pre><code>import numpy as np from scipy...
https://stackoverflow.com/questions/66354995/solve-system-of-differential-equation-in-python
Question: <p>I need to integrate over a system of differential equations in GEKKO and want to use parameters to alter a gradient.</p> <p>Conceptually this works, but the output is not what I expected. I added a code snippet for a sample problem below to illustrate the problem.</p> <p>The solver will integrate over a sp...
https://stackoverflow.com/questions/70939582/using-parameters-to-solve-differential-equations-in-gekko-python
Question: <p>I have a following <a href="https://i.sstatic.net/7RcuQ.png" rel="nofollow noreferrer">ordinary differential equation</a> and numeric parameters <a href="https://i.sstatic.net/5Ol8B.png" rel="nofollow noreferrer">Sigma</a>=0.4, x(0) = 4 and dx(0)/dt = 0<br> My task is to get Cauchy problem solution (Initi...
https://stackoverflow.com/questions/40832798/solve-ordinary-differential-equations-using-scipy
Question: <p>I'd like to code in python a coupled system of differential equations : <code>dF/dt=A(F)</code> where <code>F</code> is a matrix and <code>A(F)</code> is a function of the matrix <code>F</code>.</p> <p>When <code>F</code> and <code>A(F)</code> are vectors the equation is solved using <code>scipy.integrate...
https://stackoverflow.com/questions/59953428/solving-1st-order-differential-equations-for-matrices
Question: <p>I need to solve this system of differential equations. </p> <p>I tested it with removing <code>rk(3)</code> from the <code>rk(2)</code> equation and in that case I do get some solution. The code runs without error. However when I keep the <code>rk(3)</code> in the <code>rk(2)</code> equation I get a bunch...
https://stackoverflow.com/questions/57576549/how-to-solve-this-system-of-differential-equations-where-one-differential-is-par
Question: <p>I am trying to solve a series of differential equations as shown in the code below. But when I do simulate these differential equations, I am getting an inaccurate result. Here, I have 4 variables and I first reshaped my vector and then concatenated the values in hopes of having equal vector lengths for ea...
https://stackoverflow.com/questions/66756967/returning-odd-result-when-solving-differential-equations-with-solve-ivp
Question: <p>I am trying to solve a differential equation numerically but I need to vary y0 for my plot and view result for constant x. I can solve my equation normally as I expected:but I can't get result when I try for my real purpose as you can see</p> <pre><code>`\[Sigma] = 1; n = 23.04; Rop = y[x]; R = 0.5; sz = ...
https://stackoverflow.com/questions/24537894/plot-of-nd-solve-differential-equation-with-another-parameter
Question: <p><strong>Goal</strong></p> <p>I have been attempting to solve and plot the following coupled differential equation belonging to quadratic drag:</p> <p><a href="https://i.sstatic.net/onuqg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/onuqg.png" alt="enter image description here" /></a></p> ...
https://stackoverflow.com/questions/64410747/solving-coupled-differential-equations-of-quadratic-drag
Question: <pre><code>function dfdt=myfun(t,x) dfdt = [... x(2); (1.5*((x(2))^2)*(cos(3*(x(1)))))-(((pi/2)^2) * ... (sin((pi*t)/2)))-(20*((x(1))-(sin((pi*t)/2)))) - ... ((0.5*((x(2))^2)*abs(cos(3*(x(1)))))+0.1) * ... sat(((x(2)-((pi/2)*cos((pi*t)/2))) + ... ...
https://stackoverflow.com/questions/16978825/solving-fractional-differential-equations-in-matlab-using-fde12-function
Question: <p>How can I show that <code>y(t)=Yo/Yo+(1-Yo)e^-at</code> is the solution of the differential equation <code>dy/dt=ay(1-y)</code> using MATLAB. What function should I use?</p> Answer: <p>if you want to simulate the results use the ode's family</p> <p><a href="https://www.mathworks.com/help/matlab/ref/ode45...
https://stackoverflow.com/questions/42324200/how-to-solve-differential-equation-in-matlab
Question: <p><a href="https://i.sstatic.net/XO1BZ.png" rel="nofollow noreferrer">system of differential equations</a></p> <p>Pls look at an image above</p> <p>How can i build up the derivation function for this system to use scipy.integrate.odeint? I tried to express 3 DEs as linear combinations of second derivatives...
https://stackoverflow.com/questions/62245231/how-to-solve-this-system-of-differential-equations-numerically
Question: <p>I want to solve a system of 4 coupled differential equations with python (sympy):</p> <pre><code>eqs = [Eq(cP1(t).diff(t), k1*cE1(t)**3), Eq(cE1(t).diff(t), -k1 * cE1(t)**3 + k6 * cE3(t)**2), Eq(cE2(t).diff(t), -k8 * cE2(t)), Eq(cE3(t).diff(t), k8 * cE2(t) - k6 * cE3(t)**2)] </code></pre> <p>When I try to ...
https://stackoverflow.com/questions/65393787/solving-a-system-of-coupled-differential-equations-with-dsolve-system-in-python
Question: <p>I would like to have first several coefficients of formal power series defined implicitly by a differential equation.</p> <blockquote> <p><strong>Example.</strong></p> </blockquote> <pre class="lang-py prettyprint-override"><code>import sympy as sp sp.init_printing() # math as latex from IPython.display im...
https://stackoverflow.com/questions/46427586/how-to-solve-a-differential-equation-in-formal-power-series
Question: <p>I am trying to plot orbits of a charged particle around a Reissner–Nordström blackhole(Charged blackhole).</p> <p>I have three 2nd order differential equations as well as 3 first order differential equations. Due to the nature of the problem each derivative is in terms of proper time rather than time t. Th...
https://stackoverflow.com/questions/66664733/solving-3-coupled-nonlinear-differential-equations-using-4th-order-runge-kutta-i
Question: <p>I am trying to solve the differential equation 4(y')^3-y'=1/x^2 in python. I am familiar with the use of odeint to solve coupled ODEs and linear ODEs, but can't find much guidance on nonlinear ODEs such as the one I'm grappling with.</p> <p>Attempted to use odeint and scipy but can't seem to implement prop...
https://stackoverflow.com/questions/75479380/solving-nonlinear-differential-equations-in-python
Question: <p>I want to describe the kinetics of a chemical reaction and my idea of a reaction model results (simplified) in a differential equation of the following form:</p> <pre><code>y1'(t)=y1(t)+y2(t) </code></pre> <p>where y1 is the from an experiment measured concentration of a reactant and y2 the measured conc...
https://stackoverflow.com/questions/54920753/using-mathematica-to-solve-this-differential-equation
Question: <p>Well, I wanna solve a system of complex ODE in the form:</p> <p>$ i\hbar \dfrac{\partial \rho}{\partial t} = \left[ H, \rho \right] $</p> <p><a href="http://mathbin.heroku.com/rq65idQ" rel="nofollow" title="Paste Bin of Equation">http://mathbin.heroku.com/rq65idQ</a></p> <p>where $\rho$ and $H$ are $n x...
https://stackoverflow.com/questions/13480667/solve-system-of-complex-differential-equations-in-octave
Question: <p>I want to use the spectral method to solve partial differential equations. The equations like that, <a href="https://i.sstatic.net/vDAgk.png" rel="nofollow noreferrer">formula</a>,the initial condition is u(t=0,x)=(a^2)*sech(x),u'_t (t=0)=0.</p> <p>To solve it, I use the python with the spectral method. F...
https://stackoverflow.com/questions/60974226/how-to-use-solve-ivp-solve-partial-differential-equations-with-spectral-method
Question: <p>Taken from Sal Khan's lecture <a href="https://www.youtube.com/watch?v=oiDvNs15tkE" rel="nofollow">https://www.youtube.com/watch?v=oiDvNs15tkE</a> of the Khan academy, if I know that dN/dt=rN(1-(N/K)) (the logistic differential equation)</p> <p>How can I solve for N and plot the N=f(t) with R?</p> <p>Tha...
https://stackoverflow.com/questions/25001337/how-to-solve-and-plot-differential-equations-in-r
Question: <p>Till now, I haven't faced any issue while solving well-posed differential equations problems using sympy only in python such as</p> <ol> <li>Solving a second order linear differential equation:</li> </ol> <pre><code>import matplotlib.pyplot as plt from sympy import dsolve, symbols, Function, Eq t= symbols...
https://stackoverflow.com/questions/67430010/can-we-prioritise-sympy-over-scipy-while-solving-well-posed-differential-equatio
Question: <p>I have <a href="https://i.sstatic.net/1txPv.png" rel="nofollow noreferrer">the following equation system (click to see picture)</a> , and would like to solve for X(t), Y(t), Z(t), hopefully using Octave/Matlab, which I'm familiar with, but I would not mind solving it by any other means necessary. </p> <p>...
https://stackoverflow.com/questions/60235976/solve-system-of-differential-equation-with-embedded-non-diferential-equations-u
Question: <p>I am working on simulation of a system that contains coupled differential equations. My main aim is to solve the mass balance in steady condition and feed the solution of steady state as initial guess for the dynamic simulation. There are basically three state variables Ss,Xs and Xbh. The rate equations lo...
https://stackoverflow.com/questions/51313086/solving-non-linear-coupled-differential-equations-in-python
Question: <p>How can I solve a system of k differential equations with derivatives appearing in every equation? I am trying to use Scipy's solve_ivp.</p> <p>All the equations are of the following form:</p> <p><a href="https://i.sstatic.net/3Gqqn.png" rel="nofollow noreferrer">equations</a></p> <p>How can this system of...
https://stackoverflow.com/questions/63354720/how-to-numerically-solve-this-system-of-arbitrary-number-of-differential-equatio
Question: <p>I would like to numerically find the solution to </p> <p><code>u_t - u_xx - u_yy = f</code> on the square y ∈ [0,1], x ∈ [0,1]</p> <p>where f=1 if in the unit circle and f=0 otherwise. The boundary conditions are u=0 on all four edges.</p> <p>I have been trying to use ND-solve for ages but I keep gett...
https://stackoverflow.com/questions/4020606/mathematica-solving-differential-equations
Question: <p>I have a differential equation with time varying function W_at(t). How can I solve it using sympy's <code>dsolve</code> with initial conditions.</p> <pre><code>from sympy import * init_printing(use_unicode=True) theta_vr, theta_vd, theta_vo, t = symbols('theta_vr theta_vd theta_vo t') W_at = Function('W_a...
https://stackoverflow.com/questions/66604009/how-to-solve-a-differential-equation-with-time-dependent-parameters
Question: <p>How can I solve the second order differential equation using scilab ode() function. (For example: y'' + 3y' +2y = f(x), y(0)=0, y'(0)=0) And then plot the result of function y(x).</p> <p>I want to use this to model the RLC-circuit signal with step-function input</p> <p>Here is the code I tried</p> <pre>...
https://stackoverflow.com/questions/29477235/using-scilab-to-solve-and-plot-differential-equations
Question: <p>I have the matrix differential equation <code>Ax'=Bx+b</code>, where <code>A</code> and <code>B</code> are matrices of <code>N*N</code>, and <code>b</code> is a vector.</p> <p>I want to solve it with python. Hope someone could help me.</p> <p>Cheers!</p> Answer: <p>If your matrix <code>A</code> is regu...
https://stackoverflow.com/questions/50396666/matrix-differential-equation-solve-ax-bxb
Question: <p>I would like to solve a differential equation in R (with <code>deSolve</code>?) for which I do not have the initial condition, but only the final condition of the state variable. How can this be done?</p> <p>The typical code is: <code>ode(times, y, parameters, function ...)</code> where <code>y</code> is t...
https://stackoverflow.com/questions/40580485/how-to-specify-final-value-rather-than-initial-value-for-solving-differential
Question: <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/11513926/fast-gradient-descent-implementation-in-a-c-library">Fast gradient-descent implementation in a C++ library?</a> </p> </blockquote> <p>I'm looking to run a gradient descent optimization to min...
https://stackoverflow.com/questions/11524657/fast-gradient-descent-implementation-in-a-c-library
Question: <p>I am trying to develop stochastic gradient descent, but I don't know if it is 100% correct.</p> <ul> <li>The cost generated by my stochastic gradient descent algorithm is sometimes very far from the one generated by FMINUC or Batch gradient descent.</li> <li>while batch gradient descent cost converge when...
https://stackoverflow.com/questions/21352101/is-my-implementation-of-stochastic-gradient-descent-correct
Question: <p>I have a working implementation of multivariable linear regression using gradient descent in R. I'd like to see if I can use what I have to run a stochastic gradient descent. I'm not sure if this is really inefficient or not. For example, for each value of α I want to perform 500 SGD iterations and be able...
https://stackoverflow.com/questions/37485138/stochastic-gradient-descent-from-gradient-descent-implementation-in-r
Question: <p>I got stucked at a point where I am implementing gradient descent in python.</p> <p>The formula for gradient descent is:</p> <pre><code>for iter in range(1, num_iters): hypo_function = np.sum(np.dot(np.dot(theta.T, X)-y, X[:,iter])) theta_0 = theta[0] - alpha * (1.0 / m) * hypo_function thet...
https://stackoverflow.com/questions/32792703/gradient-descent-implementation-in-python
Question: <p>I've implemented both the batch and stochastic gradient descent. I'm experiencing some issues though. This is the stochastic rule:</p> <pre><code>1 to m { theta(j):=theta(j)-step*derivative (for all j) } </code></pre> <p>The issue I have is that, even though the cost function is becoming smaller an...
https://stackoverflow.com/questions/9163801/gradient-descent-implementation
Question: <p>I'm trying to implement "<a href="http://en.wikipedia.org/wiki/Stochastic_gradient_descent" rel="noreferrer">Stochastic gradient descent</a>" in MATLAB. I followed the algorithm exactly but I'm getting a VERY VERY large w (coffients) for the prediction/fitting function. Do I have a mistake in the algorithm...
https://stackoverflow.com/questions/5117337/stochastic-gradient-descent-implementation-matlab
Question: <p>I am trying to implement gradient descent algorithm in Python. When I plot the history of the cost function it seems to be converging but the mean absolute error I get with my implementation is way worse than the one I get from sklearn's <em>linear_model</em>. I couldn't figure out what is wrong with my im...
https://stackoverflow.com/questions/47370541/gradient-descent-implementation-absolute-error-issue
Question: <p>I'm using the below gradient descent implementation in <a href="https://github.com/schneems/Octave/blob/master/mlclass-ex1/gradientDescent.m" rel="nofollow noreferrer">Octave for ML</a>.</p> <p>I tried first to increase number of CPU cores and run Octave multithreaded using OpenBlas but still I didn't get...
https://stackoverflow.com/questions/43411013/is-there-is-a-gradient-descent-implementation-that-uses-matrix-matrix-multiplica
Question: <p>I have tried to implement gradient descent and it was working properly when I tested it on sample dataset but it's not working properly for boston dataset.</p> <p>Can you verify what's wrong with the code. why I'm not getting a correct theta vector?</p> <pre><code>import numpy as np from sklearn.datasets...
https://stackoverflow.com/questions/55210443/gradient-descent-implementation-in-python
Question: <p>I'm looking to run a gradient descent optimization to minimize the cost of an instantiation of variables. My program is very computationally expensive, so I'm looking for a popular library with a fast implementation of GD. What is the recommended library/reference?</p> Answer: <p><a href="http://www.gnu.o...
https://stackoverflow.com/questions/11513926/fast-gradient-descent-implementation-in-a-c-library
Question: <p>I am trying to implement gradient descent in python; the implementation works when I try it with training_set1 but it returns not a number(nan) when I try it training_set. Any idea why my code is broken?</p> <pre><code>from collections import namedtuple TrainingInstance = namedtuple("TrainingInstance", [...
https://stackoverflow.com/questions/15211715/gradient-descent-implementation-in-python-returns-nan
Question: <p>I have tried to implement gradient descent myself using Python. I know there are similar topics on this, but for my attempt, my guess slope can always get really close to the real slope, but the guess intercept never matched or even come close to the real intercept. Does anyone know why is that happening?<...
https://stackoverflow.com/questions/63094866/pure-python-implementation-of-gradient-descent
Question: <p>I am trying to Implement <strong>gradient Descent</strong> algorithm from scratch to find the slope and intercept value for my linear fit line.</p> <p>Using the package and calculating slope and intercept, I get slope = 0.04 and intercept = 7.2 but when I use my gradient descent algorithm for the same pro...
https://stackoverflow.com/questions/47189943/gradient-descent-implementation-is-not-working-in-julia
Question: <p>When reading an tensorflow implementation for a deep learning model, I am trying to understand the following code segment included in the training process. </p> <pre><code>self.net.gradients_node = tf.gradients(loss, self.variables) for epoch in range(epochs): total_loss = 0 for st...
https://stackoverflow.com/questions/40367514/mini-batch-gradient-descent-implementation-in-tensorflow
Question: <p>I'm trying to implement a gradient descent in Go. My goal is to predict the cost of a car from it's mileage. Here is my data set:</p> <pre><code>km,price 240000,3650 139800,3800 150500,4400 185530,4450 176000,5250 114800,5350 166800,5800 89000,5990 144500,5999 84000,6200 82029,6390 63060,6390 74000,6600 9...
https://stackoverflow.com/questions/58833048/implementing-a-gradient-descent
Question: <p>I've actually been struggling against this for like 2 months now. What is it that makes these different? </p> <pre><code>hypotheses= X * theta temp=(hypotheses-y)' temp=X(:,1) * temp temp=temp * (1 / m) temp=temp * alpha theta(1)=theta(1)-temp hypotheses= X * theta temp=(hypotheses-y)' temp=temp * (1 / ...
https://stackoverflow.com/questions/10591343/gradient-descent-implementation-in-octave
Question: <p>I am totally new to ML and python, Read linear regression and tried to implement gradient descent </p> <p>first, Could anyone please let me know what wrong I am doing?</p> <p>Input Data - </p> <pre><code> x = np.array([1,2,3,4,5,6]) y = (2*x + 5) + np.random.normal(0, 1, len(x)) curve = pd.D...
https://stackoverflow.com/questions/61714403/tried-implementing-gradient-descent
Question: <p>I am trying implemented batch gradient descent in C language. The problem is, my cost function increases dramatically in every turn and I am not able to understand what is wrong. I checked my code several times and it seems to me that I coded exactly the formulas. Do you have any suggestions or ideas what ...
https://stackoverflow.com/questions/23576301/cost-function-not-decreasing-in-gradient-descent-implementation
Question: <p>I have a problem with simple implemenation of Gradient Descent algorithm - I wrote the following code, just turning the math of GD into a matlab code, but it does not converge. Due to the simplicity of this implementation, I think the I'm missing here very crucial thing about wroking with Matlab.</p> <p>...
https://stackoverflow.com/questions/56115458/implementation-of-gradient-descent-matlab
Question: <p>I have to implement stochastic gradient descent using python numpy library. For that purpose I'm given the following function definitions:</p> <pre><code>def compute_stoch_gradient(y, tx, w): """Compute a stochastic gradient for batch data.""" def stochastic_gradient_descent( y, tx, initial_w...
https://stackoverflow.com/questions/39975050/stochastic-gradient-descent-implementation-with-pythons-numpy
Question: <p>Hi I am working on implementing gradient descent with backtracking line search. However when I try to update f(x0) the value doesn't change. Could it be something going on with the lambda expression, I am not too familiar with them?</p> <pre><code>import numpy as np import math alpha = 0.1 beta = 0.6 f = ...
https://stackoverflow.com/questions/66874237/having-trouble-making-update-in-gradient-descent-implementation
Question: <p>I'm attempting to apply a gradient descent implementation in Scala and breeze based on Octave from : <a href="https://stackoverflow.com/questions/10591343/gradient-descent-implementation-in-octave">Gradient Descent implementation in octave</a> </p> <p>The octave code I'm attempting to re-write is :</p> <...
https://stackoverflow.com/questions/37624288/implementing-gradient-descent-with-scala-and-breeze-error-could-not-find-imp
Question: <p>I've run into some problems while trying to implement Stochastic Gradient Descent, and basically what is happening is that my cost is growing like crazy and I don't have a clue why.</p> <p>MSE implementation:</p> <pre><code>def mse(x,y,w,b): predictions = x @ w summed = (np.square(y - predictions ...
https://stackoverflow.com/questions/64791138/why-im-getting-a-huge-cost-in-stochastic-gradient-descent-implementation
Question: <p>I am taking <a href="https://www.coursera.org/learn/ml-regression" rel="nofollow noreferrer">this Coursera class</a> on machine learning / linear regression. Here is how they describe the gradient descent algorithm for solving for the estimated OLS coefficients:</p> <p><a href="https://i.sstatic.net/QB9T...
https://stackoverflow.com/questions/41150457/issue-with-gradient-descent-implementation-of-linear-regression
Question: <p>In stochastic gradient descent, we often consider the objective function as a sum of a finite number of functions: </p> <pre><code> f(x)=∑fi(x) where i = 1 : n </code></pre> <p>At each iteration, rather than computing the gradient <code>∇f(x)</code>, stochastic gradient descent randomly sampl...
https://stackoverflow.com/questions/55880425/how-to-implement-stochastic-gradient-descent
Question: <p>As a self study exercise I am trying to implement gradient descent on a linear regression problem from scratch and plot the resulting iterations on a contour plot. </p> <p>My gradient descent implementation gives the correct result (tested with Sklearn) however the gradient descent plot doesn't seem to be...
https://stackoverflow.com/questions/50723432/gradient-descent-impementation-python-contour-lines
Question: <p>I've been trying to refresh my fundamental knowledge of stats, so I tried to implement simple linear regression in python using gradient descent.</p> <p>The code correctly minimizes the MSE, however it does so by making a straight horizontal line across the dataset <a href="https://i.sstatic.net/6lR4c.png"...
https://stackoverflow.com/questions/69071325/what-is-wrong-with-my-gradient-descent-implementation-for-linear-regression-in-p
Question: <p>I started with simple implementation of single variable linear gradient descent but don't know to extend it to multivariate stochastic gradient descent algorithm ?</p> <p>Single variable linear regression </p> <pre><code>import tensorflow as tf import numpy as np # create random data x_data = np.random....
https://stackoverflow.com/questions/36031324/how-to-implement-multivariate-linear-stochastic-gradient-descent-algorithm-in-te
Question: <p>I'm trying to implement a linear regression with gradient descent as explained in this article (<a href="https://towardsdatascience.com/linear-regression-using-gradient-descent-97a6c8700931" rel="nofollow noreferrer">https://towardsdatascience.com/linear-regression-using-gradient-descent-97a6c8700931</a>)....
https://stackoverflow.com/questions/58996556/implementing-a-linear-regression-using-gradient-descent
Question: <p>I implemented stochastic gradient descent algorithm matlab but unable to get proper result. First, I shuffled the training set and update each weight using one sample at a time. Is there any mistake ?</p> <pre><code>function [theta, J] = gradientdescent(x, y,theta,alpha,epochs) m = length(y); J = zeros(...
https://stackoverflow.com/questions/43016224/stochastic-gradient-descent-algorithm-implementation-in-matlab
Question: <p>I'm implementing gradient descent from scratch and I've got a segment of code which is giving me trouble.</p> <pre><code>temp = theta_new[j] theta_new[j] = theta_new[j] - alpha*deriv theta_old[j] = temp </code></pre> <p>It's not changing <code>theta_new[j]</code>. If I print <code>theta_new[j]</code> jus...
https://stackoverflow.com/questions/46555883/issue-implementing-gradient-descent
Question: <p>I am trying to implement gradient descent in octave for function having multiple theta value . Do you have any sample so?</p> Answer: <p>It was already answered in other question 4 years ago: <a href="https://stackoverflow.com/questions/10591343/gradient-descent-implementation-in-octave">Gradient Descent ...
https://stackoverflow.com/questions/38341783/vector-implementation-of-gradient-descent-with-multiple-theta
Question: <p>I have just started to learn deep learning. I found myself stuck when it came to gradient descent. I know how to implement batch gradient descent. I know how it works as well how mini-batch and stochastic gradient descent works in theory. But really can't understand how to implement in code.</p> <pre><cod...
https://stackoverflow.com/questions/38157972/how-to-implement-mini-batch-gradient-descent-in-python
Question: <p>everyone. I have a question about the implement of gradient descent. I have found several optimizers, like ada_grad, adam, sgd and so on, they're perfect. But I'm attempting to implement the naive gradient method batch gradient descent that is with the fix learning rate and acts on the whole examples in ea...
https://stackoverflow.com/questions/45562063/how-to-implement-naive-batch-gradient-descent