Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122124012
ForwardEulerSolver.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jul 15, 22:46
Size
759 B
Mime Type
text/x-c
Expires
Thu, Jul 17, 22:46 (2 d)
Engine
blob
Format
Raw Data
Handle
27437593
Attached To
R1106 Programming Concept Rouaze
ForwardEulerSolver.cpp
View Options
/*
* ForwardEulerSolver.cpp
*
* Created on: Oct 25, 2012
* Author: rpopescu
*/
#include "ForwardEulerSolver.hpp"
#include <cmath>
ForwardEulerSolver::ForwardEulerSolver()
{}
ForwardEulerSolver::~ForwardEulerSolver()
{}
void ForwardEulerSolver::SolveEquation(std::ostream& stream)
{
double y_prev = GetInitialValue();
double y_next;
double t_prev = GetInitialTime();
double t_next;
double h = GetStepSize();
int n = static_cast<int>(
std::floor((GetFinalTime() - GetInitialTime()) / h));
stream << t_prev << " " << y_prev << "\n";
for (int i = 1; i <= n; ++i) {
y_next = y_prev + h * RightHandSide(y_prev, t_prev);
t_next = t_prev + h;
stream << t_next << " " << y_next << "\n";
y_prev = y_next;
t_prev = t_next;
}
}
Event Timeline
Log In to Comment