Not solving differential equation in terms of inherent variable (subs)

조회 수: 2 (최근 30일)
A
A 2015년 1월 22일
댓글: Star Strider 2015년 1월 22일
I'm trying to solve a differential equation (T) in terms of y. The equation is the product of some functions (u & u_m) which were previously computed and depend on y. However, it keeps giving the output of T in terms of eq, instead of y, even when I use subs. I want the output only in terms of y and b. Here is the code:
syms b1 b2
u = dsolve('D2u = -1', 'u(0) = b1*Du(0)', 'u(1) = -b2*Du(1)', 'y')
u_m = int(u,0,1);
syms bt1 bt2 N
eq = -N*u/u_m;
eq = subs(eq);
T = dsolve('D2T = eq', 'T(0) = bt1*DT(0)', 'T(1) = - bt2*DT(1)', 'y')

답변 (1개)

Star Strider
Star Strider 2015년 1월 22일
The syntax you’re using may be a problem. In R2014b, this code (note the absence of the single quotes, and presence of ‘==’):
syms b1 b2 u(y)
Du = diff(u);
D2u = diff(u,2);
u = dsolve(D2u == -1, u(0) == b1*Du(0), u(1) == -b2*Du(1), y);
u_m = int(u,0,1);
syms bt1 bt2 N T(u)
DT = diff(T);
D2T = diff(T,2);
eq = -N*u/u_m;
eq = subs(eq);
T = dsolve(D2T == eq, T(0) == bt1*DT(0), T(1) == - bt2*DT(1), y);
T = simplify(T, 'steps', 10)
pretty(T)
produces this result:
T =
(2*N*(b1 + b2 + 1)*(bt1 + y + 3*bt1*bt2 + 3*bt2*y - bt1*y^3 - bt2*y^3 - y^3))/((bt1 + bt2 + 1)*(4*b1 + 4*b2 + 12*b1*b2 + 1))
3 3 3
N (b1 + b2 + 1) (bt1 + y + 3 bt1 bt2 + 3 bt2 y - bt1 y - bt2 y - y ) 2
------------------------------------------------------------------------
(bt1 + bt2 + 1) (4 b1 + 4 b2 + 12 b1 b2 + 1)
Is that what you want?
  댓글 수: 2
A
A 2015년 1월 22일
Thank you very much! It is R2014b I'm using.
Can I ask another question? When I go on to do a further calculation to find N in terms of b using T and u, I get the same problem where the system forgets that u, u_m and T depend on y, even when I use subs. What am I doing wrong? (see the u bolded in the answer). Do I have to use subs after everything?
uTu_m = u*T/u_m
uTu_m = subs(uTu_m);
exp_21 = int(uTu_m,0,1)
eqn_21 = exp_21 == 1;
sol_N = solve(eqn_21, N);
simplify(subs(sol_N))
ans = ((bt1 + bt2 + 1)*(4*b1 + 4*b2 + 12*b1*b2 + 1)^2)/(6*( u )*(b1 + b2 + 1)^2*(3*bt1 + 5*bt2 + 12*bt1*bt2 + 1))
Star Strider
Star Strider 2015년 1월 22일
Using subs may be the problem.
I rearranged your code a bit, without altering the individual assignments.
See if this does what you want:
syms b1 b2 u(y) bt1 bt2 N T(u)
Du = diff(u);
D2u = diff(u,2);
u = dsolve(D2u == -1, u(0) == b1*Du(0), u(1) == -b2*Du(1), y);
u_m = int(u,0,1);
DT = diff(T);
D2T = diff(T,2);
eq = -N*u/u_m;
eq = subs(eq);
T = dsolve(D2T == eq, T(0) == bt1*DT(0), T(1) == - bt2*DT(1), y);
T = simplify(T, 'steps', 10)
% pretty(T)
uTu_m = u*T/u_m
exp_21 = int(uTu_m,0,1)
eqn_21 = exp_21 == 1;
sol_N = solve(eqn_21, N);
sol_N_var = symvar(sol_N); % ‘u’ Not Present
sol_N = simplify(sol_N, 'steps', 10)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by