Items tagged with parameters parameters Tagged Items Feed

I could not find a way to do this in Maple looking at http://www.maplesoft.com/support/help/Maple/view.aspx?path=parameter_classes

and I see that Maple is missing from http://rosettacode.org/wiki/Named_parameters

Is it possible to call a Maple proc using named parameters? Here is an example of what this looks like from a small Ada example from the above link:

procedure Foo (Arg_1 : Integer; Arg_2 : Float := 0.0);
Foo (Arg_2 => 0.0, Arg_1 => 1);

This is very useful for proc with many arguments, and it also makes the code much
more clear and less change in using the wrong value for the wrong parameter.

In Maple notation, this can be like

foo:=proc(arg1::integer,arg2::float) ..... end proc;
foo(arg2=>10,arg1=>200);

(This editor is so bad, can't someone fix it?)

A large procedure I made caused me some problems. I finally found the source of the problem.
There seems to be some interaction between the end of parameters marker, $, and the elementwise operation ~.

Consider these 3 versions of essentially the same procedure:

restart;
Q1:=proc(Var::list,$) local n;
  n:=nops(Var);
  print(Var,n);
  proc(var::list)
       subs(Var=~[seq(1..n)],var); #Elementwise
  end proc;
end proc:
Q1([x,y]); #Doesn't work : "invalid expression"
Q2:=proc(Var::list,$) local n;
  n:=nops(Var);
  print(Var,n);
  proc(var::list)
      subs(zip(`=`,Var,[seq(1..n)]),var); # zip
  end proc;
end proc:
Q2([x,y]); #No problem
Q3:=proc(Var::list) local n; #No end of parameters marker $
  n:=nops(Var);
  print(Var,n);
  proc(var::list)
       subs(Var=~[seq(1..n)],var); # Elementwise
  end proc;
end proc:
Q3([x,y]); # No problem
lprint(Q3([x,y])); #Curious output involving ` $`
#A fourth procedure in which the output is not a procedure works:
Q4:=proc(Var::list,$) local n;
  n:=nops(Var);
  print(Var,n);
  subs(Var=~[seq(1..n)],Var)
end proc:
Q4([x,y]);

Does anybody have any comments? Is it a bug?

Hell

I write this code and didn't work , I have some erorrs as

Warning, The use of global variables in numerical ODE problems is deprecated, and will be removed in a future release. Use the 'parameters' argument instead (see ?dsolve,numeric,parameters)
Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

also I have question " How I can change the scale of plot"

parameters := [z = 0, Omega = 2.2758, tau = 13.8, T2 = 200, omega0 = 1, r = .7071, s = 2.2758, H = 1.05457173*10^(-34), omega = .5, k = 1666666.667, Delta = 1.7758]

 

sys1 := {diff(u(t), t) = s*v(t)-u(t)/T2, diff(v(t), t) = -s*u(t)-2*Omega*exp(-r^2/omega0^2-t^2*1.177^2/tau^2)*cos(kz-`ωt`)*w(t)-v(t)/T2, diff(w(t), t) = 2*Omega*exp(-r^2/omega0^2-t^2*1.177^2/tau^2)*cos(kz-`ωt`)*v(t)}; ICs1 := {u(-20) = 0, v(-20) = 0, w(-20) = -1}

 

ans1 := dsolve(`union`(eval(sys1, parameters), ICs1), numeric, output = listprocedure); plots:-odeplot(ans1, [[t, u(t)], [t, v(t)], [t, w(t)]], t = -20 .. 20, legend = [w, v, u])

 

U := eval(u(t), ans1); F := eval(((-2*10^33*Omega*H*r*U(t))*(1/omega0^2))*exp(-r^2/omega0^2-t^2*1.177^2/tau^2)*cos(kz-`ωt`), parameters)

 

plot(F, t = -20 .. 20)

Hi,

I m trying to substitute numerical values to an expression having assumed parameters, like m should be integer, a>0, but i could not do it.

i could not attach the .m file from which i am reading my expression, but i m attaching the file in which i m reading the expression, and you can see i could not assign values to parameters.

Regards

Sunitquestion.mw

Hi,

I have a Matrix whose entries are polynomials in several formal parameters (the matrix is sparse and the polynomials are rather simple, though inverses of the parameters may also arise).
Then, when I compute the kernel with LinearAlgebra-NullSpace, maple naturally gives a basis of solutions over the same ring of polynomials.

Now for some reason there are some parameters that I don't want to see in the solutions (all but two of them, actually).

How can I compute the part of the kernel that lives in $\mathbb{Z}[a,a^{-1}, b,b^{-1}]$, i.e. that involves only the first two parameters?

Thank you,

NoThik

Edit : the coefficients of the polynomials are integers, and I expect the kernel elements to have integer coefficients as well.

Hi,

I'm new to these forums. I'm using Maple 17. What am I missing about the odd behaviour exhibited below? (the code can be copy pasted into Maple)

Suppose I define m,n,p,q as integers and x as real, then define the function h(x,m,n,p,q) below.

assume(m::integer, n::integer, p::integer, q::integer, x::real);
h:=(x,m,n,p,q)->-(1/8*I)*(exp((2*I)*Pi*x)-1)^2*(exp(-(2*I)*Pi*x*(n-q+2))-exp(-(2*I)*Pi*x*(n-q+1)))/(Pi^3*x*(m-x)*(p-x));

If I do:

int(h(x, m, n, p, q), x = -infinity .. infinity)

It says it's 0, but that's not true. The integral is not always 0 but depends on m,n,p,q ... and even Maple acknowledges this. If I do:

int(h(x, 1, 1, 1, 1), x = -infinity .. infinity)

I get -(1/2*I)/Pi ... so clearly not 0.

Also, if I do:

int(h(x, m, n, m, n), x = -infinity .. infinity)

I get -(1/2*I)/(m*Pi) ... again, not 0.

What am I missing? How can I correct this and obtain the analytic expression for int(h(x, m, n, p, q), x = -infinity .. infinity)?

Trying without the assume() causes Maple to run into issues not knowing anything about m,n,p,q.

[ Edit: I finally solved the integral on paper, see my post below if you're curious. The Maple inconsistency and wrong result explained above are still there though ]

Any help would be greatly appreciated.

Regards,

Alex.

Hi guys,

I would like to solve a system of equations and inequalities with symbolic parameters (D, E, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z) for several variables (a, b, c, d, e, f, i, j, l, m, n, p, q, r, s, t, u, v).

Unfortunately the command below does not work. I get the message "Warning, solutions may have been lost".

"Solve({ l-u=0, m-v=0, n-u=0, p-v=0, Y+q-u=0, Y+r-v=0, Z+s-u=0, Z+t-v=0, (a-P*M)*l=0, (b-Q*M...

Hello,

I would like to define my model with symbolic parameters. Consequently, i have to define the symbolic parameters and theirs values in main folder.

To illustrate, i define my parameters a1, a2 like this.

After, i need to define a frame by using the parameter a1. This frame is define like this :

Hi all,

I read the help on using parameters, then I tried to modify the example


f := proc(a, b, c)

    if _params['b','c'] = NULL then
    a
    elif _params['c'] = NULL then
    a + b
    else
    a + b + c

    end if

end proc:

I can't really spot where it went wrong, but it just wouldnt execute as I would expect...

Hello every one,

I want to plot two parameters against each other from a system of ode.

The system is

restart:

with(plots):with(LinearAlgebra):

Eq1:=diff(f(eta),eta$3)+f(eta)*diff(f(eta),eta$2)-diff(f(eta),eta$1)^2-M^2*diff(f(eta),eta$1)+M^2*b+b^2=0;

Eq2:=diff(g(eta),eta$3)+f(eta)*diff(g(eta),eta$2)+(Lambda-2*diff(f(eta),eta$1)-M^2)*diff(g(eta),eta$1)+diff(f(eta),eta$2)*g(eta)=0;

N:=10: M:=0.1:

bc:=f(0)=0,D(f)(0...

Hey guys

I am currently working on my final project in high school. This project is about mathematical modelling within epidemology, and i am currently working on the mathematical models based on the SIR model.

The basis models for the SIR model were pretty easy, but i cant figure out how to fit data to my models. My first idea was to use the method of Leastsquare and/or Nonlinearfit, but i cant figure out how to do this in maple.

restart:

with(LinearAlgebra):
with(ArrayTools):


k:=4;
pA:=<seq(p[a,i],i=2..(k+1))>;
pB:=<seq(p[b,i],i=2..(k+1))>;
pA+pB;

with(VectorCalculus):

pA:=<seq(p[a,i],i=2..(k+1))>;
pB:=<seq(p[b,i],i=2..(k+1))>;
pA+pB;

 

Hi all,

 

After I loaded the package with(VectorCalculus), the output of vectors changed to a different one.

Is there any real "difference" when...

Hello,

I need to plot M vs phi from the following ode. For this I am using implicitplot but unfortunately

I am getting empty plot. Please guide me through this issue.

Thanks 

eq1 := 1/(1-phi)^2.5/(1+4117/783*phi)*diff(f(eta),`$`(eta,3))+1/2*f(eta)*diff(f(eta),`$`(eta,2))

+M*(1-diff(f(eta),eta)) = 0;

bc:=f(0)=0,D(f)(0)=beta/(1-phi)^(2.5)*(D@D)(f)(0),D(f)(N)=1;

respar:=dsolve({eq1,f(0)=0,D(f)(0)=beta/(1-phi)^(2.5)*(D@D)(f)(0)},numeric,

Hello all

I have a set of differential equations and its numerical solution, for two functions. Here's the worksheet (just a part of it, I don't need the rest)

##########################################

eq1 := diff(W(r), r) = -(1-beta*(W(r)-W0))*(M(r)+4*Pi*r^3*p(r))/(beta*r*(r-2*M(r)));

eq2 := diff(M(r), r) = 4*Pi*r^2*rho(r);

W0 := solve(thetaR = theta0-W0, W0);

r0:=10^(-5);

rf:=10^20;

# ini := evalf({M(r0) = 0, W(r0) = W0});

I am trying to overload the "." operator (noncommutative product) to handle objects I have implemented as records. Each record contains a matrix R and a parameter l. A.B will produce a new record where l is l_A+l_B and R is R_A.R_B, "." here being the normal matrix product (and I use LinearAlgebra:-Multiply in the body of my procedure for this). The objects A and B are of type 'Element', which I have defined (using AddType) and which works.

I implemented the procedure...

1 2 3 Page 1 of 3