Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are answers submitted by Joe Riel

You forgot

with(plots):

The display and textplot procedures are part of the plots package.

I'll admit to a certain bias, but I'm partial to maplev, an emacs-mode for Maple. I see that it is now distributed with the emacs-goodies Debian package, though I should send them an updated version.

In the Standard gui you can right click on the expression and select "Evaluate at a point" from the drop-down menu, then fill in 4+I.  Or you could type

eval(%,z=4+I);

Do you have to use Maple?  Solving this by hand is straightforward.  Here's a hint, compute

diff(T(x)^2,x)

and see how you can substitute that into expression.

You could use the following procedure

printTable := proc(T::table)
local index;
    printf("table([\n");
    printf("%s\n"
           , StringTools:-Join([seq](sprintf("  %a",index[]=T[index[]])
                            , index in [indices(T)])
                      ,",\n"));
    printf("])\n");
end proc:

 

While it is overkill, you could use maple to solve that linear system:

eq := y=m*x+b:
eqs := map(subs,{{y=y1,x=x1},{y=y2,x=x2}},eq);       
                     eqs := {y1 = m x1 + b, y2 = m x2 + b}

solve(eqs,{m,b});
                           -y1 x2 + x1 y2      -y2 + y1
                      {b = --------------, m = --------}
                              -x2 + x1         -x2 + x1

I'm not sure your true intent.  Expressing u and v as functions of t works:

diff(u(t)*v(t),t);
                        /d      \             /d      \
                        |-- u(t)| v(t) + u(t) |-- v(t)|
                        \dt     /             \dt     /
You could use aliases to make this easier to type and makes the output look like what you want:
alias(u=u(t),v=v(t));
                                     u, v

diff(u*v,t);         
                              /d   \       /d   \
                              |-- u| v + u |-- v|
                              \dt  /       \dt  /

If you aren't restricted to pointplot, you could use Statistics:-LineChart

Statistics:-LineChart(Y, xcoords=X);

What is the "it" you are referring? 

assume(Not(x::posint));

is equivalent to

assume(x::Not(posint));

In both cases, the (final) property is Not(posint).  However, the phrase x::Not(posint), which is of type `::`, is not a property.  It is a phrase that, in the context, applies a property to a variable.

I don't have Maple10 immediately.  However, I don't see why Not(x::posint), or, for that matter x::posint, should have been a property.  Seems to me like a bug that was fixed.

As expected

type(posint, property);
                                             true
type(Not(posint), property);
                                             true

Use unapply to create a procedure from an expression.  However, x and y are local to lister, so you cannot directly access them from pyra.  To fix that, make them parameters of lister and pass them in.  Better yet, modify lister to return procedures. 

Note that the code in lister is not particularly efficient.  Building up a list term by term in a loop is, in Maple, an O(n2) process.  Better to do this with a seq:

a := (u,n) -> max(min(abs(u-4*n)-2*n,n),-n):
b := (u,n) -> max(min(u,1/2*(abs(u-5*n)-abs(u-3*n))),u-8*n):
lister := proc(n)
local u,x,y;
    [seq(unapply([x+a(u,n),y+b(u,n)],x,y), u = 1..8*n)];
end proc:

lister(3);

Because your expression is not a polynomial, fsolve won't find all real roots. You might be able to use RootFinding:-Analytic, but that requires a bit more power than is needed for this problem.

Here is a procedure I wrote some time ago for this sort of problem.

findallroots := proc(eqs, x, rng::range(numeric))
local roots,pts,i;
    roots := {fsolve}(eqs, x, rng, 'avoid' = {x=lhs(rng), x=rhs(rng)});
    if roots = {} or not roots::set(numeric) then
        NULL
    else
        pts := sort([op(rng),op(roots)]);
        op(roots),seq(procname(eqs, x, pts[i-1]..pts[i]), i=2..nops(pts))
    fi
end proc;

f  := sin(4*x)*(exp(-(x-1)^4)):
df := diff(f,x):
a := findallroots(f, x, -2..1);
              a := -0.7853981634, -1.570796327, 0., 0.7853981634

Note that quo can assign the remainder to an optional argument (fourth, with this usage), so you could do

q := (4*a^4-2*a^3+8*a-5) / (3*a^2-1):
(nq,dq) := (numer,denom)(q):
quo(nq,dq,a,'rq') + rq/dq;
                                                   22 a
                          2               - 41/9 + ----
                       4 a    2 a                   3
                       ---- - --- + 4/9 + -------------
                        3      3               2
                                            3 a  - 1

Another possibility is to convert to a continued fraction

convert(q,confrac,a);
                    2
                 4 a    2 a                     22
                 ---- - --- + 4/9 + --------------------------
                  3      3            /    41        229     \
                                    9 |a + -- + -------------|
                                      |    66        /    41\|
                                      |         4356 |a - --||
                                      \              \    66//

Which suggests an easier way to do the original (with a slightly different, but equivalent, form):

map(normal,convert(q,confrac,a));      
                           2
                        4 a    2 a          -41 + 66 a
                        ---- - --- + 4/9 + ------------
                         3      3                2
                                           9 (3 a  - 1)


Did you mean

f := x^3;
g := piecewise(x<=0, m1*x+b1, m2*x+b2);

So is g just piecewise continuous?  Or do we have the additional constraint that m1*c+b1 = m2*c+b2?  In which case it isn't clear how to vary c. 

If we can assume that f > g for 0 < x < 1, then the solution is straightforward:

A := int(f-g, x=0..1):
dA := diff(A, c) assuming c > 0, c < 1;
solve(dA, {c});

Without that assumption, the problem gets significantly more difficult.  You need to check whether this is a minimum or maximum and satisfies the constraints.
                           

You mentioned using basis. That is a command in the deprecated linalg package. You should consider using LinearAlgebra.


First 99 100 101 102 103 104 105 Last Page 101 of 114