477 Reputation

9 Badges

6 years, 279 days

MaplePrimes Activity

These are replies submitted by MapleMathMatt



Here, it tests a given number, and returns a pair of truefalse values which indicate if the respective filtered numbers can be used to recreate the given number:

RemoveDuplicatePairs := proc( A :: list( nonnegint ), B :: list( nonnegint ), $ )
    local i, j, n, U, V;
    U := Array( A );
    V := Array( B );
    n := numelems( U );
    for i from 1 to n do
        if member( U[i], V, 'j' ) then
            U[i] := NULL;
            V[j] := NULL;
        end if;
    end do;
    U := convert( U, 'list' );
    V := convert( V, 'list' );
    return ( U, V );
end proc;

GetDigits := proc( p :: posint, $ )
    local A, q, r;
    A := Array( 1 .. 0 );
    q := p;
    while q > 0 do
        q := iquo( q, 10, 'r' );
        A ,= r;
    end do;
    ArrayTools:-Reverse( A, 'inplace' );
    A := convert( A, 'list' );
    return A;
end proc;

CombineDigits := proc( A :: list( nonnegint ), $ )
    local i, n;
    n := numelems( A );
    return add( 10^(n-i) * A[i], i = 1 .. n );
end proc;

FilterNumbers := proc( p :: posint, q :: posint, $ )
    local A, B, pp, qq:
    ( A, B ) := RemoveDuplicatePairs( GetDigits( p ), GetDigits( q ) );
    pp := CombineDigits( A );
    qq := CombineDigits( B );
    return ( pp, qq );
end proc;

RecreateNumber := proc( x :: posint, p :: posint, q :: posint, $ )
    local a, b, s, S, t, T, X;
    ( s, t ) := FilterNumbers( p, q );
    X := GetDigits( x );
    S := GetDigits( s );
    T := GetDigits( t );
    a := evalb( sort( X ) = sort( S ) );
    b := evalb( sort( X ) = sort( T ) );
    return ( a, b );
end proc;
p := 245266;
q := 526676;
x := 24;
y := 66;
z := 76;
s, t := FilterNumbers( p, q );
RecreateNumber( x, p, q ); # true, false
RecreateNumber( y, p, q ); # false, false
RecreateNumber( z, p, q ); # false, true

@jasser I'm not sure I follow the procedure. Are pairs of duplicates to be removed left-to-right? If so, for p=245266 and q=526676, the filtered numbers would be s=42 and t=76. If 6 and 7 are remaining, why 66 and not 76? Or is the goal to take a given number, 66 here, and see if it can be recreated from the leftover digits?


You can generate and export a Matrix of points like this:

Fxp := unapply( F(x), [x,p] ):
Gxp := unapply( G(x), [x,p] ):
XF := Matrix( map( x -> [x,Fxp(x,1)], [ seq( 0..5, 0.2 ) ] ) );
Export( "F-Points.csv", XF );

I'm not clear on what you are asking in Doubt 2, but I believe that the above can be adapted for it.

Hi @thiru4565,

Does this produce what you're after?


de0 := {

ibvc0 := {f(0),(D(f))(0),(D(f))(5)-1,g(0)-1,g(5)};

F := unapply( add(b[k](x)*p^k,k=0..n), x ):
G := unapply( add(c[k](x)*p^k,k=0..n), x ):

de := map( series, eval( de0, {f=F,g=G} ), p=0, n+1 ):

for k from 0 to n do

    if k = 0 then
        ibvc := expand( eval[recurse]( ibvc0, {f=F,g=G,p=0} ) ):
        ibvc := { b[k](0), D(b[k])(0), (D@@2)(b[k])(0), c[k](0), D(c[k])(0) }:
    end if:

    sys := simplify( map( coeff, de, p, k ) ) union ibvc:
    soln := dsolve( sys ):
    b[k] := unapply( eval( b[k](x), soln ), x ):
    c[k] := unapply( eval( c[k](x), soln ), x ):    

end do:

'F(x)' = F(x);
'G(x)' = G(x);

@thiru4565: Could you upload your worksheet in a reply here? That way, others can offer suggestions as well.

Hi @thiru4565,

The function F(x) implicitly depends on parameter p, but you can use eval(). For instance:

plot( eval( [ F(x), diff( F(x), x ) ], p=0.1 ), x=0..5, color=[blue,red] );

Hi @David1,

Maybe you need to set the environment variable MATLAB_SYMBOLIC to maple. Try starting Matlab by executing the following from a Command Prompt:

cd "C:\Program Files\MATLAB\R2017a\bin"
matlab.exe %*

When in Matlab, does

maple( '1' )

return 1 or an error? If it works, you can create a permanent environment variable in the Advanced System Settings of Windows.



@Carl Love 

Here's an example, where one equation is a symbolic multiple of the other:

f := a * x = b;
g := a * x - b;

EquivEQ( f, g ); # true
EquivEQ( f, c * g ); # false
EquivEQ( f, c * g, 'params'={c} ); # true

@Venkat Subramanian

Sorry, I was confused for a second there. (Classic doesn't use Java, so I don't think the Java Access Bridge can have any effect.)


Do you have any screen readers like JAWS or NVDA installed? If so, are you able to run Maple and save worksheets when the reader is disabled?

@Venkat Subramanian

The "God Mode" folder shouldn't affect Classic, since Classic doesn't use Java. The problem may be that you need to enable the Java Access Bridge. To do this, you can insert the line


in the

C:\Program Files\Maple 2017\bin.X86_64_WINDOWS\launch.ini

file. (The path assumes 64-bit Maple 2017 and 64-bit Windows.)



I was having a similar problem with Maple, and a Java crash "hs_log_pid" log file was saved on my desktop. This file referenced "EXCEPTION_ACCESS_VIOLATION" and "msvcr100.dll+0x36adf". After some digging, it turned out that "God Mode" produced similar error messages in other programs, so I tried deleting the "God Mode" folder on my desktop, and then Maple ran and saved files just fine.

I believe that the problem was either caused by or related to the JRE that ships with Maple, and using the latest update of Java 8 no longer produces the error.



The map() command is useful for distributing a function/procedure over a single, specified data container, with the other arguments fixed. For instance, for function phi(x,y,z):

map[2]( phi, a, [b,c], d ); # [ phi(a,b,d), phi(a,c,d) ]

with the index telling Maple which argument to distribute over. Note map=map[1] and map2=map[2].

The operator ~, though, operates element-wise. For phi(x,y,z) again:

phi~( [a,b], c, [d,e] ); # [ phi(a,c,d), phi(b,c,e) ]

Here, the distribution occurs in unison over the two lists (which need to be of the same size).

Of course, the results of map() and ~ may coincide:

phi~( [a,b], c, d );
map( phi, [a,b], c, d );

For your worksheet, using map~() applies map() element-wise, so (see below) X is computed as Y, and Y is computed as Z, and P treats each Ai and Bi (i=1..4) as lists (hence the subscripts):

X := map~( P, [A1, A2, A3, A4], [B1, B2, B3, B4] );
Y := [ map(P,A1,B1), map(P,A2,B2), map(P,A3,B3), map(P,A4,B4) ];
Z := [ P(A1,B1), P(A2,B2), P(A3,B3), P(A4,B4) ];
is( X = Y and Y = Z ); # true


Thanks, Robert. The "&." was indeed a typo, it should be "%.".


Sorry about that. It looks like Maple 2015.2 with Physics2015.mla (from the link I gave earlier) is needed for my code to run. Unfortunately, even with Physics18.mla, Maple 18.02 will throw an error.

1 2 Page 1 of 2