Christian Wolinski

MaplePrimes Activity


These are answers submitted by Christian Wolinski

First convert to piecewise. D(abs)(x) is defined as abs(1, x) and is undefined at x=0. Avoid 0 of the abs function like this:
 

collect(diff(I2, c), abs, normal);
evalindets(%, 'abs(1, anything)', x -> normal(convert(x, piecewise, c))) assuming (c<>-1, c<>-0.9, c<>.9000000000, c<>1);

#or

diff(convert(I2, piecewise, c), c):
map(collect, normal(%), ln, normal@simplify) assuming (c<>-1, c<>-0.9, c<>.9000000000,c<>1);

Thumb if You like.

I am assuming that the answer I got from Maple is correct.

restart;
with(Student:-MultivariateCalculus);
A := [0, 0, 0];
B := [c, 0, 0];
S := [x, 0, z];
solve([Distance(S, A) = a, Distance(S, B) = b], [x, z], explicit = false) assuming (a > 0, b > 0, c > 0);


Perhaps the answer expected is meant to include the domain of real solutions (?). Then:

restart;
with(Student:-MultivariateCalculus);
A := [0, 0, 0];
B := [c, 0, 0];
S := [x, 0, z];
Q := a > 0, b > 0, c > 0;
solve([Distance(S, A) = a, Distance(S, B) = b], [x, z], explicit = true);
ANS := (R -> [R, map(solve @ `union`, [solve]([op(evalc(subs(R, [Im(x), Im(z)])) assuming Q), Q]), {Q}) ]) ~ (%);
%[1];

The result given is:
[x = (1/2)*(a^2-b^2+c^2)/c, z = (1/2)*(-a^4+2*a^2*b^2+2*a^2*c^2-b^4+2*b^2*c^2-c^4)^(1/2)/c]
[{a = -b+c, 0 < b, 0 < c, b < c}, {0 < b, 0 < c, a < b+c, b < c, -b+c < a}, {a = b+c, 0 < b, 0 < c, b < c}, {b = c, 0 < a, 0 < c, a < 2*c}, {a = 2*c, b = c, 0 < c}, {a = b-c, 0 < c, c < b}, {0 < c, a < b+c, c < b, b-c < a}, {a = b+c, 0 < c, c < b}]
[x = (1/2)*(a^2-b^2+c^2)/c, z = -(1/2)*(-a^4+2*a^2*b^2+2*a^2*c^2-b^4+2*b^2*c^2-c^4)^(1/2)/c]
[{a = -b+c, 0 < b, 0 < c, b < c}, {0 < b, 0 < c, a < b+c, b < c, -b+c < a}, {a = b+c, 0 < b, 0 < c, b < c}, {b = c, 0 < a, 0 < c, a < 2*c}, {a = 2*c, b = c, 0 < c}, {a = b-c, 0 < c, c < b}, {0 < c, a < b+c, c < b, b-c < a}, {a = b+c, 0 < c, c < b}

From the above we have abs(b-c) < a < b+c.

Thumb if You like.

Haven't you answered this one in previous posts already? Try something like this:

E := {x, sin(x), ln(y), ln(x+y), exp(z)};
P := randpoly(E, degree=4,terms=8);
F := P -> frontend(proc(E, x) local c; [coeffs(collect(E, x, distributed), x, 'c')], [c] end, [P, indets(P, {'ln(anything), exp(anything)'})], [{Non}(function), {}]);
F(P);
F(expr);

Thumb if You like.

 

I am guessing, but this might be the only way:

null_record:=Record(name, age);
foo:=proc() #some proc that uses same Record layout
global myrecord;
   local S:=Record[null_record]();
   S:-age:=20;
   return S;
end proc:

You may want to look at packed option.

Thumb if You like.

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.

1 2 3 4 5 6 7 Last Page 1 of 9