This Script run on Octave platform. The script get input differential equation with initial condition, of the form:
The script return the function y(t).
Download the file simplediff1.m
Download the file simplediff1.m
% simple script to solve
% Symbolic solution for first-order differential equation
% Specify the first-order derivative by using:
% diff and the equation by using ==.
% Then, solve the equation by using dsolve.
% load symbolic package, and initilize PYTHON variable
pkg load symbolic
setenv PYTHON C:\ProgramData\Anaconda3\pythonw.exe
% Define symbolic variables:
% y(t) - function y and argumenr t
% a - parameter
% y0 - initial condition for y(t) - y(0) = y0
syms y(t) a y0 t0
% **** input the equaion here: *****
eqn = diff(y,t) == a*y;
% **** input the initial conditions here: *****
cond = [y(0)==y0];
S = dsolve(eqn, cond)
% Symbolic solution for first-order differential equation
% Specify the first-order derivative by using:
% diff and the equation by using ==.
% Then, solve the equation by using dsolve.
% load symbolic package, and initilize PYTHON variable
pkg load symbolic
setenv PYTHON C:\ProgramData\Anaconda3\pythonw.exe
% Define symbolic variables:
% y(t) - function y and argumenr t
% a - parameter
% y0 - initial condition for y(t) - y(0) = y0
syms y(t) a y0 t0
% **** input the equaion here: *****
eqn = diff(y,t) == a*y;
% **** input the initial conditions here: *****
cond = [y(0)==y0];
S = dsolve(eqn, cond)
Examples 1:
Differential equation with initial condition:
% **** input the equaion here: *****
eqn = diff(y,t) == a*y;
% **** input the initial conditions here: *****
cond = [y(0)==y0];
eqn = diff(y,t) == a*y;
% **** input the initial conditions here: *****
cond = [y(0)==y0];
The solution:
Examples 2:
Differential equation with initial condition:
% **** input the equaion here: *****
eqn = diff(y,t) == a*t*y;
% **** input the initial conditions here: *****
cond = [y(0)==y0];
eqn = diff(y,t) == a*t*y;
% **** input the initial conditions here: *****
cond = [y(0)==y0];
The solution:
No comments:
Post a Comment