MaplePrimes Questions

I incidently(*) discovered that using MatrixPower to find the square root matrix of a relatively small matrix, returns wrong results, even for symetric positive definite matrices.

Trying to understand how MatrixPower proceeds using showstat is not that easy, but something I'm almost sure is that it doesn't ise an Eigenvectors decomposition.

Here is an example where I'm seeking for a matrix M such that C = M^2 and C is symetric definite positive of dimension 40.
(I didn't check if problems already occurs for smaller sizes)

(*)  I was very bored by the prohibitive execution time of MatrixPower and looked for an alternative.

The matrix M that MatrixPower generates is far from verifying C = M^2 (using the option 'shape'='symmetric' doesn't improve anything).
The naive alternative based on an Eigenvectors decomposition works perfectly well while being 200 times faster.

restart:

with(LinearAlgebra):
with(Statistics):

f := proc(p)
  Sample(Uniform(0, 1), [100, p]):
  CorrelationMatrix(%):
end proc:

C := f(40):

M_MP := CodeTools:-Usage( MatrixPower(C, 1/2) ):

memory used=382.38MiB, alloc change=12.01MiB, cpu time=6.05s, real time=6.26s, gc time=386.00ms

 

LE := proc(R)
  local L, E;
  L, E := LinearAlgebra:-Eigenvectors(evalf(R)):
  L    := map(Re, L):
  E    := map(Re, E):
  E . DiagonalMatrix(sqrt~(L)) . E^(-1)
end proc:

IsDefinite(C, query = 'positive_definite');

M_LE := CodeTools:-Usage( LE(C) ):

true

 

memory used=0.90MiB, alloc change=0 bytes, cpu time=29.00ms, real time=10.00ms, gc time=0ns

 

map(fnormal, M_MP . M_MP - C):
%[1..5, 1..5];

Matrix([[-493.2020830, -3096.801269, 3350.121141, -2972.190814, -6160.797678], [-2436.661317, -6415.706483, 208.1172241, -3001.930739, 1332.904551], [202.2560565, 413.4962022, 799.7833045, -179.6552377, -1817.784899], [-2994.580353, -9862.899715, 2543.110865, -5679.831865, -2552.349252], [-98.63574955, 2078.317993, -3118.445704, 2420.432714, 5905.315145]])

(1)

map(fnormal, M_LE . M_LE - C):
%[1..5, 1..5];

Matrix([[0., -0., -0., 0., 0.], [-0., 0., 0., 0., 0.], [-0., 0., -0., 0., -0.], [0., 0., -0., 0., -0.], [-0., 0., -0., -0., -0.]])

(2)

 

Download MatrixPower_bug.mw

Could someone please exlain this behaviour:

indets('combinat:-binomial(i,j)', 'specfunc(combinat:-binomial)');
indets('combinat:-binomial(i,j)', specfunc('combinat:-binomial'));
indets('combinat:-binomial(i,j)', specfunc(combinat:-binomial));
indets(combinat:-binomial(i,j), specfunc(combinat:-binomial));


indets('combinat:-binomial(i,j)', 'specfunc(binomial)');
indets('combinat:-binomial(i,j)', specfunc('binomial'));
indets('combinat:-binomial(i,j)', specfunc(binomial));
indets(combinat:-binomial(i,j), specfunc(binomial));


indets('binomial(i,j)', 'specfunc(binomial)');
indets('binomial(i,j)', specfunc('binomial'));
indets('binomial(i,j)', specfunc(binomial));
indets(binomial(i,j), specfunc(binomial));

indets('binomial(i,j)', 'specfunc(combinat:-binomial)');
indets('binomial(i,j)', specfunc('combinat:-binomial'));
indets('binomial(i,j)', specfunc(combinat:-binomial));
indets(binomial(i,j), specfunc(combinat:-binomial));

 

I was looking for rewriting some expression in simpler forms and ened up getting wrong values from maple

Is something wrong on how I'm using it or is this a bug ?

This is the code with the output:

> NumericStatus(invalid_operation=false):
> simplify(sum(
>         (A-B)
>         *(-1+combinat:-binomial(N-2,i))
>         *(A)^(i)
>         *(B)^(N-2-i)
>     ,i=0..N-2));
                                                    (N - 1)    (N - 1)
                                                   B        - A



> NumericStatus(invalid_operation);
                                                          false

 

This is the wrong answer, is missing the part with the binomial, somehow its set to zero but the NumericStatus is still telling that everythig is fine.
It has not issues when one replaces the N-2 with N,

> simplify(sum(
>         (A-B)
>         *(-1+combinat:-binomial(N,i))
>         *(A)^(i)
>         *(B)^(N-i)
>     ,i=0..N));
                                          (N + 1)    (N + 1)                  N
                                         B        - A        + (A - B) (A + B)

> NumericStatus(invalid_operation);
                                                          false

 

If I drop the (-1) in front I get the right contribution from the binomial regardless of using N or N-2

> simplify(sum(
>         (A-B)
>         *(combinat:-binomial(N-2,i))
>         *(A)^(i)
>         *(B)^(N-2-i)
>     ,i=0..N-2));
                                                   /A + B\N          N
                                                   |-----|  (A - B) B
                                                   \  B  /
                                                   -------------------
                                                               2
                                                        (A + B)

> NumericStatus(invalid_operation);
                                                          false

which is equal to (A+B)^(N-2)*(A-B)

If I use assume(N>2) it still gives the same result but this time is flagged ad an invalid operation (which is not supposed to).
Interesting enough also if I set assume(N>0) in the second example gives me invalid_operation=true but return the correct result.

Let a, b be arbitrary real parameters. I intend to compute something like: (with exact piecewise output) 

Optimization:-Maximize(8*x + 7*y, {5*y <= 6 - 9*b, -6*x - 4*y <= 8 - 5*a - 7*b, -4*x + 7*y <= -1 - 2*a - 7*b, -x + y <= 6 + 4*a - 5*b, 7*x + 5*y <= a + 4*b}, variables = {x, y}): # Error
Optimization:-Minimize((x - 1)^2 + (2*y - 1)^2, {x - 2*y <= 2*a - b + 1, x + 2*y <= a + b, 2*x - y <= a - b + 1}, variables = {x, y}): # Error

Unfortunately, these Maple codes are virtually invalid, and the relevant commands minimize, maximize, extrema, and Student[MultivariateCalculus][LagrangeMultipliers] do not support general inequality constraints. Is it possible to tackle these small-scale constrained parametric problems in Maple?

Quite often, Maple freezes, and the file cannot be saved, and Maple cannot be closed.

Did you get the problem ?

Can someone give me an example for using

linear regressor function from deep learning package

By passing one dependent variable say Y

And a set of independent variables say X

As a matrix say 

Can we be able to split data into train and test and use this linear regressor command on train and do validation

As I am not able to see some examples on the implementations using command kind help 

I run the following command.

$ maple2022/bin/maple -q problem.mpl

where problem.mpl is the following:

with(Student[Calculus1]):
ShowSolution(Diff(ln(x),x));

I get the following output.

Differentiation Steps
    Diff(ln(x),x)
▫    1. Apply the natural logarithm rule
        ◦ Recall the definition of the natural logarithm rule
        Diff(ln(x),x) = x^(-1)
    This gives:
    x^(-1)

I want the solver to use 1/x instead of x^(-1) in the output. How can I achieve this?

P.S. I require the output to be parsable, so using output=print to show fractions in a multi-line fashion is not a solution for me.

I have this very simple intergral

((Int(sin(m*Pi*y/a), y = 0 .. b))

I want to solve it when m is even then when it is odd. Of course, a and b are real positive. Then I will do the same with the other side of the integral.

Int(sin(n*Pi*y/a)*sin(m*Pi*y/a), y = 0 .. b)

Thank you in advance.

Mario

document:Laplace_Problem.mw

Hi! 

I've been working on a file in Maple, and saved it yesterday - but now I am not able to open it, as it is corrupted. I have been able to find the back up file, HOWEVER I am not able to load half of the file as Maple comes up with a "there was a problem loading your file....". Is there anything I can do to repair the back up file? 

Any help is greatly appreciated!

Back up file is here: C_Users_jonas_OneDrive_Skrivebord_Mat_B-A_Hjemmeopgavesæt_Opgavesæt_1115_MAS_-_Kopi.mw

Is it possible to graph multiple Niquist plots using DynamicSystems:-NiquistPlot() ? All my attemps have failed. 

Thanks.

How I can ontain results without Rootof !!

Thanks

help.mw

restart

EQ1 := c[11]*exp(-n*Pi*a/b)+c[12]*exp(n*Pi*a/b) = 0

c[11]*exp(-n*Pi*a/b)+c[12]*exp(n*Pi*a/b) = 0

(1)

EQ2 := c[11]*n*Pi/b-c[12]*n*Pi/b+b^2*Q[0, 1]*sin(n*Pi*y[0, 1]/b)*(n*Pi*exp(-n*Pi*x[0, 1]/b)/b+n*Pi*exp(n*Pi*x[0, 1]/b)/b)/(n*Pi) = c[21]*n*Pi/b-c[22]*n*Pi/b

c[11]*n*Pi/b-c[12]*n*Pi/b+b^2*Q[0, 1]*sin(n*Pi*y[0, 1]/b)*(n*Pi*exp(-n*Pi*x[0, 1]/b)/b+n*Pi*exp(n*Pi*x[0, 1]/b)/b)/(n*Pi) = c[21]*n*Pi/b-c[22]*n*Pi/b

(2)

c[21] := -b^2*Q[0, 2]*sin(n*Pi*y[0, 2]/b)*exp(-n*Pi*x[0, 2]/b)/(n*Pi)

-b^2*Q[0, 2]*sin(n*Pi*y[0, 2]/b)*exp(-n*Pi*x[0, 2]/b)/(n*Pi)

(3)

EQ3 := c[11]+c[12]+b^2*Q[0, 1]*sin(n*Pi*y[0, 1]/b)*(exp(-n*Pi*x[0, 1]/b)-exp(n*Pi*x[0, 1]/b))/(n*Pi) = lambda.(c[21]+c[22])

c[11]+c[12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q[0, 1]-_Z*n*Pi*exp(-n*Pi*a/b)+_Z*n*Pi*exp(n*Pi*a/b)+(lambda.((exp(-n*Pi*x[0, 1]/b)*exp(n*Pi*a/b)*b^2*sin(n*Pi*y[0, 1]/b)*Q[0, 1]+exp(n*Pi*x[0, 1]/b)*exp(n*Pi*a/b)*b^2*sin(n*Pi*y[0, 1]/b)*Q[0, 1]+2*b^2*Q[0, 2]*sin(n*Pi*y[0, 2]/b)*exp(-n*Pi*x[0, 2]/b)*exp(n*Pi*a/b)+_Z*n*Pi*exp(-n*Pi*a/b)+_Z*n*Pi*exp(n*Pi*a/b))/(n*exp(n*Pi*a/b))))*n*exp(n*Pi*a/b))*Pi*n*exp(n*Pi*a/b))/(Pi*n*exp(n*Pi*a/b))}

(5)

``

Download help.mw

Hi,

Can i use Maple to do satellite image classification . by implement the satellite image so the software will do the math processing ?

First 223 224 225 226 227 228 229 Last Page 225 of 2424