584 Reputation

7 years, 218 days

procedure with if statement...

Maple

I have a question with a proc containing "if" statement.
i want maple to do the calculations without just like Heaviside function does. how can it be done?is it possible?

 > restart
 > f1:=proc(x) if x>=0 then 1 else 0 fi:end proc:
 > Matrix(2,[[f1(x)+2,2*f1(x)],[5,4]]);
 > P:=f1(x)*exp(x)+5*x;
 > diff(P,x)
 (1)
 >
 >

but i can do all of the above with Heaviside(x). can i do the same with my procedure?

some problems with maple...

Maple

i have a matrix named S. it has two variables with the names sigma1 and tau. i do some computations with these varibels to obtain a matrix named S_NEW. when i calculate S_NEW with parameters and then i substitute parameter tau with zero i got the answer a zero Matrix. but when i put tau=0 at the initiation of my code, i got another answer. what is the problem?

the second issue is related with the name of parametes in maple. when the varible has the name sigma1 (and tau=0), the matrix S_NEW is a matrix with the only component of (1,1). when i change the parameter name to sigma the matrix S_NEW is a matrix with the only component of (3,3). where is the problem?

 > restart:with(LinearAlgebra):
 > tau:=0;
 (1)
 > S:=Matrix(3,[[sigma1,tau,0],[tau,0,0],[0,0,0]]):B1:=Matrix(3):
 > A12,B12:=(Eigenvectors(S)):
 > V12:= Matrix(Normalize~([Column(B12,1..3)],Euclidean)):
 > S_NEW:=simplify(V12^+.S.V12) assuming real ;
 (2)
 > eval(S_NEW,tau=0)
 (3)
 >
 >
 >

how to keep set members in order of addi...

Maple

i have a question about sets. how can i keep set members in order of addition not the defualt maple ordering.
in maple help, i saw the command setsort=0..8 but i do not know how to use it.
consider exmaple below:

 > restart
 > L:={}:
 > for j in [3,5,6,1] do birth:=j: L:=`union`(L ,{j}); od;
 (1)
 >

how can i keep L as order of addition? L={3,5,6,1}. thanks in advance

a question on integration of error funct...

Maple

how this integral can be calculated in the simplest form ? the second question is what exactly is done when using assuming? for example when using assuming real, all the functions or parameteres are affected? thanks in advanced

 > restart:with(IntegrationTools):
 > (int(int(exp(-(y-beta[0]-beta[1]*x-b0-b1*x)^2/(2*sigma^2))*exp(-b0)*exp(-b1),b0=0..infinity),b1=0..infinity,continuous=true) assuming real)
 (1)
 >

a problem with fsolve...

Maple

i have a problem with a nonlinear equation containing Heaviside step function. fsolve does not return anything and SolveEquation command also returns incorrect answer. How can i solve this equation? any method or help is appreciated.

 >
 > restart:
 > with(DirectSearch):
 > F:=x*(Heaviside(x-(S0))/(1-DD)+Heaviside(-x+S0)/(1-HH*DD));
 (1)
 > EQ:=F-E*Y;
 (2)
 > HH:=0.2; DD:=0.579350262599427; S0:=1e8; E:=70e9; Y:=0.001668993263529;
 (3)
 > EQ
 (4)
 > fsolve(EQ)
 (5)
 > SolveEquations(EQ)
 (6)
 > eval(EQ,x = 1.00000000000000*10^8)
 (7)
 >