Items tagged with parameters parameters Tagged Items Feed

Let us consider the maximum value of the polynomial

x^4+c*x^2+x^3+d*x-c-1

on the interval x=-1..1 as a function g of the parameters c and d. General considerations suggest its continuity. However, a plot3d of g does not  confirm it.  Also the question arises "Is the function g(c,d) bounded from below?". Here is my try with the DirectSearch and NLPSolve:

 

restart;
``

g(10, -10)

9.

(1)

plot(x^4+x^3+10*x^2-10*x-10-1, x = -1 .. 1)

 

plot3d(g, -5 .. 5, -5 .. 5, grid = [100, 100], style = surface, color = "DarkOliveGreen")

 

DirectSearch:-GlobalOptima(proc (a, b) options operator, arrow; g(a, b) end proc, {a = -1000 .. 1000, b = -1000 .. 1000}, variables = [a, b])

[-167.208333252089, Vector(2, {(1) = 999.9999999975528, (2) = 166.20833325208952}, datatype = float[8]), 815]

(2)

DirectSearch:-GlobalOptima( (a, b) -> g(a, b), variables = [a, b])

DirectSearch:-GlobalOptima(proc (a, b) options operator, arrow; g(a, b) end proc, variables = [a, b])

Error, (in Optimization:-NLPSolve) invalid input: PolynomialTools:-CoefficientVector expects its 1st argument, poly, to be of type polynom(anything, x), but received HFloat(HFloat(undefined))*x^4+HFloat(HFloat(undefined))*x^3+HFloat(HFloat(undefined))*x^2+HFloat(HFloat(undefined))*x+HFloat(HFloat(undefined))

 

``

 

Download bound.mw

 

This might be a mis-understanding on my part, so I figured I would ask a question first.  Narrowing down my code to something minimalistic, suppose I have 2 functions, each of which take a 'context' (abbreviated ctx) as a keyword parameter.  Now, suppose that the first one calls the second, like so:

foo := proc({ctx :: list := []}) bar(ctx = ctx) end proc:
bar := proc({ctx :: list := []}) nops(ctx) end proc:

and then a call "foo(ctx = [a,b,c])" returns the (completely unexpected) value 0.  See if you can puzzle out why.  If I change my code to use different names, like

foo1 := proc({ctx :: list := []}) bar1(_ctx = ctx) end proc:
bar1 := proc({_ctx :: list := []}) nops(_ctx) end proc:

Then the call "foo1(ctx = [a,b,c])" returns the expected 3.

I have tried a number of variants, like changing the call to bar('ctx' = ctx) in foo, but that does not work.  The completely un-intuitive :-ctx does work.

Is this documented anywhere?  Is this really the intended design?  Not being to re-use a name for a keyword parameter without going through some contortions seems, a little, shall I say, odd?

The issue Type check of parameters was resolved using the depends modifier. As far as I can tell, this modifier is not allowed for expected or keyword parameters, though. Thus the issue seems to reemerge for these types of parameters. Consider the following test example:

createModule := proc(V::Vector)
   local dim := LinearAlgebra:-Dimension(V);
   module()
      export f,g,h;
      f := proc( x::depends('Vector'(dim))              ) x end proc;
      g := proc( x::expects('Vector'(dim)) := something ) x end proc;
      h := proc({x::        'Vector'(dim)  := something}) x end proc;
   end module
end proc:
createModule(Vector(4)):-f(    Vector(4));
createModule(Vector(4)):-g(    Vector(4));
createModule(Vector(4)):-h(x = Vector(4));

The function f is just a restatement of the already resolved issue, compare the above link, while the functions g and h are for the expected and keyword parameter cases, respectively. The problem remains the same: the variable dim is not evaluated for g and h. What to do? Does there exist a solution equally satisfactory as the one for f?

Consider the following two test procedures for creation of the same module:

createModule1 := proc(dim::posint)
    module()
        export det;
        det := (x::Matrix(1..dim,1..dim)) -> Determinant(x);
    end module
end proc:

and

createModule2 := proc(A::Matrix(square))
    local dim;
    dim := RowDimension(A);
    module()
        export det;
        det := (x::Matrix(1..dim,1..dim)) -> Determinant(x);
    end module
end proc:

as well as the following code lines calling these:

createModule1(       2 ):-det(IdentityMatrix(2));
createModule2(Matrix(2)):-det(IdentityMatrix(2));

The first line executes unproblematically, while for the second line an error results concerning the dimensionality check 1..dim,1..dim of the matrix. Why is dim available/initialized in the first version, while not in the second?

Hi,

Need help in plotting the function in the attached file. m, h and k are parameters.

 

Thanks

 

Bessel_Function.mw

Dear Maple users

I know how to fit a function with some parameters to some data, but how can it be done if the data is 2-dimensional? I mean: I have some time array T, some X array and some Y array. How do I fit a function with certain parameters to the data: (x(t),y(t)) to fit (X(T), y(T)), ...

Erik

How can I compute F from G according to the following text? (I implemented this but I need a more efficient implementation.)

 

Given a set G of polynomials which are a subset of k[U, X] and a monomial order with U << X, we want to comput set F from G s.t.


1. F is subset of G and for any two distinct f1, f2 in F , neither lpp (f1) is a multiple of lpp (f2) nor lpp (f2) is a multiple of lpp (f1).


2. for every polynomial g in G, there is some polynomial f in F such that lpp (g) is a multiple of
lpp (f ), i.e. ⟨lpp (F )⟩ = ⟨lpp (G)⟩,

--------------------------------------------------------------------------------------

It is worth nothing that F is not unique.

Example:  Let us consider G = {ax^2 − y, ay^2 − 1, ax − 1, (a + 1)x − y, (a + 1)y − a} ⊂ Q[a, x, y], with the lexicographic order on terms with a < y < x.

Then F = {ax − 1, (a + 1)y − a} and F ′ = {(a + 1)x − y, (a + 1)y − a} are both considered set.

please not that K[U,X] is a parametric polynomial ring (U is e sequence of parameters and X is a sequence of variables).

lpp(f) is leading monomial of f w.r.t. variables X. For example lpp(a*x^2+b*y)= x^2.

This is the code hw2_final.mw

This is the warning 

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 )"

 

How to solve it?

Hello, 

 

I am pretty new to Maple and Im trying to find the parameters of an equation using some kind of fit routine but I can only find such a routine to fit an expression to data and not vice versa.

my equation is as follows

 

epsilon(E):= a0 + a1*ln(E) + a2*ln(E)^2 + a3*ln(E)^3

 

I do have data for E which I imagine I need. 

 

E:= {121, 244, 344, 411, 444, 778, 867, 964, 1085, 1112, 1212, 1299, 1408} all in keV :)

 

Any suggestions/help would be much appreciated, although I am new to the program so go easy on me :) 

 

 

Cheers

Another easy question from a newbie:

Say I have a procedure which, along the its execution, needs to pass a parameter to a different procedure (which, in this case, would be a subroutine) to be elaborated and returned to go on.

This process may happen a few times during the execution and the passing parameter, which may have the same name but different value, needs to be worked on by the subrooutine.

My question is: how do I invoke a procedure from a parent procedure passing one or more parameters and have them returned?

Thank you

Hello

I am working on a project where I need to find the parameters of the formula:

1/2*a*erfc(1/2*2^(1/2)*(-x+m1)/s1)+(1/2-1/2*a)*erfc(1/2*2^(1/2)*(-x+m2)/s2)

which is the formula for the cumulative distribution for two gaussian peaks, one with average m1 and standard deviation s1, the other m2 and s2, with weights a and (1-a). I have data in excel that form the gaussian distribution but now I need to find the parameters of the formula that fits these data.

Is there a command in maple to find these parameters or how do I start? And do I need to upload the data from excel to maple or do I need to insert only some values?

Some one who could help me, because it is really hard and I find no information for this.

Hasselhof

Hi !

I wish to solve a differential equation with an initial condition of the type D(f)(a)=b, where 'a' and 'b' are arbitrary real constants and are entered this way symbolically. Maple interprets D(f)(a) as a function which depends on a new variable 'a' and gives the error:

 

Error, (in dsolve) found differentiated functions with same name but depending on different arguments in the given DE system: {f(a), f(psi)}

(the differential equation is for a function f(psi) which was defined previously)

 

How can I pass this initial condition f'(a)=b (a,b being constants, but arbitrary) to the Maple dsolve command?

I have been browsing the web and looking at manuals, but always find D(f)(0)=3 or any other combination with numbers only.

Thank you in advance.

Regards,

              Michael

 

 

I want to test linearly dependence of a polynomial f on a list of polynomials F by additional condition on parametric coefficients of linear parametric polynomial (linear for variables not parameters). Please note that:

  1. The polynomialand the members of are always homogenous in the variables.
  2. The coefficients of f, the coefficients of the members of F are all always polynomials in the parameters or contant and the members of N and W are all always polynomials in the parameters.

 

For example let

and

(a,b,c,d,e,h are parameters and A1,A2,A3 are variables).

If I use PolyLinearCombo(F,f,{A1,A2,A3}) (see http://www.mapleprimes.com/questions/204469-How-Can-I-Find-The-Coefficients-Of-Linear#comment217621)then its output is false,[].

Now we let to condition sets for parameters as the following:

N:=[ebc+ahd]

W:=[a,c]

The elements of N must be zero means that ebc+ahd=0

and the elements of W are non-zero that is a<>0 and c <>0.

Let a=b=c=d=h=1 and e=-1. This specialization satisfy in the above condition sets N and W. By this specialization we have:

and

Now if I use PolyLinearCombo(F,f,{A1,A2,A3}) then its output is true,[-1,1].

By this additional two condition sets I have to check that whether f is linearly independent of F or not. How can I do this without specialization? In fact I want an algorithm that its input is (null condition N, not-null condition W, list of polynomials F, a polynomial f, the set of variables) and its output is true and coefficients if f is linearly dependent of F w.r.t. null and not-null conditions N and W, else its output is false.

If the name of new procedure is ExtPolyLinearCombo and 

N:=[ebc+ahd]

W:=[a,c]

I want the output of

ExtPolyLinearCombo(N,W,F,f,{A1,A2,A3}) be true,[coefficients]

Thank you very much in advance.

 

 

guys, i have this equation which a, n, c, phi[0] are parameters and r is variable. maple solved this equation with n=0,c=c,phi[0]=5/4-1/4 c but i obtained another solution for this equation : a = 1, c = 5, n = 1, phi[0] = 1 ( you can check). 

 

restart

odesys := {5*r^a+4*n-c*r^n-4*phi[0]}

{5*r^a+4*n-c*r^n-4*phi[0]}

(1)

res := op(odesys);

5*r^a+4*n-c*r^n-4*phi[0]

(2)

 

SOL := solve(identity(res = 0, r), [a, n, c, phi[0]]);

[[a = 0, n = 0, c = c, phi[0] = 5/4-(1/4)*c]]

(3)

NULL

eval(5*r^a+4*n-c*r^n-4*phi[0], [a = 1, c = 5, n = 1, phi[0] = 1])

0

(4)

NULL


how can i get all solutions for a equation like this ?

Download eq000.mw

Trying to use the Explore() to parametrize a couple of plots simultaneously.

According to the help: "A plotting command to be explored can be a function call to plot, plot3d, a command in the plots package, or any user-defined procedure which returns a two- or three-dimensional plot structure or an Array of such plot structures."

However with the definitions

restart;
with(plots):
with(plottools):
Parab1 := ''plot(a*x^2, x = -1 .. 1, y = -3 .. 3)'';
Parab2 := ''plot(a*x^2+1, x = -1 .. 1, y = -3 .. 3)'';
L:=Array(1..2);
L[1]:=Parab1;L[2]:=Parab2;

I then find the following:

Explore(L[1], parameters = [a = -1.0 .. 1.0]);
gives the expected parabola, and the slider updates the parabola dynamically, as expected, and of course the same with L[2] in place of L[1]. However,

Explore(L, parameters = [a = -1.0 .. 1.0])

does not work, giving "Warning, expecting only range variable x in expression a*x^2 to be plotted but found name a". If I use display(L) in the command above, I receive two adjacent plots, as expected but they do not update as the parameter a is changed via the slider.

I'd guess I need to delay or promote variable evaluation somehow, but I can't seem to make it work. What am I missing?

 

 

 

 

 

 

1 2 3 4 5 6 Page 1 of 6