acer

32617 Reputation

29 Badges

20 years, 42 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

See my answer here.

@Muhammad Usman You may want to check the signs (plus, minus) in the T[w]-T[infinity] and -C[w]+C[infinity] , since your DE6 had them with both the same sign. I'm guessing that you intended a subtraction, so I changed in in DE6 below. 

restart

DE1 := x*c*(diff(f(eta), eta))*epsilon/(-epsilon*t+1)^2+(1/2)*x*c^2*(diff(f(eta), eta, eta))*y*epsilon/((-epsilon*t+1)^3*sqrt(c/(nu*(-epsilon*t+1)))*nu)+x*c^2*(diff(f(eta), eta))^2/(-epsilon*t+1)^2-sqrt(c*nu/(-epsilon*t+1))*f(eta)*x*c*(diff(f(eta), eta, eta))*sqrt(c/(nu*(-epsilon*t+1)))/(-epsilon*t+1) = a*x*epsilon/(-epsilon*t+1)^2+a^2*x/(-epsilon*t+1)^2+x*c^2*(diff(f(eta), eta, eta, eta))/(-epsilon*t+1)^2+sqrt(2)*GAMMA*x^2*c^3*(diff(f(eta), eta, eta))*sqrt(c/(nu*(-epsilon*t+1)))*(diff(f(eta), eta, eta, eta))/(-epsilon*t+1)^3+A*g*beta[T]*theta(eta)*T[w]-A*g*beta[T]*theta(eta)*T[infinity]+A*g*beta[C]*phi(eta)*C[w]-A*g*beta[C]*phi(eta)*C[infinity]-sigma*B^2*x*c*(diff(f(eta), eta))/(rho*(-epsilon*t+1))+sigma*B^2*a*x/(rho*(-epsilon*t+1))

x*c*(diff(f(eta), eta))*epsilon/(-epsilon*t+1)^2+(1/2)*x*c^2*(diff(diff(f(eta), eta), eta))*y*epsilon/((-epsilon*t+1)^3*(c/(nu*(-epsilon*t+1)))^(1/2)*nu)+x*c^2*(diff(f(eta), eta))^2/(-epsilon*t+1)^2-(c*nu/(-epsilon*t+1))^(1/2)*f(eta)*x*c*(diff(diff(f(eta), eta), eta))*(c/(nu*(-epsilon*t+1)))^(1/2)/(-epsilon*t+1) = a*x*epsilon/(-epsilon*t+1)^2+a^2*x/(-epsilon*t+1)^2+x*c^2*(diff(diff(diff(f(eta), eta), eta), eta))/(-epsilon*t+1)^2+2^(1/2)*GAMMA*x^2*c^3*(diff(diff(f(eta), eta), eta))*(c/(nu*(-epsilon*t+1)))^(1/2)*(diff(diff(diff(f(eta), eta), eta), eta))/(-epsilon*t+1)^3+A*g*beta[T]*theta(eta)*T[w]-A*g*beta[T]*theta(eta)*T[infinity]+A*g*beta[C]*phi(eta)*C[w]-A*g*beta[C]*phi(eta)*C[infinity]-sigma*B^2*x*c*(diff(f(eta), eta))/(rho*(-epsilon*t+1))+sigma*B^2*a*x/(rho*(-epsilon*t+1))

L1,L2:=(selectremove(has,[op((rhs-lhs)(DE1))],diff(f(eta), eta, eta, eta))):
new1:=`+`(op(L1))=-(`+`(op(L2)));

x*c^2*(diff(diff(diff(f(eta), eta), eta), eta))/(-epsilon*t+1)^2+2^(1/2)*GAMMA*x^2*c^3*(diff(diff(f(eta), eta), eta))*(c/(nu*(-epsilon*t+1)))^(1/2)*(diff(diff(diff(f(eta), eta), eta), eta))/(-epsilon*t+1)^3 = -a*x*epsilon/(-epsilon*t+1)^2-a^2*x/(-epsilon*t+1)^2-A*g*beta[T]*theta(eta)*T[w]+A*g*beta[T]*theta(eta)*T[infinity]-A*g*beta[C]*phi(eta)*C[w]+A*g*beta[C]*phi(eta)*C[infinity]+sigma*B^2*x*c*(diff(f(eta), eta))/(rho*(-epsilon*t+1))-sigma*B^2*a*x/(rho*(-epsilon*t+1))+x*c*(diff(f(eta), eta))*epsilon/(-epsilon*t+1)^2+(1/2)*x*c^2*(diff(diff(f(eta), eta), eta))*y*epsilon/((-epsilon*t+1)^3*(c/(nu*(-epsilon*t+1)))^(1/2)*nu)+x*c^2*(diff(f(eta), eta))^2/(-epsilon*t+1)^2-(c*nu/(-epsilon*t+1))^(1/2)*f(eta)*x*c*(diff(diff(f(eta), eta), eta))*(c/(nu*(-epsilon*t+1)))^(1/2)/(-epsilon*t+1)

normal( (rhs-lhs)(DE1) + (rhs-lhs)(new1) );

0

new2 := simplify( (-epsilon*t+1)^2/(x*c^2) * new1, size );

-(diff(diff(diff(f(eta), eta), eta), eta))*(2^(1/2)*GAMMA*x*c*(diff(diff(f(eta), eta), eta))*(-c/(nu*(epsilon*t-1)))^(1/2)-epsilon*t+1)/(epsilon*t-1) = -((-rho*(diff(f(eta), eta))^2*c^2*x-(epsilon*rho-sigma*B^2*(epsilon*t-1))*c*x*(diff(f(eta), eta))+A*rho*beta[T]*g*(epsilon*t-1)^2*(T[w]-T[infinity])*theta(eta)+A*rho*beta[C]*g*(epsilon*t-1)^2*(C[w]-C[infinity])*phi(eta)+a*((epsilon+a)*rho-sigma*B^2*(epsilon*t-1))*x)*nu*(epsilon*t-1)*(-c/(nu*(epsilon*t-1)))^(1/2)+(f(eta)*(epsilon*t-1)*(-c*nu/(epsilon*t-1))^(1/2)+(1/2)*y*epsilon)*(diff(diff(f(eta), eta), eta))*rho*c^2*x)/((-c/(nu*(epsilon*t-1)))^(1/2)*(epsilon*t-1)*x*c^2*rho*nu)

new3:=collect(lhs(new2),
          [diff(f(eta),eta,eta,eta),diff(f(eta),eta,eta),
           diff(f(eta),eta),theta(eta),phi(eta)],
           simplify) =
      collect(rhs(new2),
          [diff(f(eta),eta,eta,eta),diff(f(eta),eta,eta),
           diff(f(eta),eta),theta(eta),phi(eta)],
           u->collect(u,[f(eta),sigma],uu->simplify(uu,radical)))
      assuming -epsilon*t+1>0, c>0, nu>0;

(1+GAMMA*c^(3/2)*2^(1/2)*x*(diff(diff(f(eta), eta), eta))/(nu^(1/2)*(-epsilon*t+1)^(3/2)))*(diff(diff(diff(f(eta), eta), eta), eta)) = (-f(eta)+(1/2)*y*epsilon/(c*nu*(-epsilon*t+1))^(1/2))*(diff(diff(f(eta), eta), eta))+(diff(f(eta), eta))^2+((-epsilon*t+1)*B^2*sigma/(c*rho)+epsilon/c)*(diff(f(eta), eta))+(-T[w]+T[infinity])*A*beta[T]*g*(epsilon*t-1)^2*theta(eta)/(x*c^2)+(-C[w]+C[infinity])*A*beta[C]*g*(epsilon*t-1)^2*phi(eta)/(x*c^2)+a*B^2*(epsilon*t-1)*sigma/(c^2*rho)+(-epsilon-a)*a/c^2

DE6 := (1+sqrt(2)*GAMMA*x*c^(3/2)*(diff(f(eta), eta, eta))/((-epsilon*t+1)^(3/2)*sqrt(nu)))*(diff(f(eta), eta, eta, eta)) = ((1/2)*y*epsilon/sqrt(c*nu*(-epsilon*t+1))-f(eta))*(diff(f(eta), eta, eta))+(diff(f(eta), eta))^2+((-epsilon*t+1)*B^2*sigma/(c*rho)+epsilon/c)*(diff(f(eta), eta))-(-epsilon*t+1)^2*A*g*beta[T]*(T[w]-T[infinity])*theta(eta)/(x*c^2)+(-epsilon*t+1)^2*A*g*beta[C]*(-C[w]+C[infinity])*phi(eta)/(x*c^2)-a*epsilon/c^2-a^2/c^2-sigma*B^2*a*(-epsilon*t+1)/(rho*c^2)

(1+GAMMA*c^(3/2)*2^(1/2)*x*(diff(diff(f(eta), eta), eta))/(nu^(1/2)*(-epsilon*t+1)^(3/2)))*(diff(diff(diff(f(eta), eta), eta), eta)) = (-f(eta)+(1/2)*y*epsilon/(c*nu*(-epsilon*t+1))^(1/2))*(diff(diff(f(eta), eta), eta))+(diff(f(eta), eta))^2+((-epsilon*t+1)*B^2*sigma/(c*rho)+epsilon/c)*(diff(f(eta), eta))-(-epsilon*t+1)^2*A*g*beta[T]*(T[w]-T[infinity])*theta(eta)/(x*c^2)+(-epsilon*t+1)^2*A*g*beta[C]*(-C[w]+C[infinity])*phi(eta)/(x*c^2)-a*epsilon/c^2-a^2/c^2-sigma*B^2*a*(-epsilon*t+1)/(rho*c^2)

`assuming`([simplify(simplify(new3-DE6), size)], [-epsilon*t+1 > 0, nu > 0, c > 0]);

0 = 0

 

Download Help_2_ac.mw

@mehran rajabi So you are back-substituting the approximate root into the original expression, to see whether the result is small. Sometimes that computed value is called the residual, or the forward error.

The plot of the expression is very steep near the larger roots. That means that any small change in the root approximation will result in a large change in the computed residual (even if the back-substitution itself is performed a very high precision).

Truncation of the approximate root (ie, rounding it to d digits) incurs such a change away from the true root. So the residual computed using only say d digits of the approximate root may be significantly larger than the residual computed using more than d digits of approximation of the root.

In the following attachment I generate approximations of the root near 22.3, with successively more digits in the approximated result. Each of these is back-substituted into the original expression, and the residual computed. It demonstrates how a more accurate approximation of that root is needed in order to get a smaller residual.

resid.mw

I notice that the curve in your image is not straight, between the first and second data points.

Are you asking about curve-fitting (ie, regression or interpolation, etc)?

Afaik an animation can only show a single `background` image, taken as the last available from all the frames.

But it should be possible to produce a heatmap in an alternative format.

For example the images could be float[8] images ie. float[8] Arrays which could be used to shade density plot GRID structures instead. Those can be more memory intensive, however.

A modest number of shaded polygons would also likely serve, if you don't need a very fine granularity, and be cheaper still.

@Adam Ledger Just because unapply sometimes provides the convenient way to construct a procedure from an expression doesn't mean that it's always the right thing to use. It's not the right thing to use with the code snippet I gave in my answer.

The best way to turn my answer into a re-usable procedure is to simply wrap it in proc()...end proc. I'll do so below. I'll change some of the names in the proceduce (params or locals) so that they are not confusingly the same as their equivalents at the higher level.

I originally used _seq with an underscore as a cheap way to use a name to which one would likely not have assigned a value. In the procedure version below I'll use s.  Kitonum used S in the procedure version he posted after me. The similarity is because we were both just working around the issue by using a dummy name for the foldl call.

restart;

Gen:=proc(f, r::list(posint))
  local n,i,j,p,s;
  n:=nops(r);
  op(eval(subs(s=seq,
               [foldl(s, f(seq('i'[j],j=1..n)),
                      seq(i[p]=1..r[p],p=1..n))])));
end proc:

Gen(F, [2,1,3]);

  F(1, 1, 1), F(2, 1, 1), F(1, 1, 2), F(2, 1, 2), F(1, 1, 3),
  F(2, 1, 3)

Gen(F, [7,2]);

  F(1, 1), F(2, 1), F(3, 1), F(4, 1), F(5, 1), F(6, 1), F(7, 1), F(1, 2),
  F(2, 2), F(3, 2), F(4, 2), F(5, 2), F(6, 2), F(7, 2)

Your original question was about how to use foldl and seq to generate all the possible F calls. There are, of course, other ways to generate those F calls, and some of the other ways are reasonably simple. I was deliberately answering the question of how you could use foldl and seq to do it.

@mweisbr I could have tested for <>1 or <0 , as you stated, but <10 happened to work since all other day was larger. It was just less typing.

@mweisbr I see now that the bad points are not isolated, which I didn't realize before. I'm not sure how interpolation (including just linear) is going to be justified.

You may be able to smooth the data by convolving the errant points. (ie. something like ImageTools:-Convolution , at least in concept)

The tricky bit can be to convolve (mostly) only the points which are unsatisfactory, because you don't want their bad values affecting other good points nearby. It helps to have a robust and flexible peak detection scheme, in order to convolve only the bad data. Sometimes it's not so hard. It helps if the bad points are quite isolated.

Can you confirm whether the uploaded data is correct?

Once you have the source code in a plaintext file, why not use Maple's read command instead of repeatedly copy & pasting it into the Maple sessions?

@Annonymouse 

line is being used in Kitonum's example as an export of the plottools package. So if you don't want to load that package (and by doing so, rebind the name line) then you'd need to reference it using the long-form plottools:-line .

A:=[1, 2, 3]: B:=[4, 5, 6]:

plots:-display(plottools:-line(A, B,
                               color=red, thickness=2));

I'll also correct Kitonum's first example below. Ie, either A+t*~(B-A) or (1-t)*~A+t*~B . And if you're just going to produce a straight line then you only need two points in a space curve.

A:=[1, 2, 3]: B:=[4, 5, 6]:

plots:-spacecurve(A+t*~(B-A), t=0..1, numpoints=2,
                  color=red, thickness=2);

Also, this seems simple.

A:=[1, 2, 3]: B:=[4, 5, 6]:

plots:-pointplot3d([A,B], style=line,
                   color=red, thickness=2);

@Annonymouse Personally I think you should just add additional details and rephrasings etc to a Comment/Reply on this Question.

If you'd rather edit the Question then it's better to leave the original matter and mark the new as new. It's a reasonable choice.

Adding your own details to an Answer here would be not be clear and most useful, I think.

@Annonymouse Please don't post such a close duplicate as a separate Question. Put the followup details here instead.

@Christian Wolinski 

Sometimes kernel built-in functions like eval will call out to the interpreted Library.

Here's an example where it makes a difference, using Maple 2018.

restart;

a:=2:
trace(`eval/piecewise`):

p:=piecewise(x<a, 1/(x-a), x=a, 22, 33):

eval(p, x=a);

{--> enter \`eval/piecewise\`, args = piecewise(x < 2, 1/(-2+x), x = 2, 22, 33), {x = 2}

expr, eqs := piecewise(x < 2, 1/(-2+x), x = 2, 22, 33), {x = 2}

oper := piecewise

eqs := {x = 2}

eqs := {x = 2}

tmp := table([])

t := x = 2

tmp := {}

i := 1

piecewise(x < 2, 1/(-2+x), x = 2, 22, 33)

false

false

2 < 2

false

3

2 = 2

true

<-- exit \`eval/piecewise\` (now at top level) = 22}

22

restart;

a:=2:
unassign('`eval/piecewise`'): # not reall a good thing to do

p:=piecewise(x<a, 1/(x-a), x=a, 22, 33):

eval(p, x=a);

Error, numeric exception: division by zero

 


Download CW_pw.mw

The given examples all return 22, without emitting an error, in Maple 2018.0.

First 259 260 261 262 263 264 265 Last Page 261 of 596