acer

32490 Reputation

29 Badges

20 years, 7 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

The total derivative of h(x,y,z) is usually taken to refer to an independent variable (let's call it t, though it may in fact not represent time). The premise is that the other variables depend upon this t. And then the total derivative is taken to be,

   del h/del t
 + del h/del x * del x/del t
 + del h/del y * del y/del t
 + del h/del z * del z/del t

Now, either you have in mind that there is some variable t upon which each of x,y,z depend, or you consider that two of x,y,z depend upon the third, eg. x(z) and y(z). If it's the latter situation, h(x(z),y(z)) say, then the total derivative may be taken as,

   del h/del z
 + del h/del x * del x/del z
 + del h/del y * del y/del z

Is either of those the case at hand?

ps. It doesn't look like what is commonly termed a vector-valued function, and the Jacobian may not be what you're after.

acer

It should be possible to change Maple's Standard GUI so that it will compress/decompress worksheets on the fly.

It would be preferable if such a change still allowed one to save worksheets as uncompressed XML.

Such files could have an extension such as .mwz. Hopefully that natural choice of filename extension hasn't been exclusively preempted.

acer

.. with the XMLTools package?

acer

Is this what you wanted?

> simplify(y1c);
                               2         3   25   4   17   5
                  1 + x + 1/2 x  + 5/18 x  + --- x  + --- x
                                             144      144

As for the other part,

> y1g := 1 + x*hypergeom([1, 1 + I, 1 - I], [2, 2], x);
             y1g := 1 + x hypergeom([1, 1 - I, 1 + I], [2, 2], x)
 
> series(y1g,x); # you could increase the order
                           2         3   25   4   17   5      6
              1 + x + 1/2 x  + 5/18 x  + --- x  + --- x  + O(x )
                                         144      144
 
> plot( convert(%,polynom), x=0.5..1.0);

What range are you interested in, for the solution? For x<1, you should be able to plot y1g directly.

acer

Not all of Maple takes advantage of all assumptions.

If there isn't an example on a routine's help-page of it working with assumptions, then that's a hint that the routine doesn't respect assumptions.

In the case of `solve`, the help-pages describe `solve`'s ability to deal with assumptions on parameters but not on the main variables (unknowns for which to solve).

There was a time when almost nothing of interest in Maple took advantage of assumptions. This has been changing, slowly. Making some routines utilize assumptions would be very difficult, and could conceivably require a near-full rewrite for the routine in question.

ps. were you expecting a null return for your example, under the assumptions?

acer

Please tell us what `Ranges` and `Img` are.

I am imagining that an efficient in-place solution using the container=V option may be possible. But it'd help to see the structure of Ranges and Img.

acer

fff := proc(dist, s_one, d, n)
option hfloat;
#
# parameters:
#   sample procedure
#   Starting price stock
#   Trailing distance#
#   Number of periods
#
# returns:
#   Profit/loss with stop loss,
#   Profit/loss without stop loss
#
local rand_, i, A, C, w, w_w_, w_w, C_C,
      Exit_period, Exit_price, Last_close;

    rand_:=dist(n):

    # Stock price
    A[1]:=s_one: # Starting price stock
    for i from 2 to n do
        A[i]:=A[i-1]+rand_[i];
    end do:

    # Trailing Stop-Loss
    C[1]:=(A[1]-d):
    for i from 2 to n do
        if A[i]>A[i-1] and A[i]>(A[i]-d)
          and (A[i]-d)>C[i-1] then
            C[i]:=(A[i]-d);
        else
            C[i]:=C[i-1];
        end if;
    end do:

    w[1]:=0:
    for i from 2 to n do
        if A[i]>C[i] then
            w[i]:=0;
        else
            w[i]:=1;
        end if;
    end do;

    w_w_[1]:=0:
    for i from 2 to n do
        w_w_[i]:=(w[i]+w_w_[i-1]);
    end do;

    w_w[1]:=0:
    for i from 2 to n do
        w_w[i]:=(w_w_[i]+w_w_[i-1]);
    end do;

    # Final Corrections
    C_C[1]:=(A[1]-d):
    for i from 2 to n do
        if w_w[i]=0 then
            C_C[i]:=C[i];
        else
            C_C[i]:=C_C[i-1];
        end if;
    end do:

    ############## Results #########
    # Exit period due to stop loss
    Exit_period:=add(`if`(w_w[i]=1,i,0),i=1..n);

    # Exit price stop-loss
    Exit_price:=`if`(Exit_period=0,0,C_C[n]);

    # Last close stock price
    Last_close:=`if`(A[n]<0,0,A[n]);

    # Profit/loss with stop loss,
    # Profit/loss without stop loss
    `if`(Exit_price=0,Last_close-A[1],Exit_price-A[1]),
    Last_close-A[1];

end proc:


randomize():
X := Statistics:-Sample(Statistics:-RandomVariable(Normal(0,1))):

fff( X, 100, 4, 100 );

seq( fff( X, 100, 4, 100 ), i=1..10 );

time( seq( fff( X, 100, 4, 100 ), i=1..1000 ) );

If you need this to be really fast, then the local tables (A, C_C, etc) could be created as float[8] Vectors outside of fff and then get passed in and re-used.

acer

How about putting the whole thing in a procedure called f (which might even take no arguments at all. Have it return that final result. Then call f() repeatedly, or call seq(f(),i=1..10).

acer

I thought that _S01 (and other names similarly prefixed by _S) are what `solve`  uses to manage substitutions internally. That is to say, that they are temporary placeholders that `solve` uses while it does its work. If that's true, then it could well be a bug if they appear in the return value.

Could you post or upload an example of input, and say what Maple version you're using?

acer

Have you read the Maple help-page for limit and limit,return ?

acer

I've tried to lay out a method, and prototype code, for doing this here.

acer

It's not clear what you're asking. It appears to be a question about how to write an assignment. Here's an example,

x := 2*sin(y);

The colon-equals is what does the assignment of the expression 2*sin(y) to name (variable) x. The semicolon at the end is a statement terminator, and completes the command. If I had used a colon at the end then it would still do the assignment but the printing of the output would be suppressed.

Are you also wondering about the rules (eg. arithmetic operators, etc) that can be used to form expressions?

acer

The following should find the radius which minimizes the sum of the distances from the points to the circle.

p1:=[-10,2]: p2:=[-8,5]: p3:=[-1,-12]: p4:=[4,6]: p5:=[10,-1]:
L := [p1,p2,p3,p4,p5]:
CX:=-1: CY:=-4: # the given center
ceq:=(x-CX)^2+(y-CY)^2=r^2:
Optimization:-Minimize(
  add(abs((L[i,1]-CX)^2+(L[i,2]-CY)^2-r^2),i=1..nops(L)),
  r=0..15);
R:=rhs(op(%[2]));
PP:=plots:-pointplot([p1,p2,p3,p4,p5]):
PC:=plots:-implicitplot( subs(r=R,ceq), x=-20..20, y=-20..20):
plots:-display([PP,PC]);

acer

Your idea about how to go about showing it is good.

Write the equation of the line in parametric form, using say the parameter name t.

Now, substitute the formulae(in terms of t) for x, y, and z of that parametric form in for the x, y, and z that appear in the equation for the sphere. That results in a quadratic equation in the parameter t. Now solve that quadratic equation, to get two solutions for t. Plug each of those two values of t into the parametric form of the equation of the line, and those results are the two intersecting points.

Here's how to do those steps in Maple. First, create the points, line, and sphere.

with(geom3d):
point(a,-3,-10,2),point(b,5,14,8):
line(L,[a,b]):
_EnvXName := x: _EnvYName := y: _EnvZName := z:
sphere(s,x^2+y^2+z^2 = 36,[x,y,z]):

Maple can now give the answer right away,

intersection(P,s,L):
coordinates(P[1]);coordinates(P[2]);

Or you can do each step in Maple,

eL:=Equation(L,'t'); # equation of line
es:=Equation(s);

# substitute components of line form into sphere's equation
teq:=expand(eval(es,[x=eL[1],y=eL[2],z=eL[3]]));

# solve the quadratic equation
tsols:=solve(teq,t);

# plug both t values into the line (parametric form).
seq(eval(eL,t=tval),tval in [tsols]);

acer

What is the output from the shell command,

file try_it.so

What is your machine, a G5? And the OSX, is it 10.5? (I'm wondering whether there's a 32/64bit mismatch between the shared library and the Maple binary. I'm wondering whether the shared object needs to be compiled/linked with a -arch flag to force its architecture to match Maple's. Just an idea...)

acer

First 310 311 312 313 314 315 316 Last Page 312 of 337