mehdi jafari

769 Reputation

13 Badges

11 years, 270 days

MaplePrimes Activity


These are replies submitted by mehdi jafari

put your data on a maple worksheet,upload the worksheet,and ask your question in mathematical form,so that one can help u more efficiently,good luck on your work.

@mehran rajabi i have experience sth similar,it was solved by setting maxfun option to 0, but after some time i realized that my system of equations was incorrect or boundary conditions was not inserted correctly .

maybe u want also check both . good luck !

maybe you want to use dsolve,numeric , and choose one of the methods told in maple help :

The dsolve command with the numeric or type=numeric option finds a numerical solution for the ODE or ODE system. If the optional equation method=numericmethod is provided (where numericmethod is one of rkf45, ck45, rosenbrock, bvp, rkf45_dae, ck45_dae, rosenbrock_dae, dverk78, lsode, gear, taylorseries, mebdfi, or classical), dsolve uses that method to obtain the numerical solution.
Both initial and boundary value problems can be numerically solved, as well as initial differential algebraic problems. For a system input, the type of problem is automatically detected, but for some DAE problems it may be necessary to specify the method.
By default, a procedure is returned that can be used to obtain solution values if given the value of the independent variable.

see more ?dsolve .

for solving system of nonlinear equation,use fsolve ,

The fsolve command numerically solves one or more equations for their unknowns.

for more see ?fsolve . 
u can also upload your worksheet here to see how a system of nonlinear ODE system can be solved using dsolve

@Markiyan Hirnyk i said if there is a prize for the first one ! it is for sure that we are here to help and learn not more ! tnx

@Markiyan Hirnyk actually it seems some users have multiple accounts ! i do not know what is the benefit of having more grades here !!!!! ... is any prize for the first one ?! if there is and we do not know ! maybe we should have some accounts too !

i think there is some mistakes,maybe you have forgot to change all the varibales in your worksheet.

@jamunoz please upload yoyr original question here,it will be solved,be sure .

@Markiyan Hirnyk i think u misunderstand the problem ?!

please not that we do not have sys[jj] ,  BTCS_general, ! what are they ?!

@sarra but i re-execute it,it is alwasy fixed !  and as u can see,it does not depent on u[i,j]'s !

NULL

restart; with(PDEtools):Digits:=50:
with(LinearAlgebra):with(plots):
 interface(rtablesize = 20):

laplace := 3*diff(u(x, y), x, x)+2*diff(u(x, y), y, y) = f(x, y);

3*(diff(diff(u(x, y), x), x))+2*(diff(diff(u(x, y), y), y)) = f(x, y)

(1)

centered_stencil := proc (r, N, { direction := x }) local n, stencil, vars, beta_sol; n := floor((1/2)*N); if direction = y then stencil := (D[`$`(2, r)](u))(x, y)-add(beta[i]*u(x, y+i*h), i = -n .. n); vars := [u(x, y), seq((D[`$`(2, i)](u))(x, y), i = 1 .. N-1)] else stencil := (D[`$`(1, r)](u))(x, y)-add(beta[i]*u(x+i*h, y), i = -n .. n); vars := [u(x, y), seq((D[`$`(1, i)](u))(x, y), i = 1 .. N-1)] end if; beta_sol := solve([coeffs(collect(convert(series(stencil, h, N), polynom), vars, 'distributed'), vars)]); stencil := subs(beta_sol, stencil); convert(stencil = convert(series(stencil, h, N), polynom), diff) end proc; x_stencil := isolate(lhs(centered_stencil(2, 3, direction = x)), diff(u(x, y), x, x)); y_stencil := isolate(lhs(centered_stencil(2, 3, direction = y)), diff(u(x, y), y, y)); laplace_stencil := subs(x_stencil, y_stencil, laplace);

proc (r, N, { direction := x }) local n, stencil, vars, beta_sol; n := floor((1/2)*N); if direction = y then stencil := (D[`$`(2, r)](u))(x, y)-add(beta[i]*u(x, h*i+y), i = -n .. n); vars := [u(x, y), seq((D[`$`(2, i)](u))(x, y), i = 1 .. N-1)] else stencil := (D[`$`(1, r)](u))(x, y)-add(beta[i]*u(h*i+x, y), i = -n .. n); vars := [u(x, y), seq((D[`$`(1, i)](u))(x, y), i = 1 .. N-1)] end if; beta_sol := solve([coeffs(collect(convert(series(stencil, h, N), polynom), vars, 'distributed'), vars)]); stencil := subs(beta_sol, stencil); convert(stencil = convert(series(stencil, h, N), polynom), diff) end proc

 

diff(diff(u(x, y), x), x) = u(-h+x, y)/h^2-2*u(x, y)/h^2+u(h+x, y)/h^2

 

diff(diff(u(x, y), y), y) = u(x, -h+y)/h^2-2*u(x, y)/h^2+u(x, h+y)/h^2

 

3*u(-h+x, y)/h^2-10*u(x, y)/h^2+3*u(h+x, y)/h^2+2*u(x, -h+y)/h^2+2*u(x, h+y)/h^2 = f(x, y)

(2)

laplace_stencil := expand(laplace_stencil*h^2);

3*u(-h+x, y)-10*u(x, y)+3*u(h+x, y)+2*u(x, -h+y)+2*u(x, h+y) = h^2*f(x, y)

(3)

Subs := [seq(seq(u(x+jj*h, y+ii*h) = u[i+ii, j+jj], ii = -1 .. 1), jj = -1 .. 1), seq(seq(f(x+jj*h, y+ii*h) = f[i+ii, j+jj], ii = 0 .. 0), jj = 0 .. 0)];

[u(-h+x, -h+y) = u[i-1, j-1], u(-h+x, y) = u[i, j-1], u(-h+x, h+y) = u[i+1, j-1], u(x, -h+y) = u[i-1, j], u(x, y) = u[i, j], u(x, h+y) = u[i+1, j], u(h+x, -h+y) = u[i-1, j+1], u(h+x, y) = u[i, j+1], u(h+x, h+y) = u[i+1, j+1], f(x, y) = f[i, j]]

(4)

laplace_stencil := subs(Subs, laplace_stencil);

3*u[i, j-1]-10*u[i, j]+3*u[i, j+1]+2*u[i-1, j]+2*u[i+1, j] = h^2*f[i, j]

(5)

isolate(laplace_stencil, u[i, j]);

u[i, j] = -(1/10)*h^2*f[i, j]+(3/10)*u[i, j-1]+(3/10)*u[i, j+1]+(1/5)*u[i-1, j]+(1/5)*u[i+1, j]

(6)

M := 2; N := 2; p1 := plot([seq(seq([j, i], j = 0 .. M), i = 0 .. N)], view = [-1 .. M+2, 0 .. N+1], style = point, symbolsize = 20, symbol = circle, axes = boxed); p2 := textplot([seq(seq([j+.1, i, u[i, j] = X[(i-1)*(M+1)+j]], j = 0 .. M), i = 1 .. N)], align = [right, below], color = red); p3 := plot([seq([-1, i], i = 1 .. N), seq([M+1, i], i = 1 .. N), seq([i, 0], i = 0 .. M), seq([i, N+1], i = 0 .. M)], view = [-2 .. M+4, -2 .. N+3], style = point, symbolsize = 20, symbol = circle, axes = boxed, color = blue); p4 := textplot([seq([(-1)+.1, i, u[i, -1]], i = 1 .. N), seq([M+1+.1, i, u[i, M+1]], i = 1 .. N), seq([i+.1, 0, u[0, i]], i = 0 .. M), seq([i+.1, N+1, u[N+1, i]], i = 0 .. M)], align = [right, below], color = blue); display([p1, p2, p3, p4]);

2

 

2

 

PLOT(CURVES(Matrix(9, 2, {(1, 1) = 0., (1, 2) = 0., (2, 1) = 1., (2, 2) = 0., (3, 1) = 2., (3, 2) = 0., (4, 1) = 0., (4, 2) = 1., (5, 1) = 1., (5, 2) = 1., (6, 1) = 2., (6, 2) = 1., (7, 1) = 0., (7, 2) = 2., (8, 1) = 1., (8, 2) = 2., (9, 1) = 2., (9, 2) = 2.}), COLOUR(RGB, .47058824, 0., 0.54901961e-1, _ATTRIBUTE("source" = "mathdefault"))), STYLE(POINT), SYMBOL(CIRCLE, 20), AXESLABELS("", ""), AXESSTYLE(BOX), VIEW(-1 .. 4, 0 .. 3))

 

PLOT(TEXT([.1, 1.], u[1, 0] = X[0], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 1.00000000, 0., 0.)), TEXT([1.1, 1.], u[1, 1] = X[1], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 1.00000000, 0., 0.)), TEXT([2.1, 1.], u[1, 2] = X[2], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 1.00000000, 0., 0.)), TEXT([.1, 2.], u[2, 0] = X[3], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 1.00000000, 0., 0.)), TEXT([1.1, 2.], u[2, 1] = X[4], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 1.00000000, 0., 0.)), TEXT([2.1, 2.], u[2, 2] = X[5], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 1.00000000, 0., 0.)))

 

PLOT(CURVES(Matrix(10, 2, {(1, 1) = -1., (1, 2) = 1., (2, 1) = -1., (2, 2) = 2., (3, 1) = 3., (3, 2) = 1., (4, 1) = 3., (4, 2) = 2., (5, 1) = 0., (5, 2) = 0., (6, 1) = 1., (6, 2) = 0., (7, 1) = 2., (7, 2) = 0., (8, 1) = 0., (8, 2) = 3., (9, 1) = 1., (9, 2) = 3., (10, 1) = 2., (10, 2) = 3.})), COLOUR(RGB, 0., 0., 1.00000000), STYLE(POINT), SYMBOL(CIRCLE, 20), AXESLABELS("", ""), AXESSTYLE(BOX), VIEW(-2 .. 6, -2 .. 5))

 

PLOT(TEXT([-.9, 1.], u[1, -1], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)), TEXT([-.9, 2.], u[2, -1], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)), TEXT([3.1, 1.], u[1, 3], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)), TEXT([3.1, 2.], u[2, 3], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)), TEXT([.1, 0.], u[0, 0], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)), TEXT([1.1, 0.], u[0, 1], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)), TEXT([2.1, 0.], u[0, 2], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)), TEXT([.1, 3.], u[3, 0], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)), TEXT([1.1, 3.], u[3, 1], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)), TEXT([2.1, 3.], u[3, 2], ALIGNRIGHT, ALIGNBELOW, COLOUR(RGB, 0., 0., 1.00000000)))

 

 

eq := 'eq'; COUNT := 0; for i to N do for j from 0 to M do COUNT := COUNT+1; eq[COUNT] := laplace_stencil; print(eq[COUNT]) end do end do; vars := [seq(seq(u[i, j], j = 0 .. M), i = 1 .. N)]; A, B := GenerateMatrix(convert(eq, list), vars); for j from 0 to M do subs[inplace](u[0, j] = 0, B); subs[inplace](u[N+1, j] = 0, B) end do; for i to N do subs[inplace](u[i, -1] = u[i, 1], B); subs[inplace](u[i, M+1] = u[i, M-1], B) end do; BB, BBB := GenerateMatrix(convert(B, list), vars);

eq := eq

 

COUNT := 0

 

3*u[1, -1]-10*u[1, 0]+3*u[1, 1]+2*u[0, 0]+2*u[2, 0] = h^2*f[1, 0]

 

3*u[1, 0]-10*u[1, 1]+3*u[1, 2]+2*u[0, 1]+2*u[2, 1] = h^2*f[1, 1]

 

3*u[1, 1]-10*u[1, 2]+3*u[1, 3]+2*u[0, 2]+2*u[2, 2] = h^2*f[1, 2]

 

3*u[2, -1]-10*u[2, 0]+3*u[2, 1]+2*u[1, 0]+2*u[3, 0] = h^2*f[2, 0]

 

3*u[2, 0]-10*u[2, 1]+3*u[2, 2]+2*u[1, 1]+2*u[3, 1] = h^2*f[2, 1]

 

3*u[2, 1]-10*u[2, 2]+3*u[2, 3]+2*u[1, 2]+2*u[3, 2] = h^2*f[2, 2]

 

vars := [u[1, 0], u[1, 1], u[1, 2], u[2, 0], u[2, 1], u[2, 2]]

 

A, B := Matrix(6, 6, {(1, 1) = -10, (1, 2) = 3, (1, 3) = 0, (1, 4) = 2, (1, 5) = 0, (1, 6) = 0, (2, 1) = 3, (2, 2) = -10, (2, 3) = 3, (2, 4) = 0, (2, 5) = 2, (2, 6) = 0, (3, 1) = 0, (3, 2) = 3, (3, 3) = -10, (3, 4) = 0, (3, 5) = 0, (3, 6) = 2, (4, 1) = 2, (4, 2) = 0, (4, 3) = 0, (4, 4) = -10, (4, 5) = 3, (4, 6) = 0, (5, 1) = 0, (5, 2) = 2, (5, 3) = 0, (5, 4) = 3, (5, 5) = -10, (5, 6) = 3, (6, 1) = 0, (6, 2) = 0, (6, 3) = 2, (6, 4) = 0, (6, 5) = 3, (6, 6) = -10}), Vector(6, {(1) = h^2*f[1, 0]-2*u[0, 0]-3*u[1, -1], (2) = h^2*f[1, 1]-2*u[0, 1], (3) = h^2*f[1, 2]-2*u[0, 2]-3*u[1, 3], (4) = h^2*f[2, 0]-3*u[2, -1]-2*u[3, 0], (5) = h^2*f[2, 1]-2*u[3, 1], (6) = h^2*f[2, 2]-3*u[2, 3]-2*u[3, 2]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, -1], (2) = h^2*f[1, 1]-2*u[0, 1], (3) = h^2*f[1, 2]-2*u[0, 2]-3*u[1, 3], (4) = h^2*f[2, 0]-3*u[2, -1]-2*u[3, 0], (5) = h^2*f[2, 1]-2*u[3, 1], (6) = h^2*f[2, 2]-3*u[2, 3]-2*u[3, 2]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, -1], (2) = h^2*f[1, 1]-2*u[0, 1], (3) = h^2*f[1, 2]-2*u[0, 2]-3*u[1, 3], (4) = h^2*f[2, 0]-3*u[2, -1], (5) = h^2*f[2, 1]-2*u[3, 1], (6) = h^2*f[2, 2]-3*u[2, 3]-2*u[3, 2]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, -1], (2) = h^2*f[1, 1], (3) = h^2*f[1, 2]-2*u[0, 2]-3*u[1, 3], (4) = h^2*f[2, 0]-3*u[2, -1], (5) = h^2*f[2, 1]-2*u[3, 1], (6) = h^2*f[2, 2]-3*u[2, 3]-2*u[3, 2]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, -1], (2) = h^2*f[1, 1], (3) = h^2*f[1, 2]-2*u[0, 2]-3*u[1, 3], (4) = h^2*f[2, 0]-3*u[2, -1], (5) = h^2*f[2, 1], (6) = h^2*f[2, 2]-3*u[2, 3]-2*u[3, 2]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, -1], (2) = h^2*f[1, 1], (3) = h^2*f[1, 2]-3*u[1, 3], (4) = h^2*f[2, 0]-3*u[2, -1], (5) = h^2*f[2, 1], (6) = h^2*f[2, 2]-3*u[2, 3]-2*u[3, 2]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, -1], (2) = h^2*f[1, 1], (3) = h^2*f[1, 2]-3*u[1, 3], (4) = h^2*f[2, 0]-3*u[2, -1], (5) = h^2*f[2, 1], (6) = h^2*f[2, 2]-3*u[2, 3]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, 1], (2) = h^2*f[1, 1], (3) = h^2*f[1, 2]-3*u[1, 3], (4) = h^2*f[2, 0]-3*u[2, -1], (5) = h^2*f[2, 1], (6) = h^2*f[2, 2]-3*u[2, 3]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, 1], (2) = h^2*f[1, 1], (3) = h^2*f[1, 2]-3*u[1, 1], (4) = h^2*f[2, 0]-3*u[2, -1], (5) = h^2*f[2, 1], (6) = h^2*f[2, 2]-3*u[2, 3]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, 1], (2) = h^2*f[1, 1], (3) = h^2*f[1, 2]-3*u[1, 1], (4) = h^2*f[2, 0]-3*u[2, 1], (5) = h^2*f[2, 1], (6) = h^2*f[2, 2]-3*u[2, 3]})

 

Vector(6, {(1) = h^2*f[1, 0]-3*u[1, 1], (2) = h^2*f[1, 1], (3) = h^2*f[1, 2]-3*u[1, 1], (4) = h^2*f[2, 0]-3*u[2, 1], (5) = h^2*f[2, 1], (6) = h^2*f[2, 2]-3*u[2, 1]})

 

BB, BBB := Matrix(6, 6, {(1, 1) = 0, (1, 2) = -3, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = -3, (3, 3) = 0, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0, (4, 5) = -3, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 0, (5, 6) = 0, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = -3, (6, 6) = 0}), Vector(6, {(1) = -h^2*f[1, 0], (2) = -h^2*f[1, 1], (3) = -h^2*f[1, 2], (4) = -h^2*f[2, 0], (5) = -h^2*f[2, 1], (6) = -h^2*f[2, 2]})

(7)

ApproxSol := LinearSolve(A+BB, BBB);

ApproxSol := Vector(6, {(1) = (5/48)*h^2*f[1, 0]+(1/48)*h^2*f[2, 0], (2) = (13/384)*h^2*f[1, 0]+(5/48)*h^2*f[1, 1]+(13/384)*h^2*f[1, 2]+(5/384)*h^2*f[2, 0]+(1/48)*h^2*f[2, 1]+(5/384)*h^2*f[2, 2], (3) = (5/48)*h^2*f[1, 2]+(1/48)*h^2*f[2, 2], (4) = (1/48)*h^2*f[1, 0]+(5/48)*h^2*f[2, 0], (5) = (5/384)*h^2*f[1, 0]+(1/48)*h^2*f[1, 1]+(5/384)*h^2*f[1, 2]+(13/384)*h^2*f[2, 0]+(13/384)*h^2*f[2, 2]+(5/48)*h^2*f[2, 1], (6) = (1/48)*h^2*f[1, 2]+(5/48)*h^2*f[2, 2]})

(8)

NULL

NULL

 

Download TESTESTEst.mw

@sarra i ran it more than three times,and every thing was ok !

i think your problems does not coincides with version of maple , but setting you use,thus please upload your worlsheet here so that one can solve your problem.good luck

@Carl Love why setting time step and spacestep makes it correct !?

NULL

restart:

pde:=diff(u(t,x),t$2)=diff(u(t,x),x$2)-sin(u(t,x)):

f:=unapply(x^2,x):

IBC := {u(0,x)=f(x),u(t,-50)=0,D[2](u)(t, 50)=0,D[1](u)(0, x)=-diff(f(x),x)}:

 

pds := pdsolve(pde, IBC,time=t,range=-50..50, numeric,timestep=0.01, spacestep= 0.1);

 

 

module () local INFO; export plot, plot3d, animate, value, settings; option `Copyright (c) 2001 by Waterloo Maple Inc. All rights reserved.`; end module

(1)

p1 := pds:-plot(t = 0):

p2 := pds:-plot(t = 1/10):

p3 := pds:-plot(t = 1/2):

p4 := pds:-plot(t = 1):

p5 := pds:-plot(t = 2):

plots[display]({p1, p2, p3, p4, p5}, title = `Sine Gordaon at t=0,0.1,0.5,1,2`);

 

 

 

 

NULL


Download error_with_boundaries.mw

@Carl Love tnx for your remark

please make more clear what u want.

First 8 9 10 11 12 13 14 Last Page 10 of 23