Christian Wolinski

MaplePrimes Activity


These are answers submitted by Christian Wolinski

Never mess with builtin functions like D. Use d instead.

restart: with(plots):
alias(c[0]=c0, c[1]=c1, c[2]=c2);
PDE:=diff(C(x,t),t)=d*diff(C(x,t),x,x);
IBC:={C(x,0)=cx0, C(0,t)=ct0, D[1](C)(10,t)=0};
ct0:=1;
cx0:=0;
d:=1;
pds:=pdsolve(PDE,IBC,numeric);
L1:=[0.01, 0.1, 1, 5, 10];
L2:=[red, green, yellow,  blue, magenta, black];
for i from 1 to 5 do
 pn[i] := pds:-plot(t=L1[i], color=L2[i]):
end do:
display({seq(pn[i], i=1..5)}, title=`Numerical solution at t=0.01, 0.1, 1, 5, 10`);

So that is supposed to be the RLC circuit?
If you need then this is from google: https://en.wikipedia.org/wiki/RLC_circuit

L*(diff(x(t), t, t)) + R*(diff(x(t), t)) + (x(t))/(C) = 0;
dsolve(%);

I presume all the other questions You posted are solve the same.

 

Thumb if You like.

subsop(1=1, expr); #for multiplication
subsop(1=0, expr); #for addition
subsop(1=NULL, expr); #for both (?)

That should be M[i,j] := 1;  instead of M[i][j] := 1;

Perhaps DocumentTools package can help you with your task. See ?DocumentTools

One can imagine a function to do this, an extension of unapply, and its application. I believe in early Maple, version 3 there was a way to do this, similar to this:

g := unapply(f, [x], [a,b]);

The above wont work though. Maybe someone should extend unapply.
 

There was an error in your code, I hope you can spot it.

Use this:
 

F1 := proc(Mh := 1)
local m, H, b, a, V, k, p, j, v, chi, appr, u_appr, u_appr_1;
  m := 10;
  H := 1;
  b := 0.02;
  a := 0.05;
  V := array(0 .. m);
  V[0] := 1 - exp(-t);
  for k to m do if k = 1 then chi := 0 else chi := 1 end if;
    p := 0;
    for j from 0 to k - 1 do p := p + V[k - 1 - j]*(diff(V[j], `$`(t, 2)))
       - (diff(V[k - 1 - j], t))*(diff(V[j], t)) - a*(2*(diff(V[k - 1 - j], t)
      )*(diff(V[j], `$`(t, 3)))
       - (diff(V[k - 1 - j], `$`(t, 2)))*(diff(V[j], `$`(t, 2)))
       - V[k - 1 - j]*(diff(V[j], `$`(t, 4))))
    end do;
    p := (p + (diff(V[k - 1], `$`(t, 3)))
     - b*((diff(V[k - 1], `$`(t, 2))) + t*(diff(V[k - 1], `$`(t, 3))))
     - Mh*(diff(V[k - 1], t)))*h*H;
    p := factor(p);
    V[k] := -(int(p, t)) + 0.5*exp(t)*(int(exp(-t)*p, t))
     + 0.5*exp(-t)*(int(exp(t)*p, t)) + chi*V[k - 1] + C1 + C3*exp(-t);
    v := unapply(V[k], t);
    V[k] := frontend(expand, [V[k]]);
    V[k] := subs(C3 = solve(eval(subs(t = 0, diff(V[k], t))), C3), V[k]);
    V[k] := frontend(expand, [V[k]]);
    V[k] := subs(C1 = solve(eval(subs(t = 0, -V[k] - (diff(V[k], t)))), C1), 
    V[k]);
  end do;
  appr := 0;
  for k from 0 to m do appr := appr + V[k] end do;
  u_appr := unapply(appr, h, t);
  u_appr_1 := unapply(diff(u_appr(h, t), t), h, t);
  evalf(u_appr_1(-0.4, t));
  plot([u_appr_1(-0.4, t)], t = 0 .. 4, 0 .. 1.2, color = [black], axes = frame
  );
end proc;

plots[display](F1(2), F1(3));


Thumb if You like.

 

eval(ode, y=exp);

 

Thumb if you like.

Like this:

bix:= [seq(1..4,0.1)];  NN := nops(bix);  
prx:=[seq(1..2,0.1)];  NN1 := nops(prx);
for i  from 1 to NN do    
for j from 1 to NN1 do  
R := dsolve(eval({bc, eq1,eq2}, {bi=bix[i],pr=prx[j]}), fcns, type = numeric, method = bvp[midrich], maxmesh=2400):  
X1[i,j]:=rhs(-R(0)[3]):
end do:  
end do:  

Thumb if You like.

See my answer to an older query:
https://www.mapleprimes.com/questions/209926-How-To-Extract-Symbolic-Coefficient#answer225361
 

function_coeffs := proc(A, v::set(name))
local S, T;
    S := indets(A, {function});
    S := select(has, S, v);
    T := {Non(map(identical, S))};
    frontend(proc(A, S) local V; [coeffs](collect(A, S, distributed), S, 'V'), [V] end proc, [A, S union v], [T, {}])
end proc:

eq := 1.1*cos(t) + 0.8*sin(t) + t^2*x + x;

function_coeffs(eq, {t});


Thumb if You like.

Use this:

sol := solve([seq(E[i] = 0, i = 1 .. 5)], [S, H, r, E, P]):
sol := collect(evala(sol), [RootOf, mu, a, b], factor):
alias(Q = indets(sol, RootOf)[1]):
subs(Q = q, sol);
collect(collect((evala@Norm)(q - Q), q, normal), [q, nu, a, b] ,factor);

Also notice that you are using E as a table (defining E[1..5]) and as variable in equations. This will fail you eventually.


Thumb if You like.

Lookup primpart, content. These can be used to separate variables from coefficients of a monomial. Likewise you could use coeff.

Example
 

K := proc(monomials :: set, V :: {set, list})
   description "Test if the set is a set of multiples of the same monomial in variables V";
   map((x -> primpart(collect(x, V, distributed), V)), monomials);
   if not type(`%`, set(monomial)) then error "Input is not a set of monomials"; fi;
   evalb(nops(`%`) = 1);
end;

K({3*(a+b)*(a-b)+3*b^2, q*a^2}, {a, b});
K({3*(a+b)*(a-b)+3*b^2, q*a^2}, {q});


Thumb if You like.

 

S := remove(type, remove(has, indets(B, function), diff), trig);
frontend(proc(E, S) local V; [coeffs(collect(E, S, distributed), S, 'V')], [V]; end, [B, S], [{Non(function)}, {}]):
V := collect([%], [diff], distributed, factor);

or like this:

S := remove(type, indets(B, function), trig);
frontend(proc(E, S) local V; [coeffs(collect(E, S, distributed), S, 'V')], [V]; end, [B, S], [{Non(function)}, {}]):
V := collect([%], [diff], distributed, factor);
W := ListTools[Classify](proc(E) op(0, convert(E[2], D)); indets(%, name); end, zip(() -> [args], op(V))):
W := map(proc(S) [op](S); map2(map2, op, [1,2], %) end, W);

Thumb if You like.

 

Read the title.
                      

Comonly you would use evalc under assuming real.

For example:
evalc(%) assuming real, R+r*cos(theta)>0, r>0;

Thumb if You like.

First 12 13 14 15 16 17 18 Last Page 14 of 22