pagan

5147 Reputation

23 Badges

17 years, 122 days

 

 

"A map that tried to pin down a sheep trail was just credible,

 but it was an optimistic map that tried to fix a the path made by the wind,

 or a path made across the grass by the shadow of flying birds."

                                                                 - _A Walk through H_, Peter Greenaway

 

MaplePrimes Activity


These are answers submitted by pagan

Might the LinearAlgebra:-Generic subpackage be of interest to you?

There is a `mod/Det` routine, and even without loading LinearAlgebra you can issue this:

> restart:
> Det(<<7>>) mod 3;
                                       1

The routine `mod/Det`, which is what gets used above, will call LinearAlgebra:-Modular:-Determinant. So it's  only one (single, wrapping) function-call more expensive. You could do that directly like this:

> LinearAlgebra[Modular][Determinant](3,<<7>>);
                                       1

The IntegerDeterminant routine is for something else entirely. That computes the (non-modular) determinant using modular techniques.

There is no Determinant routine known to mod. So if you do the following then it's likely not what you intended:

> restart:
> with(LinearAlgebra):
> Determinant(<<7>>) mod 3;
                                       1

What the above is actually doing is a very slow non-modular method determinant, following by applying mod to the result.

Do the algebra,

( (110/100) * (90/100) * x ) * 100/(10*x)

Figure out how (and whether) the various pieces of that relate to the given word problem.

Do you have any conditions known about a or b, that can be used as assumptions?

> p := (2310*n^5+5775*n^4+5019*n^3+3507/2*n^2+409/2*n+5/2)
>      /(27720*n^7+97020*n^6+132300*n^5+88200*n^4+29400*n^3+4410*n^2+210*n):

> sol:=numapprox:-remez(t->1,unapply(p,n),1,5,2,2,
>                       array([1,1.5,2,2.5,3,3.5,4,5]),'maxerror');

                                                 -5                  -6
               0.005930443505 + (-0.7573184579 10   + 0.5994428155 10   x) x
   sol := x -> -------------------------------------------------------------
                     0.0065715719 + (0.0718365429 + 0.07071989085 x) x
 
> maxerror;
                                              -7
                               0.6545443957 10
 
> plot(sol,1..5):
> plot(p,n=1..5):

Try setting it up as a call to Optimization:-LPSolve (linear programming), optionally using that routine's Matrix form for input. Set the objective function to 1, and it will return a value if the set is feasible.

Issue the command ?LPSolve,MatrixForm to see the relevant help page.

> Optimization:-LPSolve( 1, eval({(a-2*b-d+2*c)*delta <= d-c-a+b,
>                                 a-b >= d-c, a>=0, b>=0},
>                                [b=2,d=5,delta=2]) );
           [1., [a = 4.99999999999999911, c = 2.00000000000000089]]
Now I change the bound for variable b, and try again,
> Optimization:-LPSolve( 1, eval({(a-2*b-d+2*c)*delta <= d-c-a+b,
>                                 a-b >= d-c, a>=0, b<=0},
>                                [b=2,d=5,delta=2]) );
Error, (in Optimization:-LPSolve) no feasible solution found

Or use the (older) simplex package.

> simplex[feasible]( eval({(a-2*b-d+2*c)*delta <= d-c-a+b,
>                          a-b >= d-c, a>=0, b>=0},
>                         [b=2,d=5,delta=2]) );
                                     true

Use quo or rem.

I tried to post the code, but the editor kept screwing up on me. One last try,

> a1:=(27720*n^(6)+83160*n^(5)+93030*n^(4)+47460*n^(3)+10689*n^(2)+819*n+5):
> a2:=27720*n^(7)+97020*n^(6)+132300*n^(\
> 5)+88200*n^(4)+29400*n^(3)+4410*n^(2)+210*n:
> q := quo( a1*(n+1/2), a2, n, 'r' );
                                    q := 1
 
> r;
                        5         4         3           2
            5/2 + 2310 n  + 5775 n  + 5019 n  + 3507/2 n  + 409/2 n
 
> simplify( a1*(n+1/2)/a2 - q - r/a2 );
                                       0
 
> q - r/a2;
                          5         4         3           2
              5/2 + 2310 n  + 5775 n  + 5019 n  + 3507/2 n  + 409/2 n
  1 - -----------------------------------------------------------------------
             7          6           5          4          3         2
      27720 n  + 97020 n  + 132300 n  + 88200 n  + 29400 n  + 4410 n  + 210 n

If you have already entered a1/a2 instead as `a`, then you could use

q := quo( numer(a)*(n+1/2), denom(a), n, 'r' );

From the description of the problem, it sounds as if you are having trouble viewing the contents of Matrices/Vectors/Arrays. If that is so then you may wish to increase the cut-off, above which you can only see the "summary" of such objects.

> interface(rtablesize);
                                      10
 
> Vector[row]( [1,2,3,4,5,6,7,8,9,10,11] );
                           [ 11 Element Row Vector ]
                           [ Data Type: anything   ]
                           [ Storage: rectangular  ]
                           [ Order: Fortran_order  ]
 
> interface(rtablesize=100):

> Vector[row]( [1,2,3,4,5,6,7,8,9,10,11] );
                      [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Of course, as Alec has shown, you could also simply use lists instead of Vectors as input to Statistics:-Mean and friends.
> f := x->2/(x^3+1):

> finv := unapply([solve(f(t)=G,t)][1],G);
                                                2 1/3
                                      ((2 - G) G )
                         finv := G -> ---------------
                                             G
 
> simplify(f(finv(x)));
                                       x
 
> simplify(finv(f(x))) assuming x>0;
                                       x


> finv := unapply([solve(f(t)=G,t)][3],G);
                                    2 1/3          1/2           2 1/3
                          ((2 - G) G )      1/2 I 3    ((2 - G) G )
        finv := G -> -1/2 --------------- + --------------------------
                                 G                      G


> simplify(finv(f(x))) assuming x>-1, x<0;
                                       x

Logical equivalence is not the same as logical implication.

Suppose that you have two logical expressions, a and b. Then, they are equivalent if a implies b and b implies a.

Mathematicians sometimes phrase this as "a if and only if b". And the Logic package supplies that particular biconditional material implication as &iff.

The command,

Logic:-Implies( a, b )

tests that a implies b.

The command

Logic:-Equivalent( a, b )

tests both that a implies b and that b implies a (ie. that a if and only if b).

I suspect that you might have confused things a little bit by using the unfortunate choice of the term "logically equivalent command" in your original post and its title. I believe that you simply meant that you wanted a translation to Maple notation, and not that you particularly wanted to test logical equivalence.

Now, the following is always true, and so the Tautology routine returns true for it,

> expr := ((p &implies q) &and (q &implies r)) &implies (p &implies r):

> Logic:-Tautology(expr);
                                     true

The converse is not true, as illustrated below,

> Logic:-Implies( (p &implies r), ((p &implies q) &and (q &implies r)) );
                                     false

> converse_expr := (p &implies r) &implies ((p &implies q) &and (q &implies r)):

> Logic:-Tautology(converse_expr);
                                     false

I believe that you were not originally asking about these next results,

> biway_expr := ((p &implies q) &and (q &implies r)) &iff (p &implies r):

> Logic:-Tautology(biway_expr);
                                     false

> Logic:-Equivalent( ((p &implies q) &and (q &implies r)), (p &implies r) );
                                     false

Wikipedia is a little weird about its logic explanations. But you could try this and this.

> expr:=(-f(xn)^2*f(zn)+f(xn)^2*D(f)(zn)*zn+f(xn)*f(zn)^2
>       -2*f(xn)*f(zn)*D(f)(zn)*zn+D(f)(zn)*xn*f(zn)^2)
>       /D(f)(zn)/(f(zn)^2+f(xn)^2-2*f(xn)*f(zn)):
 
> length( simplify(expr, size) );
                                      212

 
> map(t->factor(numer(t))/factor(denom(t)),collect(expr,D));
           2                                 2
      f(xn)  zn - 2 f(xn) f(zn) zn + xn f(zn)          f(xn) f(zn)
      ---------------------------------------- - ------------------------
                                 2               (f(xn) - f(zn)) D(f)(zn)
                  (f(xn) - f(zn))
 
> length(%);
                                      175
> Logic:-Implies( ( (p &implies q) ∧ (q &implies r) ), p &implies r );
                                     true
 
> expr := ((p &implies q) ∧ (q &implies r)) &implies (p &implies r);
     expr := ((p &implies q) ∧ (q &implies r)) &implies (p &implies r)
 
> Logic:-Tautology(expr);
                                     true

It seems as easy to convert to a list of the digits as it is to convert to a string of the digits.

> f := proc(n)
> local l;
>   l := convert(n, base, 10);
>   evalb(l = ListTools:-Reverse(l));
> end proc:
> g := proc(n)
> local s;
>    s := convert(m, string);
>    evalb(s = StringTools:-Reverse(s));
> end proc:

Now, efficiency is another question. It might be faster to grab the first half digits, form a reverse number with those, and compare that to the second half digits number. You could use repeated irem calls, or convert(..,base) and ListTools:-Reverse, or convert(...,string) and StringTools:-Reverse to do the flip of the first half digits.

> F := proc(n)
> local a, m, r, t;
> a := ceil(log[10](1.0*n));
> if type(a,odd) then
>   m := (a-1)/2;
>   t := irem(n,10^(m+1));
>   irem(n,10^m,'r');
> else # a is even
>   m := a/2;
>   t := irem(n,10^m,'r');
> end if;
> evalb(parse(StringTools:-Reverse(convert(r,string))) = t);
> end proc:
>
> F(743347);
                                     true
 
> F(749347);
                                     false
 
> F(7439347);
                                     true
 
> F(7499347);
                                     false

What were the actual inputs that you entered which produce these error messages?

For the "unable to parse" problem, are you saying that it works in Worksheet mode but not in Document mode (both run in the Standard GUI, not Classic)?

 

How do you want the points plotted? In a polar coordinate system? Or in rectilinear coordinates (which represent the r and theta)?

You could try these. Each complex value in list L is converted to a separate list (of modulus and argument).

L:=[1+sqrt(3)*I,-1+sqrt(3)*I,sqrt(2)+I];
map(t->[op(convert(t,'polar'))],L);
plots:-polarplot(map(t->[op(convert(t,'polar'))],L),style=point);
plots:-pointplot(map(t->[op(convert(t,'polar'))],L),view=[-3..3,-3..3],style=point);
First 44 45 46 47 48 Page 46 of 48