Joe Riel

9660 Reputation

23 Badges

20 years, 4 days

MaplePrimes Activity


These are answers submitted by Joe Riel

solve(alpha*x - conjugate(alpha)*x=1);
                                          1
              {alpha = alpha, x = - --------------}
                                             _____
                                    -alpha + alpha

It would help to have the actual worksheet.  You can upload it with the green arrow.  It looks as though you are creating symbols, sCR, rather than products, s*C*R, etc.

I looked at the model (tdk7.msim) , which as you suggested, is rather complicated.  It appears as there is a more fundamental problem than the event iteration.  I temporarily prevented that message from occuring by forcing the boolean input to S4 (selector on middle-left) to be constantly true. With that we get the error message "index-1 and derivative evaluation failure on event at t=40.540882".  The cause of that is that the "denominator" to divider D5 (left side of schematic) is going to zero.  Note that its output is from switch S2, one of whose inputs is tied to 0.  You need to figure out how to prevent a division by zero.  I don't know what the model is doing to suggest something.

Your condition is correct.  What is the full error message?  Note that the call to print is invalid, use double-quotes (not single forward quotes) to create a string.

In general, fsolve has more than one way to indicate it didn't find a solution.  It may return NULL.  It may also return the unevaluated call, fsolve(...).

Off the cuff:

- a working concept of Maple's Simplification table
- familarity with the ?debugger
- ?CodeTools package.
- ?debugopts (esoteric, but traceproc and procdump are useful when CodeTools stuff doesn't do what you want)
- ?numelems
- ?_passed, _npassed, _rest, _nrest, _options, etc...
- ?upperbound, lowerbound

If the goal is to be able to manipulate an inert function call and various symbolic parameters, then later evaluate them, you could use the following technique.

s := 1;
U := proc(c) if s = 1 then log(c) else 1/(s-1) end if; end proc: # or whatever ...
y := %U(c)^2 + %s;   # use %U and %s rather than U and s
                                                    2
                                            y := %U(c)  + %s
value(y);
                                                    2
                                               ln(c)  + 1



Rather then assigning Functions2, I'd consider doing

U := proc(c)
global s;
  if not [args]::list(numeric) then return 'procname'(args) end if;
  if s = 1 then
     return log(c);
  else
     return (c^(1-s)-1)/(1-s);
  end if;
end proc:

Then

eval(U(c),Parameters2);
                                  0

By total derivative I assume you mean the gradient.

> y:=(a-3)/(b+3);
                                       a - 3
                                  y := -----
                                       b + 3

> eval(y,[a=r*t,b=s*t]);
                                    r t - 3
                                    -------
                                    s t + 3

> VectorCalculus:-Gradient(%,[r,t]);
                       t    _    /   r      (r t - 3) s\ _
                    ------- e  + |------- - -----------| e
                    s t + 3  r   |s t + 3            2 |  t
                                 \          (s t + 3)  /

Assuming the procedure is still assigned, print it, then copy the output to an input region.  The problem with doing so is that copying it invariably screws up the formatting, so its hard to read. The following routine can be used to avoid that problem:

PrintProc := proc( P :: {name,string,procedure})
local opacity,p;
    p := P;
    if p :: string then
        opacity := kernelopts('opaquemodules'=true);
        p := eval(parse(p));
        kernelopts('opaquemodules'=opacity);
    end if;
    p := debugopts('procdump'=p);
    p := StringTools:-RegSubs("\n *[0-9]+"="\n", p);
    printf("%s\n", p);
end proc:

You might be able to substitute by doing

p := proc() local i,y; y := (i=30); end proc;
pnew := subs((i=30) = (i=50), eval(p));

Addendum: the above subs won't work (as explained in the followup) because i is local to p.

Following pagan's lead, here's another manual approach. I used the naked differentials, but removed them before integrating. Years ago I wrote a Maple package that could integrate such one-forms...some day I should revive it.

deq := A=B*x*d(y)/d(x);
                              B x d(y)
                          A = --------
                                d(x)  
isolate(deq,x);
                          x       A   
                         ---- = ------
                         d(x)   B d(y)
map(`/`,%);
                         d(x)   B d(y)
                         ---- = ------
                          x       A   
eval(%,d=1);
                             1   B
                             - = -
                             x   A
int(lhs(%),x=x1..x2) = int(rhs(%),y=y1..y2) assuming positive;
                                    B (y2 - y1)
                 -ln(x1) + ln(x2) = -----------
                                         A     
combine(%,ln) assuming positive;
                        /x2\   B (y2 - y1)
                      ln|--| = -----------
                        \x1/        A     

Maple doesn't normally handle "naked" differentials (dx, dy), though some packages may permit it.  You could formulate the original equation as a standard Maple differential equation, then use ?dsolve to solve it:

deq := deq := A=B*x*diff(y(x),x):
dsolve({deq, y(x1)=y1});

                               A ln(x)        A ln(x1)
                        y(x) = ------- + y1 - --------
                                  B              B



 

You cannot  necessarily do so.  To see that, do

eq := A[p]*v+C[L]*(M[L]*v*s+B[p]*v+F[L])/A[p]+V[t]*s*(M[L]*v*s+B[p]*v+F[L])/((4*beta)*A[p]) = k[q]*xv-k[qp]*(M[L]*v*s+B[p]*v+F[L])/A[p]:

ex := (lhs-rhs)(eq):
with(LargeExpressions):
collect(ex,[v,xv],Veil[K]);
                                             1/4 K[1] v - k[q] xv + 1/4 K[2]

The above expression is equal to zero, but v/xv cannot be isolated to a constant. 

In control theory one is frequently interested in the derivative, dv/dxv, which can be computed via

isolate(%,v);
tf := diff(%,xv);
Unveil[K](rhs(tf));

I'm not sure what you want to do, but global variables are usually not the best approach. You can assign s to be local to g:

g := proc(y,a,b)
local s;
    s := x -> x+a+b;
    s(y);
end proc:
g(a,b,c);
                  a+b+c

combine(f,radical,symbolic);

Acer's method is nicer than mine. The problem with these approaches, as I hinted at, is that they don't really work with any normal flow. That is, one can use them to show a particular expansion, but doing so will require duplicating the input when assigning.  One way to avoid that is to modify the procedure so that it prints the expansion while returning the value. For example

show:=proc(expr::uneval)
local val;
val := eval(expr);
subsindets(expr,And(name,satisfies(t->type(eval(t),constant))),
``@eval) = val;
val;
end proc:

a := 3: b := 4:
y := show(a+b^2);
(3)+(4)^2 = 19
y := 19

First 50 51 52 53 54 55 56 Last Page 52 of 114