satisfying the initial condition y(0) =0

14 views (last 30 days)
aYOUB aLI on 27 Oct 2020
Answered: madhan ravi on 27 Oct 2020
Determine the solution satisfying the initial condition y(0) =0 of the function dy/dx =1/e^(x+y+2) ,

Answers (1)

madhan ravi
madhan ravi on 27 Oct 2020
help ode45
ODE45 Solve non-stiff differential equations, medium order method. [TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0) with TSPAN = [T0 TFINAL] integrates the system of differential equations y' = f(t,y) from time T0 to TFINAL with initial conditions Y0. ODEFUN is a function handle. For a scalar T and a vector Y, ODEFUN(T,Y) must return a column vector corresponding to f(t,y). Each row in the solution array YOUT corresponds to a time returned in the column vector TOUT. To obtain solutions at specific times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN = [T0 T1 ... TFINAL]. [TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS) solves as above with default integration properties replaced by values in OPTIONS, an argument created with the ODESET function. See ODESET for details. Commonly used options are scalar relative error tolerance 'RelTol' (1e-3 by default) and vector of absolute error tolerances 'AbsTol' (all components 1e-6 by default). If certain components of the solution must be non-negative, use ODESET to set the 'NonNegative' property to the indices of these components. ODE45 can solve problems M(t,y)*y' = f(t,y) with mass matrix M that is nonsingular. Use ODESET to set the 'Mass' property to a function handle MASS if MASS(T,Y) returns the value of the mass matrix. If the mass matrix is constant, the matrix can be used as the value of the 'Mass' option. If the mass matrix does not depend on the state variable Y and the function MASS is to be called with one input argument T, set 'MStateDependence' to 'none'. ODE15S and ODE23T can solve problems with singular mass matrices. [TOUT,YOUT,TE,YE,IE] = ODE45(ODEFUN,TSPAN,Y0,OPTIONS) with the 'Events' property in OPTIONS set to a function handle EVENTS, solves as above while also finding where functions of (T,Y), called event functions, are zero. For each function you specify whether the integration is to terminate at a zero and whether the direction of the zero crossing matters. These are the three column vectors returned by EVENTS: [VALUE,ISTERMINAL,DIRECTION] = EVENTS(T,Y). For the I-th event function: VALUE(I) is the value of the function, ISTERMINAL(I)=1 if the integration is to terminate at a zero of this event function and 0 otherwise. DIRECTION(I)=0 if all zeros are to be computed (the default), +1 if only zeros where the event function is increasing, and -1 if only zeros where the event function is decreasing. Output TE is a column vector of times at which events occur. Rows of YE are the corresponding solutions, and indices in vector IE specify which event occurred. SOL = ODE45(ODEFUN,[T0 TFINAL],Y0...) returns a structure that can be used with DEVAL to evaluate the solution or its first derivative at any point between T0 and TFINAL. The steps chosen by ODE45 are returned in a row vector SOL.x. For each I, the column SOL.y(:,I) contains the solution at SOL.x(I). If events were detected, SOL.xe is a row vector of points at which events occurred. Columns of are the corresponding solutions, and indices in vector specify which event occurred. Example [t,y]=ode45(@vdp1,[0 20],[2 0]); plot(t,y(:,1)); solves the system y' = vdp1(t,y), using the default relative error tolerance 1e-3 and the default absolute tolerance of 1e-6 for each component, and plots the first component of the solution. Class support for inputs TSPAN, Y0, and the result of ODEFUN(T,Y): float: double, single See also ODE23, ODE113, ODE15S, ODE23S, ODE23T, ODE23TB, ODE15I, ODESET, ODEPLOT, ODEPHAS2, ODEPHAS3, ODEPRINT, DEVAL, ODEEXAMPLES, RIGIDODE, BALLODE, ORBITODE, FUNCTION_HANDLE. Documentation for ode45 doc ode45
help dsolve
DSOLVE Symbolic solution of ordinary differential equations. DSOLVE will not accept equations as strings in a future release. Use symbolic expressions or sym objects instead. For example, use syms y(t); dsolve(diff(y)==y) instead of dsolve('Dy=y'). DSOLVE(eqn1,eqn2, ...) accepts symbolic equations representing ordinary differential equations and initial conditions. By default, the independent variable is 't'. The independent variable may be changed from 't' to some other symbolic variable by including that variable as the last input argument. The DIFF function constructs derivatives of symbolic functions (see sym/symfun). Initial conditions involving derivatives must use an intermediate variable. For example, syms x(t) Dx = diff(x); dsolve(diff(Dx) == -x, Dx(0) == 1) If the number of initial conditions given is less than the number of dependent variables, the resulting solutions will obtain arbitrary constants, C1, C2, etc. Three different types of output are possible. For one equation and one output, the resulting solution is returned, with multiple solutions to a nonlinear equation in a symbolic vector. For several equations and an equal number of outputs, the results are sorted in lexicographic order and assigned to the outputs. For several equations and a single output, a structure containing the solutions is returned. If no closed-form (explicit) solution is found, then a warning is given and the empty sym is returned. DSOLVE(...,'IgnoreAnalyticConstraints',VAL) controls the level of mathematical rigor to use on the analytical constraints of the solution (branch cuts, division by zero, etc). The options for VAL are TRUE or FALSE. Specify FALSE to use the highest level of mathematical rigor in finding any solutions. The default is TRUE. DSOLVE(...,'MaxDegree',n) controls the maximum degree of polynomials for which explicit formulas will be used in SOLVE calls during the computation. n must be a positive integer smaller than 5. The default is 2. DSOLVE(...,'Implicit',true) returns the solution as a vector of equations, relating the dependent and the independent variable. This option is not allowed for systems of differential equations. DSOLVE(...,'ExpansionPoint',a) returns the solution as a series around the expansion point a. DSOLVE(...,'Order',n) returns the solution as a series with order n-1. Examples: % Example 1 syms x(t) a dsolve(diff(x) == -a*x) returns ans = C1/exp(a*t) % Example 2: changing the independent variable x = dsolve(diff(x) == -a*x, x(0) == 1, 's') returns x = 1/exp(a*s) syms x(s) a x = dsolve(diff(x) == -a*x, x(0) == 1) returns x = 1/exp(a*s) % Example 3: solving systems of ODEs syms f(t) g(t) S = dsolve(diff(f) == f + g, diff(g) == -f + g,f(0) == 1,g(0) == 2) returns a structure S with fields S.f = (i + 1/2)/exp(t*(i - 1)) - exp(t*(i + 1))*(i - 1/2) S.g = exp(t*(i + 1))*(i/2 + 1) - (i/2 - 1)/exp(t*(i - 1)) syms f(t) g(t) v = [f;g]; A = [1 1; -1 1]; S = dsolve(diff(v) == A*v, v(0) == [1;2]) returns a structure S with fields S.f = exp(t)*cos(t) + 2*exp(t)*sin(t) S.g = 2*exp(t)*cos(t) - exp(t)*sin(t) % Example 3: using options syms y(t) dsolve(sqrt(diff(y))==y) returns ans = 0 syms y(t) dsolve(sqrt(diff(y))==y, 'IgnoreAnalyticConstraints', false) warns Warning: The solutions are subject to the following conditions: (C67 + t)*(1/(C67 + t)^2)^(1/2) = -1 and returns ans = -1/(C67 + t) % Example 4: Higher order systems syms y(t) a Dy = diff(y); D2y = diff(y,2); dsolve(D2y == -a^2*y, y(0) == 1, Dy(pi/a) == 0) syms w(t) Dw = diff(w); D2w = diff(w,2); w = dsolve(diff(D2w) == -w, w(0)==1, Dw(0)==0, D2w(0)==0) See also SOLVE, SUBS, SYM/DIFF, odeToVectorfield. Documentation for dsolve doc dsolve


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by