acer

32333 Reputation

29 Badges

19 years, 321 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Since 2018 the Mobius Project and Maple TA are owned and managed by DigitalEd, which is a different company than Maplesoft.

They have their own Mobius user forum.

You don't have to use a spacecurve for this. You could also transform the 2D plot into a 3D plot. (I usually prefer a transformed curve, since 2D plot does adaptive plotting. In this case, however, I force that off.)

Here is some added detail. In such cases it sometimes helps to use an odd grid size (if the midpoint is problematic), but it's not quite clear here. A little transparency for the surface allows the curve to show better, upon rotation and visual inspection. I also show it with narrower ranges (which is better than zooming).

restart;

with(orthopoly):
with(LinearAlgebra):
with(plots):
interface(rtablesize=20):

Digits:=15:

k:=2:
M:=2:
K:=2^(k-1):
N:=K*M:

 

 

alpha:=1:


alpha1:=alpha: 
beta:=1:
lambda:=(m,alpha1,beta)->sqrt((2*m+alpha1+beta+1)*GAMMA(2*m+alpha1+beta+1)*m!/(2^(alpha1+beta+1)*GAMMA(m+alpha1+1)*GAMMA(m+beta+1)));
psii:=(n,m,x)->piecewise((n-1)/K <= x and x <= n/K,  2^(k/2) *lambda(m,alpha1,beta)*simplify(JacobiP(m,alpha1,beta,2^(k)*x-2*n+1)), 0);
local i,j: psi:=(x)->Array([seq(seq(psii(i,j,x),j=0..M-1),i=1..K)] ):

w:=(n,x)->(1+x)^(1/gama-1):
omega:=(n,x)->w(n,2^(k)*x-2*n+1):

lambda := proc (m, alpha1, beta) options operator, arrow; sqrt((2*m+alpha1+beta+1)*GAMMA(2*m+alpha1+beta+1)*factorial(m)/(2^(alpha1+beta+1)*GAMMA(m+alpha1+1)*GAMMA(m+beta+1))) end proc

proc (n, m, x) options operator, arrow; piecewise((n-1)/K <= x and x <= n/K, 2^((1/2)*k)*lambda(m, alpha1, beta)*simplify(JacobiP(m, alpha1, beta, 2^k*x-2*n+1)), 0) end proc


psi:=t->Matrix(N,1,[seq(seq(psii(i,j,t),j=0..M-1),i=1...K)] ):
 
 


for i from 1 to N do
X[i]:=evalf((2*i-1)/((2^k)*M)):
end do:

for i from 1 to N do
T[i]:=evalf((2*i-1)/((2^k)*M)):
end do:

for i from 1 to N do
r[i]:=evalf(psi(T[i])):
end do:
Phi_mxm:=Matrix([seq(r[i],i=1...N)]);
 

Matrix(4, 4, {(1, 1) = 1.73205080756888, (1, 2) = 1.73205080756888, (1, 3) = 0., (1, 4) = 0., (2, 1) = -3.87298334620742, (2, 2) = 3.87298334620742, (2, 3) = 0., (2, 4) = 0., (3, 1) = 0., (3, 2) = 0., (3, 3) = 1.73205080756888, (3, 4) = 1.73205080756888, (4, 1) = 0., (4, 2) = 0., (4, 3) = -3.87298334620742, (4, 4) = 3.87298334620742})

 

P:=proc(k,M,nn) local PB,m,i,p,j,xi;
m:=M*(2^(k-1)):
xi:=(i,n)->((i+1)^(n+1)-2*i^(n+1)+(i-1)^(n+1));
PB:=Matrix(m,m):
for i from 1 to m do
p:=0:
for j from 1 to m do
if i=j then PB[i,j]:=1;
 fi:
if i<j then p:=p+1:
PB[i,j]:= xi(p,nn);
 fi:
end do;
p:=1:
end do:
PB:=1/m^nn/GAMMA(nn+2)*PB;

return PB;
end proc:
PP:=alpha->Phi_mxm.P(k,M,alpha).MatrixInverse(Phi_mxm);

proc (alpha) options operator, arrow; `.`(Phi_mxm, P(k, M, alpha), LinearAlgebra:-MatrixInverse(Phi_mxm)) end proc


key:=4:
rho:=1:
mmm:=1:
sigma:=1:

u_exact:=(x,t)-> 1/(1+exp(sqrt(key/6)*x-(5/6)*key*t))^2 ;
f1:=unapply(u_exact(x,0),x):
g1:=unapply(u_exact(0,t),t);
g2:=unapply(u_exact(1,t),t);

 

U:=Matrix( N,N,symbol=u);
wwxx:= diff(f1(x),x,x)+(psi(x)^+.U.PP(alpha).psi(t))(1):
wwt:= diff(g1(t),t)+x*(diff(g2(t),t)-diff(g1(t),t)-(psi(1)^+.PP(2)^+.U.psi(t))+psi(x)^+.PP(2)^+.U.psi(t))(1) :
ww:= f1(x)+g1(t)-g1(0)+x*(g2(t)-g2(0)-g1(t)+g1(0)-(psi(1)^+.PP(2)^+.U.PP(alpha).psi(t)))(1)+(psi(x)^+.PP(2)^+.U.PP(alpha).psi(t))(1) :

MC:=unapply(wwt -rho*wwxx -key*ww .(1-(1/mmm)*ww^sigma ),x,t):

u_exact := proc (x, t) options operator, arrow; 1/(1+exp(sqrt((1/6)*key)*x-(5/6)*key*t))^2 end proc

g1 := proc (t) options operator, arrow; 1/(1+exp(-(10/3)*t))^2 end proc

g2 := proc (t) options operator, arrow; 1/(1+exp((1/3)*sqrt(6)-(10/3)*t))^2 end proc

Matrix(%id = 18446884636710097494)

PDEson:=Matrix(N,N):

for i from 1 to N do
for j from 1 to N do
PDEson(i,j):=simplify(
evalf(

MC(X[i],T[j])


)
)=0:
end do:
end do:

coz:=fsolve({seq(seq(PDEson(i,j),i=1..N ),j=1..N )}):
U:=subs(op(coz),U):
 


UU:=(x,t)->evalf(f1(x)+g1(t)-g1(0)+x*(g2(t)-g2(0)-g1(t)+g1(0)-(psi(1)^+.PP(2)^+.U.PP(alpha).psi(t)))(1)+(psi(x)^+.PP(2)^+.U.PP(alpha).psi(t))(1)):

graphic_3D:=plot3d(UU(x,t), x=0..1, t=0..1, grid=[301,301],
                   color=gray,transparency=0.1,style=surface):

graphic_2D:=plot(UU(0.5,t),t=0..1,thickness=2,color=red,
                 adaptive=false,numpoints=2001):

display(
  graphic_3D,
  plottools:-transform((x,y)->[0.5,x,y])(graphic_2D),
  lightmodel=Light1
);

graphic_3Df:=plot3d(UU(x,t), x=0.499..0.501, t=0.4..0.6, grid=[301,301],
                   color=gray,transparency=0.1,style=surface):

graphic_2Df:=plot(UU(0.5,t),t=0.4..0.6,thickness=2,color=red,
                  adaptive=false,numpoints=2001):

display(
  graphic_3Df,
  plottools:-transform((x,y)->[0.5,x,y])(graphic_2Df),
  lightmodel=Light1
);

 

Download problem_ac.mw

It is not necessary to declare P1 as global when calling it from within P2 (since you merely use it, and P2 doesn't assign to the name).

And you shouldn't declare it local, since you want the P1 from the outer scope to be accessed. 

Why do you write that the result from your example should be x*dy , instead of x*dx ? (Your Question originally stated, "...the expression should reduce to x * dy")

Is it possible that you are hoping for something like this?

restart;

dx := f -> diff(f, x):
dy := f -> diff(f, y):

x := () -> x:
y := () -> y:

eq1 := x * dy:
eq2 := y * dx:

eq1(eq2);
                x dx

This looks slightly suspicious to me, but perhaps I'm not understanding your purpose properly.

The following work in Maple 18.

(In modern Maple 2020 you only need to change from active sum to inert Sum. But that change, alone, is insufficient to make it work in your Maple 18.)

restart

kernelopts(version);

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

lambda := .3:

omega := lambda+mu+xi:

alpha := 2*sqrt(lambda*mu)

.9165151390

NULL

B[1] := BesselI(k-1, alpha*(u-y))

BesselI(k-1, .9165151390-.9165151390*y)

B[2] := BesselI(k+1, alpha*(u-y))

BesselI(k+1, .9165151390-.9165151390*y)

evalf(Int(unapply(Sum((B[1]-B[2])*exp(-omega*(u-y)), k = 1 .. infinity), y), 0 .. u));

.7246342704

evalf(Int(unapply(Sum((B[1]-B[2])*exp(-omega*(u-y)), k = 1 .. infinity), y), 0 .. u))

.7246342704

This is slower, using active sum instead of inert Sum.
evalf(Int(unapply(sum((B[1]-B[2])*exp(-omega*(u-y)), k = 1 .. infinity), y), 0 .. u))

.7246342704

 

NULL

Download int_sum.mw

I am guessing that your original question was to find the inflection points of x^sin(x) . I consider this reasonably likely since it is short and simple, it's 1st derivative is the formula your originally posted, and there is clearly some confusion since your original query showed a (mistaken) attempt at rootfinding its 1st derivative.

If my guess is wrong then you could simply change the definition of the procedure body of f below, to match your originally posted fprime_expr formula.

But it would be best if you could clarify what is the actual, intended question.

restart;

with(Student:-Calculus1):
with(plots):
interface(warnlevel=0):

#
# I am guessing that your original question was to find
# the inflection points of x^sin(x) .|
#
# If not, then you simply have to change the first line below.
#

f := x -> x^sin(x);

proc (x) options operator, arrow; x^sin(x) end proc

diff(f(x), x);

x^sin(x)*(cos(x)*ln(x)+sin(x)/x)

#
# Inflection points occur where the expression's 2nd derivative
# changes sign.
#
# Another way to conceptualize it is to think of the points
# at which the curve changes between being "convex up" and
# "convex down".
#

Inflpts := InflectionPoints(f(x), x=0..10, numeric);

[1.395288666, 2.916095860, 7.258616748, 8.576145756]

Roots(diff(f(x), x, x), x=0..10, numeric);

[1.395288666, 2.916095860, 7.258616748, 8.576145756]

#
# Yet another way to conceptualize it is to think of the
# points where the first derivative attains a relative
# maximum or
 minimum. (But not the end-points...)
#
{ op( ExtremePoints(diff(f(x), x), x=0..10, numeric) ) } minus {0.,10.};

{1.395288666, 2.916095860, 7.258616748, 8.576145756}

#
# Here, the shaded portion changes color when the curve changes
# between being convex up and convex down (that is, at the inflection
# points).
#
display(
  pointplot(map(p->[p,f(p)],Inflpts),
            symbolsize=20,symbol=solidcircle,color=blue),
  FunctionPlot('f(x)', x=0.0..10.0),
  axis[1]=[tickmarks=Inflpts], size=[500,250]
);

#
# If we plot the 2nd derivative we can see that it changes sign at
# these points.
#
display(
  pointplot(map(p->[p,0],Inflpts),
            symbolsize=20,symbol=solidcircle,color=blue),
  plot(diff(f(x), x, x), x=0..10, legend=Diff(f(x),x,x)),
  axis[1]=[tickmarks=Inflpts], size=[500,250]
);

#
# If we plot the 1st derivative we can see that it has extreme
# values at these points.
#
display(
  pointplot(map(p->[p,D(f)(p)],Inflpts),
            symbolsize=20,symbol=solidcircle,color=blue),
  plot(diff(f(x), x), x=0..10, legend=Diff(f(x),x)),
  axis[1]=[tickmarks=Inflpts], size=[500,250]
);

 

Download inflectionpts.mw

Why do you think that all your separate r1() calls (within the same loop iteration, or even the same piecewise!) will produce the same value?! They do not.

In the loop, first assign the r1() call to some temp variable name. Then use that assigned name in the piecewise and the print.

I had previously submitted a similar bug report against Maple 2020.0 for Linux, for this unfortunate behavior regression. The default font size for 1D input is still (ostensibly) set to 12pt, but the appearance of it was unpleasingly larger than in previous versions.

Of course it makes no sense. My monitor and dot-pitch are unchanged, so 12pt ought to appear the same as before. The default zoom level is the same, at 100%.

If I set the font size to 11pt then it appears visually as the same dimension as 12pt did in previous versions.

I can set a custom style (with 11pt default), and make that my gui's home page. But it's more awkward.

I don't know if the problem is just a Java version idiosyncrasy, or something related to hi-res tweaks, or other.

 

Your eq1 is an equation, with x1 given explicitly.

You can use it to substitute a value for x1 into your eq2 equation (or something else in which x1 appears).

For example,

   eval(eq2, eq1);

 

Your code is full of syntax errors. The error messages explain them.

For example, your brackets don't match in the first mistake. The number of opening and closing brackets (delimiters) are different.

Also, you need to enter if...then and while..do all in a single execution group. You have mistakenly tried to write thise across multiple execution groups. Use Shift-Enter to move to a new line inside an execution group, and only use Enter to finish and execute it.

Maple works with radians, not degrees. So use Pi/6 instead of 30.

Also, use a floating point value if that's what you want in return (if there is no easy exact result). Eg, sin(4.8) etc.

You could try closing the palettes (panel on the left side of the GUI). I have a recollection of some stall issues related to that.

You could also try closing the context-panel (right side of the GUI). Let us know if either of these makes a difference.

And if you are able to discover a trigger example, then please do share it.

Let us know is the domain over which you want an approximating polynomial is not just 0..1.

restart

lambda := proc (x) options operator, arrow; (-1.565845910+2.393779704*x^2+1.564996800*x^4+1.800900000*x^6)/(x^2+2)^4 end proc

a, b := 0, 1; Digits := 15; K := expand(eval(numapprox:-chebpade(lambda(t), t = 0 .. 1, [11, 0]), T = orthopoly[T]))

0, 1

-1.52912602770120*t^8+.316503853656742*t^7-0.10877005919702e-1*t^5-0.724603953293e-3*t^3+1.54422942262127*t^9-.698472042216867*t^10+.124540489696808*t^11-0.978653647938183e-1+.345390592384950*t^2-.441314123152201*t^4+.499491688907188*t^6-0.1185138058e-5*t

plot(log10(abs(lambda(t)-K)), t = a .. b, size = [500, 200], adaptive = false, numpoints = 70, view = -15 .. 0)

plot([lambda(t), K], t = a .. b, style = [line, point], color = [red, blue], adaptive = false, numpoints = 30, size = [500, 200])

 

Download help2_ac.mw

You could add the listprocedure option to dsolve, and then pick off the procedures individually.

It's generally more efficient to use plots:-odeplot than to plot using the procedures separately as done below. But these compute pretty quickly, so performance may not be a central concern here.

(There are also other ways to pick off the individual results. You can recover some efficiency by using option remember.)

For example,

restart;

ddesys := {diff(S(t),t) = -beta*S(t)*Ix(t)/N,
diff(Ex(t),t) = beta*S(t)*Ix(t)/N - sigma*Ex(t-tau__1),
diff(Ix(t), t) = sigma*Ex(t - tau__1)- gamma*Ix(t-tau__2),
diff(R(t),t) = gamma*Ix(t-tau__2),
diff(Dx(t),t) = delta*Ix(t),
S(0) = 80900, Ex(0) = 1, Ix(0) = 1, R(0) = 0, Dx(0) = 0 }:

dsn := dsolve(eval(ddesys, {beta = 4, gamma = 0.0478, sigma = 0.10,
              delta = 0.0005, N=80900, tau__1 = 1.1,tau__2 = 8.7,tau__3 = 0}),
              numeric, output=listprocedure):

Dxfun := eval(Dx(t), dsn):
Exfun := eval(Ex(t), dsn):
Ixfun := eval(Ix(t), dsn):
Rfun := eval(R(t), dsn):
Sfun := eval(S(t), dsn):

Dxfun(20.0), Exfun(20.0), Ixfun(20.0);

HFloat(4.89877539841769), HFloat(26744.91529379044), HFloat(4309.387881985894)

### Compare
plots:-odeplot(dsn, [[t,Dx(t)], [t,Ex(t)], [t,Ix(t)],
                      [t,R(t)], [t,S(t)]],
               t=0..120, size=[500,300]);

plot([Dxfun, Exfun, Ixfun, Rfun, Sfun], 0..120, size=[500,300]);

 

Download listprocedure.mw

Here are two ways.

You could adjust the values used for width, distance, and offset. (The values are assigned to w,d,o respectively. See the ColumnGraph help page for their meaning.)

If your actual data is quite different then it would really help if you uploaded and attached it. If your numeric and string data are simply rows/columns of a Matrix then you could extract those, convert to lists, and use like L and S below.

restart;

L:=[74,71,87,83,85,61]:
S:=["Belgium","Bulgaria","Czechia","Denmark",
    "Germany (until 1990 former territory of the FRG)",
    "Estonia"]:

(w,d,o) := 25,60,30:
Statistics:-ColumnGraph(L, width=w, distance=d, offset=o,
                        axis[2]=[tickmarks=[[seq(0..100,10)],color=black],
                                 gridlines=[color=black], color=white],
                        axis[1]=[tickmarks=[seq(o+w/2+(i-1)*(w+d)
                                                =typeset(StringTools:-WrapText(S[i],11)),
                                                i=1..nops(S))]],
                        axesfont=["Lucida Sans",10], axes=normal, color="SteelBlue",
                        view=[0..o+(nops(S)-1)*(w+d)+d,0..100], size=[600,400]);

 

Download columngraph_ac.mw

The following uses plots:-textplot instead of tickmarks on the x-axis.

restart;

L:=[74,71,87,83,85,61]:
S:=["Belgium","Bulgaria","Czechia","Denmark",
    "Germany (until 1990 former territory of the FRG)",
    "Estonia"]:

(w,d,o) := 25,60,30:
plots:-display(
  Statistics:-ColumnGraph(L, width=w, distance=d, offset=o,
                          axis[2]=[tickmarks=[[seq(0..100,10)],color=black],
                                   gridlines=[color=black], color=white],
                          axis[1]=[tickmarks=[]], axesfont=[TIMES,10],
                          axes=normal, color="SteelBlue"),
  seq(plots:-textplot([o+w/2+(i-1)*(w+d),-2,
                       typeset(StringTools:-WrapText(S[i],11))],
                       align=[below],font=[TIMES,10]),i=1..nops(S)),
  plots:-pointplot([[0,102]],color=white),
  view=[0..o+(nops(S)-1)*(w+d)+w+d/2,default], size=[600,400]);

 

Download columngraph_tpl.mw

First 123 124 125 126 127 128 129 Last Page 125 of 336