numerical-methods

C Code Wavelet Transform and Explanation

耗尽温柔 提交于 2020-04-30 06:14:05
问题 I am trying to implement a wavelet transform in C and I have never done it before. I have read some about Wavelets, and understand the 'growing subspaces' idea, and how Mallat's one sided filter bank is essentially the same idea. However, I am stuck on how to actually implement Mallat's fast wavelet transform. This is what I understand so far: The high pass filter, h(t), gives you the detail coefficients. For a given scale j, it is a reflected, dilated, and normed version of the mother

SIR model using fsolve and Euler 3BDF

可紊 提交于 2020-04-30 05:44:46
问题 Hi i've been asked to solve SIR model using fsolve command in MATLAB, and Euler 3 point backward. I'm really confused on how to proceed, please help. This is what i have so far. I created a function for 3BDF scheme but i'm not sure how to proceed with fsolve and solve the system of nonlinear ODEs. The SIR model is shown as and 3BDF scheme is formulated as clc clear all gamma=1/7; beta=1/3; ode1= @(R,S,I) -(beta*I*S)/(S+I+R); ode2= @(R,S,I) (beta*I*S)/(S+I+R)-I*gamma; ode3= @(I) gamma*I; f(t,

Error in code, a method to compute sqrt (a)

六眼飞鱼酱① 提交于 2020-04-17 22:12:15
问题 One of the methods to compute sqrt(a), a>0 is X(n+1) = (a + (X(n)*X(n-1))/(X(n)+X(n-1)), n = 1, 2, …, with X0=1 and X1=a (That is, it is known that lim n-> infin of Xn = sqrt(a) Write a function [sqa, nitr] = mySqrt(a) which implements this calculation. The function should use a while-loop, terminate when the difference between Xn+1 and Xn becomes smaller than eps(10*a) , and output Xn+1 in sqa and the value of n at which the while-loop was terminated in nitr . Test your function for a =

Error in code, a method to compute sqrt (a)

本秂侑毒 提交于 2020-04-17 22:10:49
问题 One of the methods to compute sqrt(a), a>0 is X(n+1) = (a + (X(n)*X(n-1))/(X(n)+X(n-1)), n = 1, 2, …, with X0=1 and X1=a (That is, it is known that lim n-> infin of Xn = sqrt(a) Write a function [sqa, nitr] = mySqrt(a) which implements this calculation. The function should use a while-loop, terminate when the difference between Xn+1 and Xn becomes smaller than eps(10*a) , and output Xn+1 in sqa and the value of n at which the while-loop was terminated in nitr . Test your function for a =

Matlab Euler Explicit ode solver with adaptable step, is there a way to make code faster?

泄露秘密 提交于 2020-01-24 00:39:32
问题 I am trying to find a way to make this code faster. Nagumo1 is the function that calculates the value of the two derivatives at time t. function x = nagumo(t, y, f) Iapp = f(t); e = 0.1; F = 2/(1+exp(-5*y(1))); n0 = 0; x = zeros(2, 1); z(1) = y(1) - (y(1).^3)/3 - y(2).^2 + Iapp; %z(1) = dV/dt z(2) = e.*(F + n0 - y(2)); %z(2) = dn/dt x = [z(1);z(2)]; end It is a system of differential equations that represents a largely simplified model of neuron. V represents a difference of electric

Constructing a Multidimensional Differentiation Matrix

元气小坏坏 提交于 2020-01-23 17:56:05
问题 I have been trying to construct the matrix D ij , defined as I want to plot it for points located at x i = -cos[ π (2 i + 1) / (2 N )] on the interval [-1,1] to consequentially take derivatives of a function. I am though having problems constructing the differentiating matrix D ij . I have written a python script as: import numpy as np N = 100 x = np.linspace(-1,1,N-1) for i in range(0, N - 1): x[i] = -np.cos(np.pi*(2*i + 1)/2*N) def Dmatrix(x,N): m_ij = np.zeros(3) for k in range(len(x)):

How can I use numpy.correlate to do autocorrelation?

北战南征 提交于 2020-01-18 05:47:05
问题 I need to do auto-correlation of a set of numbers, which as I understand it is just the correlation of the set with itself. I've tried it using numpy's correlate function, but I don't believe the result, as it almost always gives a vector where the first number is not the largest, as it ought to be. So, this question is really two questions: What exactly is numpy.correlate doing? How can I use it (or something else) to do auto-correlation? 回答1: To answer your first question, numpy.correlate(a

octave error undefined near line 1 column 1

北战南征 提交于 2020-01-16 14:37:34
问题 I try to read a matrix from a file. The code is very simple function [mat] = read(file) mat = load(file_points) But when I try to run it read('file') mat = scalar structure containing the fields: mat = 3 4 6 3 5 1 it shows the matrix, but when I run this command... >>mat(1,1) error: 'points' undefined near line 1 column 1 回答1: From Octave Forge about load() If invoked with a single output argument, Octave returns data instead of inserting variables in the symbol table. If the data file

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