pagan

5147 Reputation

23 Badges

17 years, 125 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

> eqs:={2*x+3*y-z=2,x+y+2*z=2,x-4*y+z=0};
         eqs := {x - 4 y + z = 0, x + y + 2 z = 2, 2 x + 3 y - z = 2}

> A,B:=LinearAlgebra:-GenerateMatrix(eqs,{x,y,z});
                                 [1    -4     1]  [0]
                                 [             ]  [ ]
                         A, B := [1     1     2], [2]
                                 [             ]  [ ]
                                 [2     3    -1]  [2]

> LinearAlgebra:-Determinant(A);
                                      -26

> LinearAlgebra:-LinearSolve(A,B);
                                    [ 10 ]
                                    [ -- ]
                                    [ 13 ]
                                    [    ]
                                    [4/13]
                                    [    ]
                                    [6/13]

> solve(eqs);
                              10
                         {x = --, y = 4/13, z = 6/13}
                              13

Now try these.

> eqs:={2*x+3*y-z=2,x+y+2*z=2,-3*x-4*y-z=-4};
       eqs := {-3 x - 4 y - z = -4, x + y + 2 z = 2, 2 x + 3 y - z = 2}

> AB:=LinearAlgebra:-GenerateMatrix(eqs,{x,y,z},augmented);
                               [-3    -4    -1    -4]
                               [                    ]
                         AB := [ 1     1     2     2]
                               [                    ]
                               [ 2     3    -1     2]

> LinearAlgebra:-Determinant(A[1..3,1..3]);
                                       0

> LinearAlgebra:-LinearSolve(AB); # infinite many solutions
                              [6/5 - 7/5 _t4[2]]
                              [                ]
                              [     _t4[2]     ]
                              [                ]
                              [2/5 + 1/5 _t4[2]]

> eqs:={2*x+3*y-z=2,x+y+2*z=2,-3*x-4*y-z=0};
        eqs := {-3 x - 4 y - z = 0, x + y + 2 z = 2, 2 x + 3 y - z = 2}

> AB:=LinearAlgebra:-GenerateMatrix(eqs,{x,y,z},augmented);
                                [-3    -4    -1    0]
                                [                   ]
                          AB := [ 1     1     2    2]
                                [                   ]
                                [ 2     3    -1    2]

> LinearAlgebra:-Determinant(A[1..3,1..3]);
                                       0

> LinearAlgebra:-LinearSolve(AB); # no solutions
Error, (in LinearAlgebra:-LA_Main:-LinearSolve) inconsistent system

> LinearAlgebra:-ReducedRowEchelonForm(AB);
                              [1    0     7    0]
                              [                 ]
                              [0    1    -5    0]
                              [                 ]
                              [0    0     0    1]

The Optimization package does numerical (not exact symbolic) computation, as the Help explains.

There is also a `minimize` command for exact symbolics, but it does't really handle extra constraints (or assumptions).

Sometimes, you can use `identify` after the fact, to discover a nice exact symbolic result. But since the results from Optimization might not be accurate to `Digits` number of digits, it may be necessary to first apply `evalf` and chop it down a bit. (Optimization routines provide tolerance options for controlling accuracy.)

with(Optimization):

objective:=(1-b^2)/a+(1-c^2)/b+(1-a^2)/c:
cons:={a^2+b^2+c^2 = 1}:

sol1:=Minimize(objective,cons,assume=nonnegative);

identify(evalf(sol1));

Maple has a pretty nice debugger for use with procedures. See ?debugger and ?stopat

> p:=proc()
> local i,j,k;
> for i from 1 to 4 do
>   for j from 1 to 4 do
>     for k from 1 to 4 do
>       evalf(sin(i*j*k));
>     end do;
>   end do;
> end do;
> Pi;
> end proc:
>
> stopat(p);
                                      [p]

>
> p();
p:
   1*  for i to 4 do
         ...
       end do;

DBG> into
p:
   2     for j to 4 do
           ...
         end do

DBG> into
p:
   3       for k to 4 do
             ...
           end do

DBG> into
p:
   4         evalf(sin(i*j*k))

DBG> next
.8414709848
p:
   4         evalf(sin(i*j*k))

DBG> list

p := proc()
local i, j, k;
   1*  for i to 4 do
   2     for j to 4 do
   3       for k to 4 do
   4 !       evalf(sin(i*j*k))
           end do
         end do
       end do;
   5   Pi
end proc

DBG> outfrom
-.7568024953
p:
   3       for k to 4 do
             ...
           end do

DBG> list

p := proc()
local i, j, k;
   1*  for i to 4 do
   2     for j to 4 do
   3 !     for k to 4 do
   4         evalf(sin(i*j*k))
           end do
         end do
       end do;
       ...
end proc

DBG> next
.9893582466
p:
   3       for k to 4 do
             ...
           end do

DBG> into
.9893582466
p:
   4         evalf(sin(i*j*k))

DBG> into
.1411200081
p:
   4         evalf(sin(i*j*k))

DBG> i,j,k
1,
3,
2
p:
   4         evalf(sin(i*j*k))

DBG> cont
                                      Pi

> quit

Use AudioTools:-Create to form h (and s). It places certain attributes on the object that are missing when youi simply form them using the Array constructor.

> with(AudioTools):
> Create(10);
                           [ 1..441000 1-D Array  ]
                           [ Data Type: float[8]  ]
                           [ Storage: rectangular ]
                           [ Order: Fortran_order ]

> attributes(%);
                                 44100, 16, 1
> `index/commutingindexes`:=proc(idx,M,val)
> local idx1:
> idx1:=op(sort(idx));
> if nargs = 2 then
>   # retrieving
>   M[idx1];
> else
>   # storing
>   M[idx1]:=op(val);
> end if:
> end proc:

> A:=Array(commutingindexes,1..3,1..3,1..3);
                          [ 1..3 x 1..3 x 1..3 3-D Array ]
                     A := [ Data Type: anything          ]
                          [ Storage: rectangular         ]
                          [ Shape: commutingindexes      ]
                          [ Order: Fortran_order         ]


> A[3,1,2]:=17:
> A[2,3,1];
                                      17


> A[2,1..3,1..3];
                                [ 0    0    17]
                                [             ]
                                [ 0    0     0]
                                [             ]
                                [17    0     0]

> A[3,1..3,1..3];
                                [ 0    17    0]
                                [             ]
                                [17     0    0]
                                [             ]
                                [ 0     0    0]

Try %e or %a or %g instead of %f.

> x:=3.7e-400:

> printf("%f\n",x);
0.000000

> printf("%e\n",x);
3.700000e-400

> printf("%a\n",x);
.37e-399

> printf("%g\n",x);
3.7e-400

It can be made explicit, as a function of S, yes? That should plot slightly faster.

eq := theta0 = 10 * (exp(1) - exp(S) ) / exp(S):
f:=solve(eq,S):
plot(f,theta0=0..1);
where
> lprint(f);
ln(10/(theta0+10))+1

Did you mean something like this?

plots:-display({graph1,
                plottools:-translate(graph2,25.79084938,0)});

You could also do a change of coordinates, say, when creating graph2.

graph2b:= plot(invlaplace(ybar3,s,t-25.79084938),
               t=25.79084938..50+25.79084938, colour=red):

plots:-display({graph1, graph2b});

The global name D is protected because it is already assigned as a procedure which does differentiation. See ?D

If global name D were inadvertantly assigned to something else, then other parts of Maple which rely upon it would fail to work properly.

Those Villanova worksheets are pretty old and somewhat outdated in general. In current Maple, you can easily plot a Matrix of 2-column data directly.

 C1:=<0,1,5,17>:
 C2:=<3,7,14,17>:
 plot(<C1|C2>);

Also, see ?ImportMatrix and ?ExcelTools[Import] and ?readdata for a few ways to read in data from a text file.

Start by checking ?index,package , by looking at that help page in your Maple (and not in the online help, which will always point at the latest release's help page).

expr:=sqrt(exp(x)*Pi/(2*x))*x*erf(sqrt(x/2))+1;

series(expr,x);

You are treating the argument of g as if it were x+a*f(x), but it is not. It is just x. And so your series expanded about x0 will still have terms involving powers of (x-x0) and not  of (x+a*f(x)-x0).

At the same time, when taking the derivatives you are treating g as if it were only the "outer" f of your composite function. But it is not. Your g is a composition, and so the coefficients of your series will involve differentiating g (and not only f) using the chain rule.

> restart:

> taylor(g(x),x=x0,2): convert(%,polynom);
                           g(x0) + D(g)(x0) (x - x0)
 
> g:=unapply(f(x + a * f(x)),x);
                            g := x -> f(x + a f(x))
 
> eval(%%); # now that g is assigned.
        f(x0 + a f(x0)) + D(f)(x0 + a f(x0)) (1 + a D(f)(x0)) (x - x0)
 
> taylor(f(x+a*f(x)),x=x0,2): convert(%,polynom);
        f(x0 + a f(x0)) + D(f)(x0 + a f(x0)) (1 + a D(f)(x0)) (x - x0)

Perhaps you could focus on working out the first two terms "by hand", and then compare with Maple. Use the chain rule when calculating the derivative of g. Notice that doing so involves finding and multiplying by the derivative of x + a*f(x), which is (1 + a*D(f)(x)). Then compare what you get with these below.

> # the first term, the constant term
> g(x0);
                                f(x0 + a f(x0))

> # the derivative of g
> D(g);
                     x -> D(f)(x + a f(x)) (1 + a D(f)(x))

> # the first derivative of g, applied at x=x0.
> # this will appear in the coefficient of the second term.
> D(g)(x0);
                      D(f)(x0 + a f(x0)) (1 + a D(f)(x0))

> # If D notation is less clear to you than diff notation,
> # then you can also do the following. Note the presence
> # of the term D(f), representing the derivative of the
> # unknown function f. 
> diff(g(x),x);
                                       /      /d      \\
                      D(f)(x + a f(x)) |1 + a |-- f(x)||
                                       \      \dx     //

> convert(%,diff);
                 / d       \|                /      /d      \\
                 |--- f(t1)||                |1 + a |-- f(x)||
                 \dt1      /|t1 = x + a f(x) \      \dx     //

What did you try?

Do you find something wrong with the output of the following?

plot(tan(a),view=[-10..10,-2..2]);
One crude but quick way.
plotsetup(char);
plots:-display(plottools:-circle([0,0],1),
               plottools:-circle([0,0],0.75),
               plottools:-rectangle([-0.25,-0.25],[0.25,0.25]),
               axes=none);
First 37 38 39 40 41 42 43 Last Page 39 of 48