Joe Riel

9530 Reputation

23 Badges

20 years, 24 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Just a comment on the code.  Is there a reason you are using both LinearAlgebra and linalg routines?  The latter package is deprecated.

First, you need to precisely define the problem.  Do you want to minimize Int(f-g, 0..1) or Int(abs(f-g), 0..1)?  The latter is considerably more difficult than the former.  Second, just because the derivative is 0 doesn't mean you have a minimum (local or not).

If the absolute value is to be used, then look at the case with m1=0, b1=1/8, m2=1, b2= -1/4.  There are two places where the derivative is 0, both are local minimums, neither corresponds to your proposed solution.

You can take advantage of the Vector constructor and do

for i to 4 do
    e[i] := Vector(4, {i=1});
end do;

Another possibility is to use LinearAlgebra:-UnitVector:

for i to 4 do
   e[i] := LinearAlgebra:-UnitVector(i,4);
end do;

Look at the Statistics package.  To generate a 20x10000 matrix filled with samples of a specific Logistic distribution do, for example

with(Statistics):
X := RandomVariable(Logistic(0.1, 0.5)):
R := Sample(X,[1..20,1..10000]);

Maybe you could give an example of what you want.  Do you have specific values of x in mind?  You could, for example, do

eq := y=x^2+2:
for xx in [1,2,2.3] do
   printf("%f %f\n", xx, eval(rhs(eq),x=xx));
end do:

That only prints the output.  Do you actually want to insert it into a table or Matrix? 

So here's one approach.

restart;
ode1 := diff(y(x),x)^2 + 4*c*diff(y(x),x)+4*c^2*y(x)/(1-x^2);
ics := y(0)=0;
sol := frontend(solve, [ode1, [diff(y(x),x)]], [{`+`,`*`,`^`,list},{}]);
# manually choose one branch
dsol := dsolve(subs(c=3,[sol[1,1],ics]),numeric):
plots[odeplot](dsol,[x,y(x)],0..1);
The other branch is more interesting. Both have a singularity at x=1.

Sum doesn't take a third argument.  Add does, so you might be able to do

Area := add(f(x)*dx, x=a..b, dx)

however, because of round-off the final x value may be less than b.  To avoid that, you can either use fractions for dx, or use integers and scale.  Actually, you don't want to use the final value, so you really should used integers.

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);
First 98 99 100 101 102 103 104 Last Page 100 of 114