acer

32405 Reputation

29 Badges

19 years, 349 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

The GUI does not actually use a Maple command, when it adjusts the plot's characteristics via that right-click menu. What the GUI has at hand is the PLOT call structure.

There is some new-ish "re-draw" stuff related to a command that the Maple plotting commands sometimes inject as text into the plotting structure -- eg. PLOT function call, as structure. It can use that now for some zooming. For example you can zoom out of the following plot, and magically the (post Maple 2022) GUI will cause the plot command to be reformed with a widened range, and reexecuted.

P:=plot(sin(1/x), x=0..1, gridlines=true):
indets(P,"input"=anything); # outputs the following:

{"input" = [table([1 = plot, 2 = [sin(1/x)], 3 = (x = 0 .. 1), 4 = (gridlines = true)]), "originalview" = [0.0000192831942484872343 .. 0.997499999997671694, -1. .. 1.], "originalaxesticks" = AXESTICKS(DEFAULT, DEFAULT, _ATTRIBUTE("source" = "mathdefault"))]}

So, that is actually stored in the PLOT function call (data structure) that the Library plot command produces, in modern Maple. And when the rendered, inline plot is zoomed out then the GUI is now able to send a modified reconstruction of the plotting command call, to the kernel. The original structure only had data computed for x=0..1, but after zoom-out the reexecuted call can recalculate for the wider range.

But the GUI's knowledge of how to adjust the call is limited. It knows how to change the range, but not everything. And not all plotting commands store the details in the structure. And, importantly, there's no place for the GUI to hand back the modified command (or even the new output structure) to the user.

A plot in a PlotComponent does allow the user to access the GUI's stored structure. If you right-click the above plot when inside a PlotComponent, and change the color, then you can programmatically extract the modified plot structure from the embedded component (GetProperty). But unfortunately the spiffy zoom-out redraw/reexecute thing doesn't seem to work in a component. And the GUI lacks knowledge about how to itself adjust the relevant stored command data, in most cases.

That leaves the PlotBuilder. You can issue,
   PlotBuilder(lhs(eq));
and, in the right-panel, modify the range and the gridline choices, etc, and toggle on the "Show Command" button. That can be a handy way to explore various option choices, and see/copy the underlying command. Unfortunately it doesn't yet support discrete data (eg. your list of numeric root values, for which pointplot could be a choice).

@salim-barzani In the attached variant, the lastest parameter values used in the exploration are available (outside the exploration). They are assigned in a list to the name last.

graph_in_simple_shape_accc.mw

You could, of course, subsequently programmatically substitute those values into your M expression, if you also need that.

Alternatively, the following variant has the latest instance of M (substituted) assigned to the name last.

graph_in_simple_shape_acccB.mw

restart;

kernelopts(version);

`Maple 2024.1, X86 64 LINUX, Jun 25 2024, Build ID 1835466`

eq:=-0.0004*x^2 - 2.7680*10^(-28)*x^12 - 2.1685*10^(-43)*x^18 - 1.3245*10^(-37)*x^16 - 1.6917*10^(-32)*x^14 + 0.7650 + 6.6773*10^(-18)*x^8 - 2.5543*10^(-23)*x^10 - 8.0002*10^(-13)*x^6 + 3.6079*10^(-8)*x^4 = 0:

plot(lhs(eq),x=-210..210,size=[500,200]);

fsolve(eq);

-202.6025057, -111.9794723, -49.07370166, 49.07370166, 111.9794723, 202.6025057

solve({eq, x<infinity}, x);

{x = -202.6025057}, {x = -111.9794723}, {x = -49.07370166}, {x = 49.07370166}, {x = 111.9794723}, {x = 202.6025057}


Download r01.mw

You can supply 

    output=L

to the,

   CodeTools:-Usage

command call. The list L can contain items like, value, realtime, bytesalloc, etc.

That makes it return an expression sequence of all those output choices. So you can get your hands on the timing/mem results programatically, as additional returned results.

You can then store items in that returned expression sequence, as you see fit. And your computation's own result is included in that sequence, if value is an item in the list L.

That's in contrast to the default behavior of a merely printed message containing the various stats, and only the value as single returned result.

Is this something like what you're after? (I realize that the final construct is not in terms of functional differential operators.)

I've used PDEtools:-undeclare(prime) to get the derivatives displayed in a "subscripted" notation.

restart

interface(showassumed = 0)

assume(tau::real); assume(sigma::real); alias(G = G(tau, sigma), F = F(tau, sigma))

PDEtools:-undeclare(prime, quiet)

X := G/F; Z := sigma+2*(diff(log(F), tau)-(diff(log(F), sigma)))

G/F

 

sigma+2*(diff(F, tau))/F-2*(diff(F, sigma))/F

(1)

X_tau_tau := simplify(diff(X, tau, tau)); X_sigma_sigma := simplify(diff(X, sigma, sigma))

((diff(diff(G, tau), tau))*F^2-2*(diff(G, tau))*(diff(F, tau))*F-G*(diff(diff(F, tau), tau))*F+2*G*(diff(F, tau))^2)/F^3

 

((diff(diff(G, sigma), sigma))*F^2-2*(diff(G, sigma))*(diff(F, sigma))*F+2*G*(diff(F, sigma))^2-G*(diff(diff(F, sigma), sigma))*F)/F^3

(2)

Z_tau := simplify(diff(Z, tau)); Z_sigma := simplify(diff(Z, sigma)); Z_tau_sigma := simplify(Z_tau+Z_sigma)

(-2*(diff(diff(F, sigma), tau))*F+2*(diff(F, sigma))*(diff(F, tau))+2*(diff(diff(F, tau), tau))*F-2*(diff(F, tau))^2)/F^2

 

1+2*(diff(diff(F, sigma), tau))/F-2*(diff(F, sigma))*(diff(F, tau))/F^2-2*(diff(diff(F, sigma), sigma))/F+2*(diff(F, sigma))^2/F^2

 

(2*(diff(F, sigma))^2-2*(diff(diff(F, sigma), sigma))*F+F^2+2*(diff(diff(F, tau), tau))*F-2*(diff(F, tau))^2)/F^2

(3)

eq := F^2*simplify(X_tau_tau-X_sigma_sigma+Z_tau_sigma*G/F) = 0

-(diff(diff(G, sigma), sigma))*F+2*(diff(G, sigma))*(diff(F, sigma))-G*(diff(diff(F, sigma), sigma))+(diff(diff(G, tau), tau))*F+F*G-2*(diff(G, tau))*(diff(F, tau))+G*(diff(diff(F, tau), tau)) = 0

(4)

D_tau_tau_G_F := (diff(G, tau, tau))*F-2*(diff(G, tau))*(diff(F, tau))+G*(diff(F, tau, tau)); D_sigma_sigma_G_F := (diff(G, sigma, sigma))*F-2*(diff(G, sigma))*(diff(F, sigma))+G*(diff(F, sigma, sigma))

(diff(diff(G, tau), tau))*F-2*(diff(G, tau))*(diff(F, tau))+G*(diff(diff(F, tau), tau))

 

(diff(diff(G, sigma), sigma))*F-2*(diff(G, sigma))*(diff(F, sigma))+G*(diff(diff(F, sigma), sigma))

(5)

simplify(eq, {D_tau_tau_G_F = Diff(G*F, tau, tau), D_sigma_sigma_G_F = Diff(G*F, sigma, sigma)})

F*G+Diff(F*G, tau, tau)-(Diff(F*G, sigma, sigma)) = 0

(6)

NULL

NULL

Download BE_ac.mw

I realize that this has some flaws; it can't get by discontinuities in the numeric solving, due to the set-up. But perhaps it might inspire you.

(I can't help but feel that I once knew some better way, but right now cannot recall it. I'm sure I'll kick myself, shortly.)

restart;

with(plots): interface(warnlevel=0):

epsilon := .01:

pot := 1/sqrt(x^2+y^2+epsilon)-1/sqrt((x-.25)^2+y^2+epsilon):

CP := contourplot(pot,x=-.1..0.35,y=-.25..0.25,contours=15,color="Burgundy"):

ds := dsolve({diff(y(x),x)=-1/subs(y=y(x),implicitdiff(pot,y,x)),y(0.125)=par},
             y(x),numeric,parameters=[par],abserr=1e-5):

SL := proc(p)
  ds(':-parameters'=[par=p]);
  display(odeplot(ds,[x,y(x)],x=-0.1..0.35,color=blue));
end proc:

display(CP, seq(SL(y0),y0=-3..3,0.04),
        view=[-0.1..0.35,-0.25..0.25]);

Download Dipole_fields_ac.mw

Is this the kind of thing you're after?

restart

_local(gamma)

with(PDEtools)

with(Physics)

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

NULL

pde := -I*(diff(U(xi), xi))*gamma*k*mu+I*gamma*(diff(U(xi), xi))*sigma*w+(diff(diff(U(xi), xi), xi))*gamma*k*w+U(xi)*gamma*mu*sigma+(2*I)*(diff(U(xi), xi))*k*sigma+2*alpha*U(xi)^3+(diff(diff(U(xi), xi), xi))*k^2-I*(diff(U(xi), xi))*w-U(xi)*sigma^2-U(xi)*mu

-I*(diff(U(xi), xi))*gamma*k*mu+I*(diff(U(xi), xi))*gamma*sigma*w+(diff(diff(U(xi), xi), xi))*gamma*k*w+U(xi)*gamma*mu*sigma+(2*I)*(diff(U(xi), xi))*k*sigma+2*alpha*U(xi)^3+(diff(diff(U(xi), xi), xi))*k^2-I*(diff(U(xi), xi))*w-U(xi)*sigma^2-U(xi)*mu

case1 := [mu = -(4*gamma*k*w+4*k^2-sigma^2)/(gamma*sigma-1), A[0] = 0, A[1] = -RootOf(_Z^2*alpha+gamma*k*w+k^2), B[1] = RootOf(_Z^2*alpha+gamma*k*w+k^2), w = (gamma*k*mu-2*k*sigma)/(gamma*sigma-1)]

G1 := U(xi) = 2*RootOf(_Z^2*alpha+gamma*k*w+k^2)/sinh(2*xi)

`~`[`=`]([mu, w], eval([mu, w], case1)); C1 := solve(%, [mu, w])[]

[mu = -(4*gamma*k*w+4*k^2-sigma^2)/(gamma*sigma-1), w = (gamma*k*mu-2*k*sigma)/(gamma*sigma-1)]

[mu = (4*gamma*k^2*sigma+gamma*sigma^3+4*k^2-sigma^2)/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1), w = -k*(4*gamma*k^2+gamma*sigma^2-2*sigma)/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1)]

newcase1 := [op(C1), op(`~`[`=`]([A[0], A[1], B[1]], eval([A[0], A[1], B[1]], case1)))]

[mu = (4*gamma*k^2*sigma+gamma*sigma^3+4*k^2-sigma^2)/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1), w = -k*(4*gamma*k^2+gamma*sigma^2-2*sigma)/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1), A[0] = 0, A[1] = -RootOf(_Z^2*alpha+gamma*k*w+k^2), B[1] = RootOf(_Z^2*alpha+gamma*k*w+k^2)]

pde3 := eval(pde, newcase1)

-I*(diff(U(xi), xi))*gamma*k*(4*gamma*k^2*sigma+gamma*sigma^3+4*k^2-sigma^2)/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1)-I*(diff(U(xi), xi))*gamma*sigma*k*(4*gamma*k^2+gamma*sigma^2-2*sigma)/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1)-(diff(diff(U(xi), xi), xi))*gamma*k^2*(4*gamma*k^2+gamma*sigma^2-2*sigma)/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1)+U(xi)*gamma*(4*gamma*k^2*sigma+gamma*sigma^3+4*k^2-sigma^2)*sigma/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1)+(2*I)*(diff(U(xi), xi))*k*sigma+2*alpha*U(xi)^3+(diff(diff(U(xi), xi), xi))*k^2+I*(diff(U(xi), xi))*k*(4*gamma*k^2+gamma*sigma^2-2*sigma)/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1)-U(xi)*sigma^2-U(xi)*(4*gamma*k^2*sigma+gamma*sigma^3+4*k^2-sigma^2)/(4*gamma^2*k^2+gamma^2*sigma^2-2*gamma*sigma+1)

odetest(eval(G1, newcase1), pde3)

0

pde4 := collect(pde3, [U(xi)], simplify)

2*alpha*U(xi)^3-4*k^2*U(xi)/(1+(4*k^2+sigma^2)*gamma^2-2*gamma*sigma)+(diff(diff(U(xi), xi), xi))*k^2/(1+(4*k^2+sigma^2)*gamma^2-2*gamma*sigma)

odetest(eval(G1, newcase1), pde4)

0

Download test_sol_for_PDE1_ac.mw

You have mixed up the order of the arguments. You've used a different order, in two different places.

You have DOE set up with the columns (apparently) being:
    epsilon, A, Br, N, beta, m, lambda0, lambda1

But you constructed your procedure Fop to treat its arguments as if the order were,
    A, Br, N, beta, epsilon, lambda[0], lambda[1], m

I'm guessing that the wrong one is your construction of Fop, because there you just used a lexicographic order, and ignored how you set up the columns of DOE.

So I suppose that you wanted Fop more like this: Answer_not_same_ac.mw

Such a placeholder is not required. And you don't need to substitute into a diff(...) result.

Instead, you can just use D(W). You can use it as D(W)(u(t)) in your DE for dsolve. And you can use it for D(W)(u) in your fieldplot call.

And you also don't need to define W the same way, a second time. Since the original W was defined before the parameters were assigned values then calls to W or D(W) will pick up the latest parameter values assigned.

So your same processes can become more tidy and legible, eg, proteins_ac.mw

If you really want to visualize the latest parameter values in the formula then you can just invoke it to print it, eg.
   D(W)(Un);

If you want you can assign D(W) to some name, to avoid having D repeat effort. Eg,
   dW := D(W);
and then use that. Eg. proteins_acc.mw

You could put all your procedures into a package module, and then LibraryTools:-Save that instead.

See also the relevant section of the Programming Guide.

Here are various ways in which one may leverage the collect command to attain the target form.

restart;

Zin := ((Rsp + (omega*L2 - omega02^2*L2/omega)*I)*(Rpp + (omega*L1 - omega01^2*L1/omega)*I) + 0.01*omega^2*L1*L2)/(Rsp + (omega*L2 - omega02^2*L2/omega)*I);

((Rsp+I*(omega*L2-omega02^2*L2/omega))*(Rpp+I*(omega*L1-omega01^2*L1/omega))+0.1e-1*omega^2*L1*L2)/(Rsp+I*(omega*L2-omega02^2*L2/omega))


Zout := Rpp + (omega*L1 - omega01^2*L1/omega)*I + (0.01*omega^2*L1*L2)/(Rsp + (omega*L2 - omega02^2*L2/omega)*I);

Rpp+I*(omega*L1-omega01^2*L1/omega)+0.1e-1*omega^2*L1*L2/(Rsp+I*(omega*L2-omega02^2*L2/omega))

First, lets assign that denominator to a name, so that we
can more easily manipulate and collect/simplify w.r.t it.

FF:=1/select(type,Zin,anything^(-1));

Rsp+I*(omega*L2-omega02^2*L2/omega)

Let's also veil that 0.01 float, using a placeholder for it. Otherwise various reasonable techniques will get some
subexpression with coefficients of 1. or 1.000..., etc.
(Converting it to rational is not helpful, if you want only that very same float back at the end.)
We can't freeze a float directly, to I'll also wrap with a dummy function.

temp := simplify(subsindets(Zin,float,freeze@__K),{FF=FFF});

((I*L1*omega^2-I*L1*omega01^2+Rpp*omega)*FFF+L1*L2*omega^3*`freeze/R0`)/(omega*FFF)

Going for the target just as you had it, ie. some subexpressions not completely factors w.r.t L1, L2.

Since we cannot collect w.r.t imaginary unit I directly, temporarily replace that too.

subs(I=II,temp):
eval(collect(%,[Rpp,II,omega01],thaw),[II=I,FFF=FF,__K=(x->x)]);

Rpp+I*(omega*L1-omega01^2*L1/omega)+0.1e-1*omega^2*L1*L2/(Rsp+I*(omega*L2-omega02^2*L2/omega))

Alternatively, frontend the collect, so that we may collect w.r.t I.

eval(frontend(collect,[temp,[Rpp,L2,I,omega],thaw],
              [{`+`,`*`,list},{}]),
     [FFF=FF,__K=(x->x)]);

Rpp+I*(omega*L1-omega01^2*L1/omega)+0.1e-1*omega^2*L1*L2/(Rsp+I*(omega*L2-omega02^2*L2/omega))

The choice of variables for which we may collect is not unique.

subs(I=II,temp):
eval(collect(%,[FFF,Rpp,II],thaw),[II=I,FFF=FF,__K=(x->x)]);

Rpp+I*(L1*omega^2-L1*omega01^2)/omega+0.1e-1*omega^2*L1*L2/(Rsp+I*(omega*L2-omega02^2*L2/omega))

These are the kind of irritating 1.000... artefacts that may arise if we
don't veil that float coefficient.

simplify(Zin,{FF=FFF});
eval(collect(subs(I=II,%),[FFF,Rpp,II,omega],thaw),[II=I,FFF=FF]);

0.1000000000e-1*((100.*I)*FFF*L1*omega^2-(100.*I)*FFF*L1*omega01^2+L1*L2*omega^3+100.*FFF*Rpp*omega)/(omega*FFF)

1.000000000*Rpp+I*(1.000000000*omega*L1-1.000000000*omega01^2*L1/omega)+0.1000000000e-1*omega^2*L1*L2/(Rsp+I*(omega*L2-omega02^2*L2/omega))

As I mentioned in my Reply, some of the subexpressions may
be further factored (say, w.r.t L1 or L2).

eval(collect(temp,[FFF,Rpp,L2],simplify@thaw),[FFF=collect(FF,L2),__K=(x->x)]);

Rpp+I*L1*(omega^2-omega01^2)/omega+0.1e-1*omega^2*L1*L2/(I*(omega-omega02^2/omega)*L2+Rsp)

Download collect_I_ex.mw

You can simply pass the explicit option, to get the result in terms of explicit radicals directly from the solve command.

eq1 := y=1/2*(x-5)^2-6:
eq2 := y=3*x-2:

solve([eq1,eq2],{x,y},explicit);

{x = 8+47^(1/2), y = 22+3*47^(1/2)}, {x = 8-47^(1/2), y = 22-3*47^(1/2)}


Download solve_sys_expl.mw

In other words, you don't need to use two different commands to get the roots in radical form.

For a polynomial system involving more than one variable then results involving roots/radicals are not expressed in explicit form by default (even for this low degree).

See also the subsection Controlling the Form of Solutions in the Help page for topic solve,details . (Unfortunately, the difference between a single polynomial in one variable and system is not made entirely clear there, in this respect.)

First, and most importantly, notice that,
   0 < x and x <> 2
evaluates to just,
   0 < x
since <> and = evaluate as if under evalb, with active and.

In this case you are running into the effect of,

evalb( x <> 2 );
             true

So 0 < x and x <> 2 becomes 0 < x and true, which becomes just 0<x . Not what you intended!

This subtlety has caught out many Maple users; you're in good company.

Instead, you can use an inert form such as (captitalized) And .

restart;


Note that the following produces just x>0
So don't pass that to solve !

0 < x and x <> 2

0 < x

d2 := solve(And(0 < x, x <> 2), x);

RealRange(Open(2), infinity), RealRange(Open(0), Open(2))

lprint(d2);

RealRange(Open(2),infinity), RealRange(Open(0),Open(2))

map[2](`::`,x,Or(d2));

Or(x::(RealRange(Open(2), infinity)), x::(RealRange(Open(0), Open(2))))

convert(%, relation);

Or(And(2 < x, x <= infinity), And(0 < x, x < 2))

map[2](`in`,x,Or(d2));

Or(`in`(x, RealRange(Open(2), infinity)), `in`(x, RealRange(Open(0), Open(2))))

convert(%, relation);

Or(And(2 < x, x <= infinity), And(0 < x, x < 2))


Download solve_ineq_1.mw

Now, we've obtained more consistent results. And if you're wondering why the slightly different forms of input produce the different forms of output, well, it's because it's more useful to have the choice. (It's been noted previously, and reported, that documentation of all the input/ouput forms from solve are under-documented.)

I am guessing that you'd like all the real roots to be stored, in the case that there are multiple real roots for a given set of parameter values. If not you can pass the option maxsols=1 to fsolve.

restart;


Here I'll just use the expression-form calling sequence of fsolve,
where the first argument is an expression and the second is of
the form x=range.

Reg_IV := proc(beta, n)
  local alpha, b, c, d, k, `&alpha;L`,
        `&alpha;R`, delta, eqn, x;
  `&alpha;L` := 3+beta-6*beta^(1/2);
  `&alpha;R` := 1-beta; delta := (`&alpha;R`-`&alpha;L`)/n;
  print(`&beta; = `, evalf(beta, 5), `n = `, evalf(n, 5));
  print(`&alpha;L = `, evalf(`&alpha;L`, 5),
        `&alpha;R = `, evalf(`&alpha;R`, 5),
        `&delta; = `, evalf(delta, 5));
  print(``);
  for k from 0 to n+1 do
    alpha := `&alpha;L`+k*delta;
    b := -5+alpha-3*beta;
    c := 8-4*alpha-6*beta+2*beta^2-2*alpha*beta;
    d := -(4*beta+4)*(1-alpha-beta);
    eqn := x^3+b*x^2+c*x+d;
    x[k] := [fsolve(eqn, x=0 .. 2)];
    print(evalf(x[k], 5));
  end do;
  print(``);
  print(evalf(x, 5));
end proc:

Reg_IV(0.2, 4);

`&beta; = `, .2, `n = `, 4.

`&alpha;L = `, .51672, `&alpha;R = `, .8, `&delta; = `, 0.70820e-1

``

[]

[]

[.23706, .71971]

[.10761, .79636]

[0., .85081]

[.89400]

``

x


You could use the operator-form calling sequence of fsolve, but
notice that by default that would only return a single root. You could pass
fsolve the maxsols=3 option, but that's still less efficient that using the
expression-form calling sequence above, which returns all real roots
of the polynomial by default.

Reg_IV := proc(beta, n)
  local alpha, b, c, d, k, `&alpha;L`,
        `&alpha;R`, delta, eqn, x;
  `&alpha;L` := 3+beta-6*beta^(1/2);
  `&alpha;R` := 1-beta; delta := (`&alpha;R`-`&alpha;L`)/n;
  print(`&beta; = `, evalf(beta, 5), `n = `, evalf(n, 5));
  print(`&alpha;L = `, evalf(`&alpha;L`, 5),
        `&alpha;R = `, evalf(`&alpha;R`, 5),
        `&delta; = `, evalf(delta, 5));
  print(``);
  for k from 0 to n+1 do
    alpha := `&alpha;L`+k*delta;
    b := -5+alpha-3*beta;
    c := 8-4*alpha-6*beta+2*beta^2-2*alpha*beta;
    d := -(4*beta+4)*(1-alpha-beta);
    eqn := unapply(x^3+b*x^2+c*x+d, x);
    x[k] := [fsolve(eqn, 0 .. 2, maxsols=3)];
    if hastype(x[k],specfunc(fsolve)) then
      x[k] := [];
    end if;
    print(evalf(x[k], 5));
  end do;
  print(``);
  print(evalf(x, 5));
end proc:

Reg_IV(0.2, 4);

`&beta; = `, .2, `n = `, 4.

`&alpha;L = `, .51672, `&alpha;R = `, .8, `&delta; = `, 0.70820e-1

``

[]

[]

[.23706, .71971]

[.10761, .79636]

[.85081]

[.89400]

``

x

Download fsolve_oper_expr_ex.mw

ps. Some people prefer the alternate name MakeFunction instead of unapply. That's moot if you want all the roots, since using expression-form for fsolve is more efficient in that case.

pps. I put the roots in a list, since in the case of multiple roots I expect you'll find it slightly more straightforward to deal with a stored list rather than deal with stored expression sequences.

I hope you realize that numerically integrating the numerically computed derivative is (numerically) generally a bad idea.

Also, I suppose that you realize such numeric computation is not all necessary here, and that (as you say) you are trying to establish something about the three numeric solvers in play here.

But you have been unclear as to why you think that this methodology shows something significant and what precisely that might be. (Also, why differentiate numerically at all?) There are so many controls in play here (eg. the working precision in each of the three numeric solvers in play, tolerances, etc.) that you blanket/vague goal lacks focus and thus meaning. This is the kind of thing where it's more sensible to start with the numeric requirements, explicitly. Then see if you can attain them. Otherwise (IMO) you risk flailing more with the functionality choices and missing something key.

With all of the 1) numeric pde solver, 2) numeric differentiation outside that pde solver (ugh), and 3) numeric integration then any numeric difficulties are going to be a causality muddle. How would you ever decide which might be some weak link? (especially considering that not all the parts are necessary...)

It's not clear to me what you mean by, "...the global form of the conservation law over time".

Is this the kind of numeric integration you were trying to get at? (I'm not suggesting that this is the plot you're after. I include it merely to go with that integration result at the particular t=0 point.)

restart;

pde := diff(v(x, t), t, t) = diff(v(x, t), x, x):

f := xi -> exp(-xi^2):

a := -10: b := 10: dx := 1/50: t_final := 10:

pds := pdsolve(pde, {v(a, t) = 0, v(b, t) = 0, v(x, 0) = f(x + 5),
                     D[2](v)(x, 0) = -eval(diff(f(x), x), x = x + 5)},
               numeric, range = a .. b, time = t, spacestep = dx):

sol_proc := rhs(pds:-value(output = listprocedure)[3]):

sol := (x, t) -> piecewise(a < x and x < b, sol_proc(x, t), 0):

plot(D[2](sol)(x,0), x=a..b, size=[500,200]);

evalf(Int(D[2](sol)(x,0), x=a..b, digits=10, epsilon=1e-5, method=_d01ajc));

-0.5778633229e-10

Download pde_num_hmm.mw

ps. Here's another syntax for the integration and plot above. You original syntax was not ok, using an fdiff call like an expression alongside the (operator style) a..b for the range of integration.

evalf(Int(x->fdiff(sol_proc(x, t), [t = 0]),
          a .. b, digits=10, epsilon=1e-5, method=_Dexp));
plot(x->fdiff(sol_proc(x, t), [t = 0]), a .. b, size=[500,200]);
First 15 16 17 18 19 20 21 Last Page 17 of 336