mehdi jafari

559 Reputation

13 Badges

6 years, 308 days

MaplePrimes Activity


These are answers submitted by mehdi jafari


restart:

B[t+1]:=B[t]+X[t,t+1]-D[t,t+1];

B[t]+X[t, t+1]-D[t, t+1]

(1)

T[t+1]:=(m+1)/(m*sum(X[t-i,t+1-i],i=1..m-1));

(m+1)/(m*(sum(X[t-i, t+1-i], i = 1 .. m-1)))

(2)

 


Download sum.mw

i think u just want assign s members to constants , u can do it like this :

for i to nops(s) do
C||i:=rhs(op(i,s));od;



restart:

Eq1 := diff(psi(y), y, y, y, y)-M*(diff(psi(y), y, y))-Gr*b*y = 0;

 

bcs1:=psi(0)=0,(D@@2)(psi)(0)=0,psi(h)=-F/2,D(psi)(h)=A;

 

res1:=(dsolve(Eq1));

 

 

diff(diff(diff(diff(psi(y), y), y), y), y)-M*(diff(diff(psi(y), y), y))-Gr*b*y = 0

 

psi(0) = 0, ((D@@2)(psi))(0) = 0, psi(h) = -(1/2)*F, (D(psi))(h) = A

 

psi(y) = -((1/6)*Gr*b*y^3-exp(M^(1/2)*y)*_C2-exp(-M^(1/2)*y)*_C1)/M+_C3*y+_C4

(1)

res2:=(dsolve({Eq1,bcs1},psi(y)));

psi(y) = -((1/6)*Gr*b*y^3-(1/6)*exp(M^(1/2)*y)*(2*Gr*b*h^3+6*A*M*h+3*F*M)/(exp(M^(1/2)*h)*M^(1/2)*h+exp(-M^(1/2)*h)*M^(1/2)*h-exp(M^(1/2)*h)+exp(-M^(1/2)*h))+(1/6)*exp(-M^(1/2)*y)*(2*Gr*b*h^3+6*A*M*h+3*F*M)/(exp(M^(1/2)*h)*M^(1/2)*h+exp(-M^(1/2)*h)*M^(1/2)*h-exp(M^(1/2)*h)+exp(-M^(1/2)*h)))/M-(1/6)*(-Gr*exp(M^(1/2)*h)*M^(1/2)*b*h^3-Gr*exp(-M^(1/2)*h)*M^(1/2)*b*h^3+3*Gr*exp(M^(1/2)*h)*b*h^2-3*Gr*exp(-M^(1/2)*h)*b*h^2+3*F*M^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))

 

-(1/6)*(-Gr*exp(M^(1/2)*h)*M^(1/2)*b*h^3-Gr*exp(-M^(1/2)*h)*M^(1/2)*b*h^3+3*Gr*exp(M^(1/2)*h)*b*h^2-3*Gr*exp(-M^(1/2)*h)*b*h^2+3*F*M^(3/2)*exp(M^(1/2)*h)+3*F*M^(3/2)*exp(-M^(1/2)*h)+6*A*M*exp(M^(1/2)*h)-6*A*M*exp(-M^(1/2)*h))/(M*(exp(M^(1/2)*h)*M^(1/2)*h+exp(-M^(1/2)*h)*M^(1/2)*h-exp(M^(1/2)*h)+exp(-M^(1/2)*h)))

 

0

(5)

 



Download maple_(3).mw

 

it is almost correct, i just made i also local ,


restart;

 

with(plots);

 

g := proc (F, A, B, X0, g::evaln) local f, a, b, E, x0,i, erreur, N, n, x1, ps, pp, pic; f := F; a := A; b := B; x0 := X0; E :=evalf(abs(f(x0)));

 

erreur := 0.1e-3;

 

N := 100;

 

n := 0;

 

for i to N do x1 := evalf(x0-f(x0)/(D(f))(x0));

 

E := abs(f(x1));

 

n := n+1; ps[n] := plot([[x0, 0.], [x0, f(x0)], [x1, 0.]], color = green, thickness = 2);

 

x0 := x1 end do; g := evalf(x1); pp := plot(f(x), x = a .. b, color = red); pic := seq(ps[i], i = 1 .. n); display(pp, pic) end proc;

f := proc (x) options operator, arrow; sin(x)-cos(2*x)+.2 end proc;

a := 0; b := 6;

 

[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fieldplot, fieldplot3d, gradplot, gradplot3d, implicitplot, implicitplot3d, inequal, interactive, interactiveparams, intersectplot, listcontplot, listcontplot3d, listdensityplot, listplot, listplot3d, loglogplot, logplot, matrixplot, multiple, odeplot, pareto, plotcompare, pointplot, pointplot3d, polarplot, polygonplot, polygonplot3d, polyhedra_supported, polyhedraplot, rootlocus, semilogplot, setcolors, setoptions, setoptions3d, spacecurve, sparsematrixplot, surfdata, textplot, textplot3d, tubeplot]

 

proc (F, A, B, X0, g::evaln) local f, a, b, E, x0, i, erreur, N, n, x1, ps, pp, pic; f := F; a := A; b := B; x0 := X0; E := evalf(abs(f(x0))); erreur := 0.1e-3; N := 100; n := 0; for i to N do x1 := evalf(x0-f(x0)/(D(f))(x0)); E := abs(f(x1)); n := n+1; ps[n] := plot([[x0, 0.], [x0, f(x0)], [x1, 0.]], color = green, thickness = 2); x0 := x1 end do; g := evalf(x1); pp := plot(f(x), x = a .. b, color = red); pic := seq(ps[i], i = 1 .. n); plots:-display(pp, pic) end proc

 

proc (x) options operator, arrow; sin(x)-cos(2*x)+.2 end proc

 

0

 

6

(1)

 


Download correct.mw

please read this article or i copy some of it here :
http://www.maplesoft.com/support/faqs/detail.aspx?sid=87675

Changing the default set of fonts Maple uses in the Standard interface is a two step process.

To change the default font for a type of input or output:

1. Select Format -> Styles

2. Select the style you wish to change and click the "Modify" button.

3. Change the font type, size, colour, etc. as desired and click "OK"

The default input/output modes for Maple are:

2D Math input: "C 2D Math"

1D Math input: "C Maple Input"

2D Math output: "C 2D Output"

The above steps will apply the change for the current worksheet only. If you were to restart Maple, the old default values will be restored. You must make a user defined style set if you want this change permanently. Here is how you can save the changes made above:

1. Select Format -> Manage Style Sets -> New Style Set

2. Select "Select All". Save the file.

3. Select the "User-defined Style Set" radio button. Browse to the style set file you created in the previous step and select it. Click "OK".

This makes Maple use the style set you've defined in future sessions.

(Note that you will need to keep that style set worksheet in its current location. If you move it, the font will go back to its default)

To return to the defaults, go back to:

Format -> Manage Style Sets

and select “Default Maple Style Set”.

good luck!

one of many way is this :


restart:n:=5;# number of arguments#

5

(1)

f:=Sum((a[i])*x^i,i=0..n);

Sum(a[i]*x^i, i = 0 .. 5)

(2)

 

# giving values to coefficients#

a[1]:=1.3:a[2]:=5.73:a[3]:=7:a[4]:=9:a[5]:=11:

value(eval(f));

a[0]+1.3*x+5.73*x^2+7*x^3+9*x^4+11*x^5

(3)

#or u can do like this

restart:

f:=a*x^2+b*x+c:

params:={a=1,b=2,c=3}:

eval(f,params);

x^2+2*x+3

(4)

 

for editing your post, in the down of your question,there is more,click on more and edit it . hope bests for you,since you decerve it . good luck

Download value.mw

u can use a program which adds virtual printer so that u can print any thing u want to pdf files. for example adobe acrobat pro.
also u can use these pdfs.

M15QRC_win.pdf

maple-ref.pdf

maple_18.pdf

use hint for sepration of varibales, you should also write Pi with capital P .


``

restart:

PDE:=diff(u(x,t),t)=diff(u(x,t),x$2);

diff(u(x, t), t) = diff(diff(u(x, t), x), x)

(1)

BCs:={u(0,t)=0, u(Pi/4,t)=0 , u(x,0)=x*(Pi/4-x)};

{u(0, t) = 0, u(x, 0) = x*((1/4)*Pi-x), u((1/4)*Pi, t) = 0}

(2)

 

ans:=pdsolve(PDE, HINT = h(x)*g(t));

PDESolStruc(u(x, t) = h(x)*g(t), [{diff(diff(h(x), x), x) = _c[1]*h(x), diff(g(t), t) = _c[1]*g(t)}])

(3)

PDEtools:-build(ans);

u(x, t) = exp(_c[1]^(1/2)*x)*_C1*exp(_c[1]*t)*_C2+_C1*exp(_c[1]*t)*_C3/exp(_c[1]^(1/2)*x)

(4)

NULL

pds:=pdsolve(PDE,BCs,numeric):

p1 := pds:-plot(t = 0):p2 := pds:-plot(t = 1/10):p3 := pds:-plot(t = 1/2):p4 := pds:-plot(t = 1):``NULLp5 := pds:-plot(t = 2):plots[display]({p1, p2, p3, p4, p5});

 

 

PDEtools:-Laplace(PDE,u(x,t));

``

NULL

``


 actually i do not know why Laplace does not solve this.

Download pde_(2).mw

 

 

 

restart:

Max:=proc() local m,i;
m:=-infinity;
for i in (args) do
if i>m then
m:=i
end if;od;m;
end proc:

triangle:=proc(a,b,c) local A,S;
A:=evalf({(args)} minus {Max(args)});
S:=sqrt(op(1,A)^2+op(2,A)^2);
if Max(args)<S then;
print("the triangle is acute");
elif Max(args)=S then;
print("the triangle is right");
else;
print("the triangle is obtuse");
end if;
end proc:

triangle(3,5,10);triangle(3,5,4);

 

 

(1)

 

 

 

 

 

 two_procedures.mw


restart:
with(Optimization):
with(LinearAlgebra):
L:=1:  r:=2:  tau:= 1:
interface(rtablesize= 2*r+1):

Z:= Matrix(
     2*r+1, 2*r+1,
     [tau,
      seq(evalf((L/(2*(iz-1)*Pi))*sin(2*(iz-1)*Pi*tau/L)), iz= 2..r+1),
      seq(evalf((L/(2*(iz-1-r)*Pi))*(1-cos(2*(iz-1-r)*Pi*tau/L))), iz= r+2..2*r+1)
      ],
     scan= columns,
     datatype= float[8]
);
                        
Dtau00:= < 1 >:
Dtau01:= Vector[row](r):
Dtau02:= Vector[row](r):
Dtau10:= Vector(r):
Dtau20:= Vector(r):

Dtau1:= DiagonalMatrix([seq(evalf(cos(2*i*Pi*tau/L)), i= 1..r)]):
Dtau2:= DiagonalMatrix([seq(evalf(sin(2*i*Pi*tau/L)), i= 1..r)]):
Dtau3:= -Dtau2:
Dtau4:= copy(Dtau1):

Dtau:= < < Dtau00 | Dtau01 | Dtau02 >,
         < Dtau10 | Dtau1  | Dtau2  >,
         < Dtau20 | Dtau3  | Dtau4  > >;
 
P00:= < L/2 >:
P01:= Vector[row](r):
P02:= Vector[row](r, j-> evalf(-L/j/Pi), datatype= float[8]):
P10:= Vector(r):
P20:= Vector(r, i-> evalf(L/2/i/Pi)):
P1:= Matrix(r,r):
P2:= DiagonalMatrix(P20):
P3:= DiagonalMatrix(-P20):
P4:= Matrix(r,r):

P:= < < P00 | P01 | P02 >,
      < P10 | P1  | P2  >,
      < P20 | P3  | P4  > >;

interface(rtablesize=2*r+1):    # optionally
J:=Vector([L, L/2 $ 2*r]):      # Matrix([[...]]) would also work here

E:=DiagonalMatrix(J);

X:=  Vector[row](2*r+1,symbol=a);
U:=Vector[row](2*r+1,symbol=b);

X0:= Vector[row](2*r+1,[1]);
G:=Vector[row](2*r+1,[1]);
C:=simplify(X-X0-G.Z-X.Dtau.P+X.Dtau.Z-U.P);

Matrix(%id = 18446744073932440990)

Matrix(%id = 18446744073932442670)

Matrix(%id = 18446744073936503742)

Matrix(%id = 18446744073936503982)

Vector[row](%id = 18446744073936504342)

Vector[row](%id = 18446744073936504462)

Vector[row](%id = 18446744073936504582)

Vector[row](%id = 18446744073936504702)

Vector[row](%id = 18446744073936506878)

(1)

J:=X.E.Transpose(X)+U.E.Transpose(U);

a[1]^2+(1/2)*a[2]^2+(1/2)*a[3]^2+(1/2)*a[4]^2+(1/2)*a[5]^2+b[1]^2+(1/2)*b[2]^2+(1/2)*b[3]^2+(1/2)*b[4]^2+(1/2)*b[5]^2

(2)

indets(J); indets(C)

{a[1], a[2], a[3], a[4], a[5], b[1], b[2], b[3], b[4], b[5]}

{a[1], a[2], a[3], a[4], a[5], b[1], b[2], b[3], b[4], b[5]}

(3)

Minimize(J,{seq(C[i]=0,i=1..nops(C))});






[1.52587355672056, [a[1] = HFloat(1.1444051675404217), a[2] = HFloat(0.07357433784470904), a[3] = HFloat(0.019083716254587775), a[4] = HFloat(-0.23114059939913092), a[5] = HFloat(-0.11990652561630644), b[1] = HFloat(-0.3814683891801405), b[2] = HFloat(0.0), b[3] = HFloat(-8.695843524419988e-16), b[4] = HFloat(-0.23114059939913095), b[5] = HFloat(-0.1199065256163064)]]

(4)

#XP:=-.015+X[1]+add(X[l+1]*f1(l)+X[r+l+1]*f2(l), l= 1..r):
#plot([XP,T1], t= 0..1);#,legend= "Solution Of x(t) with r=50"):

 

 

 

 

 


Download solved.mws

at first,i should request to upload the worksheet insetead of copying commands with this format, just copy and paste it in your worksheet to see it is not directly executable. when you load LinearAlgebra packgar,there is no need everytime to load part of package , if you need to load part of the package, just to it like this : 

with(LinearAlgebra,DiagonalMatrix):

your matrix bounds are not correct so you can not multiply them correctly ! please change your matrix bounds,

 

restart:with(Optimization):with(LinearAlgebra,DiagonalMatrix):

L := 1: r := 2: tau := 1:

interface(rtablesize = 2*r+1):

 Z:= Matrix(2*r+1, 2*r+1,[tau,seq(evalf((L/(2*(iz-1)*Pi))*sin(2*(iz-1)*Pi*tau/L)), iz= 2..r+1),seq(evalf((L/(2*(iz-1-r)*Pi))*(1-cos(2*(iz-1-r)*Pi*tau/L))), iz= r+2..2*r+1)],scan= columns,datatype = float[8]);

Z := Matrix(5, 5, {(1, 1) = 1., (1, 2) = 0., (1, 3) = 0., (1, 4) = 0., (1, 5) = 0., (2, 1) = 0., (2, 2) = 0., (2, 3) = 0., (2, 4) = 0., (2, 5) = 0., (3, 1) = 0., (3, 2) = 0., (3, 3) = 0., (3, 4) = 0., (3, 5) = 0., (4, 1) = 0., (4, 2) = 0., (4, 3) = 0., (4, 4) = 0., (4, 5) = 0., (5, 1) = 0., (5, 2) = 0., (5, 3) = 0., (5, 4) = 0., (5, 5) = 0.})

(1)

Dtau00 := `<,>`(1); Dtau01 := Vector[row](r); Dtau02 := Vector[row](r); Dtau10 := Vector(r); Dtau20 := Vector(r);

 

Dtau00 := Vector(1, {(1) = 1})

 

Dtau01 := Vector[row](2, {(1) = 0, (2) = 0})

 

Dtau02 := Vector[row](2, {(1) = 0, (2) = 0})

 

Dtau10 := Vector(2, {(1) = 0, (2) = 0})

 

Dtau20 := Vector(2, {(1) = 0, (2) = 0})

(2)

Dtau1:= DiagonalMatrix([seq(evalf(cos(2*i*Pi*tau/L)), i= 1..r)]): Dtau2:= DiagonalMatrix([seq(evalf(sin(2*i*Pi*tau/L)), i= 1..r)]):  Dtau3:= -Dtau2: Dtau4:= copy(Dtau1): Dtau:= < < Dtau00 | Dtau01 | Dtau02 >>, < Dtau10 | Dtau1 | Dtau2 >, < Dtau20 | Dtau3 | Dtau4 > ;

Dtau := Matrix(1, 5, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0}), Matrix(2, 5, {(1, 1) = 0, (1, 2) = 1., (1, 3) = 0, (1, 4) = 0., (1, 5) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 1., (2, 4) = 0, (2, 5) = 0.}), Matrix(2, 5, {(1, 1) = 0, (1, 2) = -0., (1, 3) = -0., (1, 4) = 1., (1, 5) = 0, (2, 1) = 0, (2, 2) = -0., (2, 3) = -0., (2, 4) = 0, (2, 5) = 1.})

(3)

P00:= < L/2 >: P01:= Vector[row](r): P02:= Vector[row](r, j-> evalf(-L/j/Pi), datatype= float[8]):P10:= Vector(r): P20:= Vector(r, i-> evalf(L/2/i/Pi)): P1:= Matrix(r,r): P2:= DiagonalMatrix(P20): P3:= DiagonalMatrix(-P20): P4:= Matrix(r,r): P:= < < P00 | P01 | P02 >> ,< P10 | P1 | P2 >, < P20 | P3 | P4 > ;

P := Matrix(1, 5, {(1, 1) = 1/2, (1, 2) = 0, (1, 3) = 0, (1, 4) = -.318309886100000, (1, 5) = -.159154943000000}), Matrix(2, 5, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (1, 4) = .1591549430, (1, 5) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0.7957747152e-1}), Matrix(2, 5, {(1, 1) = .1591549430, (1, 2) = -.159154943000000, (1, 3) = 0., (1, 4) = 0, (1, 5) = 0, (2, 1) = 0.7957747152e-1, (2, 2) = 0., (2, 3) = -0.795774715200000e-1, (2, 4) = 0, (2, 5) = 0})

(4)

interface(rtablesize = 2*r+1); J := Vector([L, `$`((1/2)*L, 2*r)]); E := DiagonalMatrix(J); X := Vector[row](2*r+1, symbol = a); U := Vector[row](2*r+1, symbol = b); X0 := Vector[row](2*r+1, [1]); G := Vector[row](2*r+1, [1]); C := simplify(X-X0-G.Z-X.Dtau.P+X.Dtau.Z-U.P);

5

 

J := Vector(5, {(1) = 1, (2) = 1/2, (3) = 1/2, (4) = 1/2, (5) = 1/2})

 

E := Matrix(5, 5, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (2, 1) = 0, (2, 2) = 1/2, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1/2, (3, 4) = 0, (3, 5) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1/2, (4, 5) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 1/2})

 

X := Vector[row](5, {(1) = a[1], (2) = a[2], (3) = a[3], (4) = a[4], (5) = a[5]})

 

U := Vector[row](5, {(1) = b[1], (2) = b[2], (3) = b[3], (4) = b[4], (5) = b[5]})

 

X0 := Vector[row](5, {(1) = 1, (2) = 0, (3) = 0, (4) = 0, (5) = 0})

 

G := Vector[row](5, {(1) = 1, (2) = 0, (3) = 0, (4) = 0, (5) = 0})

(5)

J := X.E.Transpose(X)+U.E.Transpose(U);

Minimize(J, {C = 0});

 


Download problem.mw

you can remove differentiation independent parameter by using declare and prime, like this :

with(PDEtools,declare):
declare(A(t), prime = t);

but actually it is not what you want, what you want is this :

restart:

 

 

d:=diff(A(t), t);

 

diff(A(t), t)

(1)

A(t)=((Int(d,t)));

A(t) = Int(diff(A(t), t), t)

(2)

``

maybe it is so obvious ,but this is the only direct way to relate a function to its differentiation !!! and u can not do it in any other way i think ! good luck !

Download diff.mw

Hi sir,please refer to these links, hope it helps you . good luck Sir.

http://www.mapleprimes.com/questions/150659-How-To-Plot-With-The-Results-Of-Desolve-Command

http://www.mapleprimes.com/questions/201243-Solution-Of-System-Of-Nonlinear-ODEs#answer204818

good luck!

what do u mean by finding relation between two expressions ? 

restart:

alias(z=x^2+y);

z

(1)

 f(x^2+y)=factor(x^4+y^2+2*y*x^2);

f(z) = z^2

(2)

``

 

Download alias.mw

as maple help page :

unapply(expr, x, y, .., options);

The result of unapply(expr, x) is a functional operator. Applying this operator to x gives the original expression.
"unapply(expr,x)(x)->expr"

In particular, for a function
f(x)
,
"unapply(f(x),x)->f"

for example :
p := x^2+sin(x)+1;
f := unapply(p, x);
f(Pi);

good luck !

 

 

 

 

as u can seen in the picture, i write Pi in two ways in maple 18

5 6 7 8 9 Page 7 of 9