A list of puns related to "Euler method"
So it's been years since I've done partial and total derivation, and I can't afford Mathematica. I've already asked on Stackexchange to no avail and i'd like to get through this problem rather quickly since this is just the start of a larger problem I'm working on.
Any help would be greatly appreciated.
In a class I have we need to write a script to run the Backward (Implicit) Euler method. It’s an implicit method so need to calculate Y at the next iteration, and we use Newtons method for that. However, the equations look like they solve the same thing (I.e. the value of Y at the next iteration). Have I missed something? What’s the point in using Backward Euler if Newtons method already finds the next iteration? (I guess this would go for any implicit method…) TIA for any advice!
And what are its strengths and shortcomings?
Hi all! I am doing this problem and don’t understand how I would apply Euler to this. Would I:
Put the 4 in the x’s and re iterate 0.3 every time?
Please help!
Hi, does anyone have an old copy of their Matlab Work for the Euler’s Method assignment for Differential Equations? Goodman doesn’t have enough supplemental material to work off of.
So earlier today, I made a wave equation simulation, but it seems to gain energy from nowhere. to investigate that, I made an SHM oscillator, and it also gains energy and deviates from the true solution. So my question is, why is that?
Since there's no way to get the velocity's formula and the other variables' using LaPlace or separating variables I've used this loop to approximate it.
Here's the script:
from sympy import *
v,t,w,s = symbols('v t w s')
m,g,u,k,a = symbols("m g u k a")
m = 80
w = 10
g = 9.807
u = 0.02
k = (0.430.2551.01178)/2
a = N(pi/4)
acc = gsin(a)-ugcos(a)-(k/m)(v+w)**2
how_long = 0
delta_time = 0.001
steps = int(how_long/delta_time)
pos = 0
vel = 0
for i in range(steps):
vel += acc.subs(v,vel) * delta_time
pos += vel * delta_time
ac = gsin(a)-ugcos(a)-(k/m)(vel+w)**2
expr= 'm/s\N{SUPERSCRIPT TWO}'
print("a = "+str(ac)+expr)
print("v = "+str(vel)+" m/s")
print("s = "+str(pos)+" m")
print("t = "+str(how_long)+" s")
"w" is the wind's velocity which is constant, "u" is the coefficient of friction, "a" is the angle of the slope, "k" is just the drag coeff. times the projected area of the moving object times the air's density over 2. "how_long" is the final time and "delta_time" is the steps' size.
As you can see the acceleration's equation consists of a differential equation in which the acceleration is the moving object's velocity derivative with respect to time (dv/dt) and the velocity of the moving object is also included in the air drag [(k/m)(v+w)²].
Hello! i'm trying to follow the course on Neural Computation at MIT (https://ocw.mit.edu/courses/brain-and-cognitive-sciences/9-40-introduction-to-neural-computation-spring-2018/index.htm) but as a psychology student i'm struggling with the math and the programming - not discouraged though, just need some assistance!
There's something entirely wrong with the program i've written, or the values i've calculated, so here's all the steps i've done (you can skip to the code, the first part is just calculating values - i just added it in case, maybe the error is done at this early stage, even though i checked it several times).
Calculating values (more physics than code):
Given a "neuron" which is a perfect sphere, with the radius of 0.06mm, a specific membrane capacitance (cm - c for capacitance, m for membrane) 10nF/mm^(2), a specific membrane conductance (gm - g for conductance) of 1 μS/mm^(2), calculate total membrane conductance and total membrane capacitance.
I get these values: total membrane conductance = 0.045 μS
total membrane capacitance = 0.45 nF
and from the conductance i calculate the resistance (1/0.45μS)= 22.22 m ℧
The lecturer emphasizes:
a. You set the cell’s capacitance, resistance, and resting potential (using the values calculated and defined above).
b. You set the initial condition V0 (i.e. V(t=0)) to V0 = Vrest and the current injected Ie to 100 pA starting at 100ms and finishing at 200 ms.
c. Your code updates V(t) at every time step using the exponential Euler method.
Matlab code:
%Cell Parameters
C = 0.45; % Capacitance in nF
R = 2.222e-11; % Resistance in MegaOhm
Vrest = -70; % Leakage current reversal potential in mV
% Integration parameters
dt = 0.1; % integration time-step in ms
Tdur = 1000; % simulation total time in ms
V0 = Vrest; % initial condition in mV
k = ceil(Tdur/dt); % total number of iterations
V = zeros(1,k+1); % Voltage vector in mV
V(1)=V0; % assigned to the first element of array V, the initial condition V0
% time vector
t = dt.*(0:k); % time vector in ms
% Current pulse parameters
Tstart = 100; % curent pulse start time in ms
Tstop = 200; % curent pulse stop time in ms
Iamplitude = 0.1; % current pulse amplitude in nA
I = zeros(1,k+1);
... keep reading on reddit ➡Hi,
I have been experimenting a bit with an explicit and implicit Euler's methods to solve a simple heat transfer partial differential equation:
∂T/∂t = alpha * (∂^2T/∂x^2)
T = temperature, x = axial dimension. The initial condition I used is for x = 0, T = 100 °C. And the boundary condition at the end of the computational grid: for T**(x = L) =** T**(x=*****L-***1), where L is a length of the computational grid -> the last and the and next-to-last values of temperature are the same.
Would some be willing to look at my code (I am not a MATLAB guy, but I try to learn) whether my implementation of implicit method is correct.
My thoughts:
Explicit method (works fine): Every values of T are calculated by T1(i) + heat_coefficient*((T1(i+1)-2*T1(i)+T1(i-1))/dx^2)*dt
, except for the first and the last value which are specified by the I.C. and B.C., respectively.
My question:
Implicit method: At first, I create a tri-diagonal matrix MAT
, which defines a relationship between the values in the next time line (n+1). In the case of an implicit method, I cannot write I.C. and B.C. exactly, and therefore I save them on the “Right side of the equation”, i.e. pS(i) = -(T2(i)*dx^2)/(heat_coefficient*dt)
;
By this, I express all the values in one time line (n) and after that, I continue in the following time line (n+1).
If I put I.C. or B.C. into the “Right side of the equation”, the results become very sensitive to any change of positional (dx) and time (dt) step. Behavior of the temperature function is therefore wrong: the curves of a temperature should converge to the same values after certain time (if the time goes to infinity), however, my curves converge to a different values (and randomly change based on dx and dt).
How do I achieve to start at a temperature of 100 °C, such that after an “infinitely” long time, all of the temperature curves converge to 100 °C?
Should the values of I.C. and B.C. be put into a tri-diagonal matrix - e.g., if I have matrix with dimensions [N,N], then I specify I.C. for point [1,1], and B.C. for point [N,N]? (Unfortunately, it did not work properly when I tried)
Also, my implementation of the tri-diagonal matrix is probably not very nice, but it works.
Is Heun's method always better (as in more accurate) than Euler's method in solving ODEs or are there pathological counter examples? I am assuming that all derivatives are smooth at least within the region of integration. The reason I question this is because Heun's method computes only an estimate of the derivative at x(n+1) = xn+h because it has to estimate y(xn+h) also when y' = f(x,y) so I got to wondering how could Heun know that his estimated derivative was always a better derivative. If it's not always a better derivative estimate then what would the conditions be?
Looks like I have another rookie question.
I was taking another look at eulers method and it looks like it consistent undershoots the solution when evaluation y'=y. I decided if I evaluation the slope of y from y' one step ahead it should consistently overshoot the solution but that's not what is happening. It seems to follow the graph more closely but also ends up undershooting in the end.
I am trying to evaluation y(xn+h) = yn + h * f(xn) as the standard euler solution where f(xn) = y'(xn)
and then I modified it to be: y(xn+h) = yn + h * f(xn + h) where f(xn+h) = y'(xn+h) = y(xn)+h which should consistently overshoot the function but it does not.
Any ideas why?
From my understanding, both are used to approximate a solution to a function without explicitly working out. Newtons method work will most basic functions and Euler's method is used only for differential equations. (Is this true? Can Euler's method work for other equations as well?
And Finally, is there a difference in their methods? When I search on Wikia, they seem the same to me (or at least very similar)
Suppose f(x) is the solution to the differential equation dy/dx= 3x-2y with boundary condition f(1)=5. What is the approximation for f(1.2) using eulers method starting at x=1 and using 2 steps of equal size?
Greetings fellow programmers. Project Euler problem 4 asks for the largest palindrome number which can be made with the product of two 3-digit number. I have managed to solve this with a bit of brute force: The resulting products can only be of length 5 or 6 digits. I have then used some flow control to check the first and last digits and the second and second to last digits etc. to check they are the same, giving a perfectly acceptable solution.
However, it occurred to me that there must be an iterative method I can use to check the values at these indexes, making the code more flexible to include palindromes for numbers of larger lengths. But this method will not yield to me after several days attempts! The problem I am having currently is that my code only checks the first and last digit and then adds this into my palindrome list, regardless of whether the other digits follow this pattern, what I need is for the program to check each pair of numbers, ensure they are 'all' the same and then append to my palindrome list. I've copied my code below:
products = []
for i in range(100,1000):
for j in range(i,1000):
p=i*j
products.append(str(p))
#str required to use len in next code
palindromes = []
for i in products:
for j in range(0,len(i)//2):
if i[j] == i[len(i)-1-j]:
palindromes.append(i)
else:
continue
Help is very much appreciated, this is really frying my noodle and I feel that I am missing something super obvious!
Hi, first-time poster here
I'm a student at HS-level in DK, who has decided to write my annual large scale assignment on Schrödinger's equation. My teacher has only given us a brief introduction to the equation and has tasked us to solve it numerically with Euler's method for the hydrogen atom. He rewrote the equation on to a form I simply cannot seem to find online or anywhere else. My knowledge of using Euler's method for second-order ODEs is very sparse too. I have attached the equation. If someone can please help me understand, how I must use Euler's method on this specific form, I would be very thankful.
Thank you
Oi,
we are doing the Euler's method in our Differential equations class and I wanted to program a Ti-84 Plus CE-T programme for Euler's method, if you know the differential equation, X(0), Y(0), the step (i.e x=0.2) and the number of steps, which would fasten my calculations.
The code is attached below this text. The issue I encountered is, how to enter the differential equation? For example, how do I enter dY/dX=X+2Y? When I wrote the programme below I thought, if I would enter X+2Y
that the expr(Str1)→D
would calculate the expression, where X and Y were specified at the beginning. However, my GDC says that it can't progress beyond expr(Str1)→D
, because 'Variable used is not defined."
What should I change or rather why doesn't my programme work?
Disp "DE Approximator"
Input "dY/dX:",Str1
Input "X(0):",X
Input "Y(0):",Y
Input "Step:",S
Input "Number of steps:",N
N+1→N
A=0
While A<N
expr(Str1)→D
X+S→X
Y+DS→Y
Disp {X,Y}
A+1→A
End
Kind regards
Hello! i'm trying to follow the course on Neural Computation at MIT (https://ocw.mit.edu/courses/brain-and-cognitive-sciences/9-40-introduction-to-neural-computation-spring-2018/index.htm) but as a psychology student i'm struggling with the math and the programming - not discouraged though, just need some assistance!
I've posted a more lengthy description of my problem here: https://www.reddit.com/r/matlab/comments/ngzxve/mit_intro_to_neural_computation_course_2018/
It's part of the first problemset, where I just can't seem to get a sensible model of a simplified neuron, when I plot the voltage - I was hoping maybe someone had an example of a for-loop applying an exponential Euler method to calculate/model the voltage of a simplified neuron (with a resting potential, but no voltage or time dependant ion channels), when injected with current.
Please let me know if you need some more information or a matlab file or similiar, i'm stuck to the point where i'm just gonna move on, and hope that the solution strikes me at some point, helping me realize where I screwed up...
Best regards from Denmark
Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.