mmcdara

7022 Reputation

18 Badges

8 years, 229 days

MaplePrimes Activity


These are questions asked by mmcdara


Can the number of frames per second be changed programmatically in animate and/or animatecurve ?

Thanks in advance

How are constructed binary operators in Maple?
Is it possible to create a binary operator A that we can use this way z := x A y ?

TIA
 

It seems that DrawGraph cannot display the weights of more than 45 arcs of a directed graphs (the arcs themselves are keeping to be displayed correctly).

Maybe a version issue?

WeightedGraphs.mw

Hi
I would like to matrixplot consecutive powers of a matrix. As the name of the matrix is not always the same I wrote a simple "embedded" procedure WM to do this.
This produre works well when called directly, but I don't understand how to make it work when called from animate
 

WM := P -> n -> plots:-matrixplot(P^n, heights=histogram):

U := Matrix(2$2, [0.8, 0.2, 0.4, 0.6]);
WM(U)(1);  #ok whatever the value of the argument of W(U)

plots:-animate(WM(U), [n], n=1..2);  # produces an error

# even this simpler command doesn't work
plots:-animate(plots:-matrixplot, [U^n], n=1..2)  # same error as above

Can you help me to fix this?

TIA

PS: I firstly defined WM this way

WM := proc(P, n)  plots:-matrixplot(P^n, heights=histogram) end proc:

but I met difficulties to tell animate that only n was the parameter to change

How can I use fdiff within Optimization:-NLPSolve and get rid of this error?

Here is an example

restart:
with(Optimization):

# with exact gradient
obj := proc(v)
         10*v[1]^2 - 2*v[1]*v[2]^2 + v[2]^4 + 1 - 2*v[2] + v[2]^2
       end proc:

objgrad := proc(v, w)
        w[1] := 20*v[1] - 2*v[2]^2:
        w[2] := -4*v[1]*v[2] + 4*v[2]^3 - 2 + 2*v[2]
end proc:

NLPSolve(2, obj, objectivegradient=objgrad);
[0.276597509679878506, [0.0364560120817733,0.603788442821000]]


# with approximated gradient estimated "by hand"
objgrad := proc(v, w)
        local eps  := 1e-8:
        w[1] := ( obj(v+~[eps, 0]) - obj(v-~[eps, 0]) )/(2*eps):
        w[2] := ( obj(v+~[0, eps]) - obj(v-~[0, eps]) )/(2*eps):
end proc:

NLPSolve(2, obj, objectivegradient=objgrad);
[0.276597509679878562, [[0.0364560121188285,0.603788442801479]]


# with approximated gradient computed with diff
objgrad := proc(v, w)
        w[1] := fdiff(obj, [1], v);
        w[2] := fdiff(obj, [2], v);
end proc:

NLPSolve(2, obj, objectivegradient=objgrad);
Error, (in Optimization:-NLPSolve) invalid input: fdiff expects its 3rd argument, X, to be of type {algebraic, equation, list(algebraic), list(equation), set(equation)}, but received Vector[row](2, {(1) = 1.0, (2) = 1.0}, datatype = float[8])


Thanks in advance

First 15 16 17 18 19 20 21 Last Page 17 of 45