tomleslie

13876 Reputation

20 Badges

15 years, 164 days

MaplePrimes Activity


These are answers submitted by tomleslie

Using

eq4 := dsolve({eq2, incs}, y(t), type = numeric, maxfun=0);

I can plot out to 10secs.

The solution is both very small and highly oscillatory - if you want to plot much further than ~10secs, I suspect you may have to start experimenting with error/stepsize controls

I modified your code very slightly, to take out the 'view' restriction and the 'numpoints' restriction, neuther of which seem to be useful/necessary, and I  get an oscillatory (but not "divergent") solution. So just try the following

vz := 2*(-eta^2+1);
D_im := .22;
r0 := 1;
pde := diff(vz*Y(eta, z), z)-D_im*((diff(eta*(diff(Y(eta, z), eta)), eta))/eta+diff(Y(eta, z), `$`(z, 2)))/r0 = 0;
pde := expand(%);
ibc := [Y(1, z) = 0, (D[1](Y))(0, z) = 0, Y(eta, 0) = 1, (D[2](Y))(eta, 0) = 0];
sol := pdsolve(pde, ibc, numeric, time = z, range = 0 .. 1);
pds := sol:-value(z = 0, output = listprocedure);
#sol:-plot(z = 0.1e-3, numpoints = 50, color = blue, view = 0 .. 1);
sol:-plot(z = 0.1e-3, numpoints = 500, color = blue);

A caveat: I tried this in Maple 18, Maple 2015 and 2016, and got the same plot every time - I don't have Maple 17 still installed on my machine, but I'd be really surprised if this is a version issue

I had a similar problem recently: bad ram stick corrupted my OS

Complete win7 reinstall, followed by Maple re-install (three versions, Maple 18, Maple 2015 and Maple 2016).

I just had to enter license code corresponding to the Maple version, and all three versions are now working again

Consider the possibilities in

a:=3.0:
plt:=a*x^2:
plot( plt, x=0..5,
      legend=typeset("A plot of %1 for a=%2", `a*x^2`,a),
      legendstyle=[font=[Times, bold, 12]]
    );

Check out the attached in which I used an explicit 'assume' statement.

assumeVariations.mw

Why 'assume' should be respected when an apparently equivalent 'assuming' is not - I have no idea:-(

I did this in Maple 18 - don't have anything earlier

  1. You are using 'gamma' as a simple variable: this name is 'protected' in Maple, so if you really, really want to use 'gamma' as a variable name, then you have to declare it as 'local'
  2. The above issue is made worse because you are also using the Maple's in-built 'gamma' function. Having set 'gamma' as a simple variable (as in [1] above), to access the inbulit 'gamma' function in Maple you have to use the syntax  ':-gamma'
  3. In your final loop, you are using simple equality signs ie '=' rather than assignments, ie ':='
  4. In your final loop you are using 'sum()' rather than 'add()'. 'sum' will always try to find a closed-form expression for your summation. If/when this fails, it will (if possible) just compute the terms and 'add' them. Since your summations are finite, and terms are known there is little point in first trying to for a closed-form solution: 'add()' will be more efficient
  5. See the attached for the corrected version

corr_sir.mw

You state

"However, the fsolve used to defined Prev above appears to be a bad way to do it, since the Prev function can't for example plot."

but the following code would seem to produce the plot which you need

restart;
with(Student[Statistics]):
X:=NormalRandomVariable(0,1);
Probability(X <= 0.6);
Prev:=p->fsolve(Probability(X<=x)=p, x);
plot(Prev, 0..1);

or am I missing something?

According to the plottools[exportplot] help page, you have the following choices in Maple 2015

Supported Export Formats
• Formats supported by exportplot include the following:
 Raster Graphics formats: GIF, JPEG, TIFF
 Vector Graphics formats: BYU, DXF, COLLADA, JVX, OBJ, OFF, PLY, POV, STL, VTK, WM

It would therefore seem that the Maple does not support either .svg or .emf files.

Only suggestion I can make is either to use an on-line translator, or get a copy of some free graphics program such as gimp, which (if memory serves) can translate almost anything to almost anything

@emrantohidi 

Below is the code mentioned last night

(I stll can't use the big green up-arrow to upload files any more.)

Like I said, the following runs, plots outputs up to about ~0.4, and then barfs because of a singularity

 

#########################################################

  restart;
  with(orthopoly):
# print(`output redirected...`): # input placeholder
  N := 4: Digits := 20:
# print(`output redirected...`): # input placeholder
# A := -1: B := 1:
  rho := 3/4:
  g1 := proc(x)
             options operator, arrow:
             local A := -1:
             1/2+(1/2)*tanh((1/2)*(A-(2*rho-1)*x/sqrt(2))/sqrt(2))
        end proc:
  g2 := proc(x)
             options operator, arrow:
             local B := 1:
             1/2+(1/2)*tanh((1/2)*(B-(2*rho-1)*x/sqrt(2))/sqrt(2))
        end proc:
# print(`output redirected...`): # input placeholder
  f := proc(x)
            options operator, arrow:
            1/2+(1/2)*tanh((1/2)*x/sqrt(2))
       end proc:
# print(`output redirected...`): # input placeholder
  uexact := proc(x, t)
                 options operator, arrow:
                 1/2+(1/2)*tanh((1/2)*(x-(2*rho-1)*t/sqrt(2))/sqrt(2))
            end proc:
# print(`output redirected...`): # input placeholder
#
# following is used nowhere - why does it exist??
# Comment out
#
# basiceq := simplify(diff(uexact(x, t), `$`(t, 1))-(diff(uexact(x, t), `$`(x, 2)))+uexact(x, t)*(1-uexact(x, t))*(rho-uexact(x, t))):
# print(`output redirected...`): # input placeholder
#
  alpha := 0: beta := 0:
  pol := P(N-1, alpha+1, beta+1, x):
  pol := unapply(pol, x):
  dpol := simplify(diff(pol(x), x)):
  dpol := unapply(dpol, x):
# print(`output redirected...`): # input placeholder
  nodes := fsolve(P(N-1, alpha+1, beta+1, x)):
  xx[0] := -1:
  for i to N-1 do
      xx[i] := nodes[i]
  end do:
# print(`output redirected...`): # input placeholder
  xx[N] := 1:
  for k from 0 to N do
      h[k] := 2^(alpha+beta+1)*GAMMA(k+alpha+1)*GAMMA(k+beta+1)/((2*k+alpha+beta+1)*GAMMA(k+1)*GAMMA(k+alpha+beta+1))
  end do:
# print(`output redirected...`): # input placeholder
  w[0] := 2^(alpha+beta+1)*(beta+1)*GAMMA(beta+1)^2*GAMMA(N)*GAMMA(N+alpha+1)/(GAMMA(N+beta+1)*GAMMA(N+alpha+beta+2)):
# print(`output redirected...`): # input placeholder
  for jj to N-1 do
      w[jj] := 2^(alpha+beta+3)*GAMMA(N+alpha+1)*GAMMA(N+beta+1)/((1-xx[jj]^2)^2*dpol(xx[jj])^2*factorial(N-1)*GAMMA(N+alpha+beta+2))
  end do:
# print(`output redirected...`): # input placeholder
  w[N] := 2^(alpha+beta+1)*(alpha+1)*GAMMA(alpha+1)^2*GAMMA(N)*GAMMA(N+beta+1)/(GAMMA(N+alpha+1)*GAMMA(N+alpha+beta+2)):
# print(`output redirected...`): # input placeholder
  for j from 0 to N do
      dpoly1[j] := simplify(diff(P(j, alpha, beta, x), `$`(x, 1))):
      dpoly1[j] := unapply(dpoly1[j], x):
      dpoly2[j] := simplify(diff(P(j, alpha, beta, x), `$`(x, 2))):
      dpoly2[j] := unapply(dpoly2[j], x)
  end do:
# print(`output redirected...`): # input placeholder
# print(??): # input placeholder
  for n to N-1 do
      for i from 0 to N do
          BB[n, i] := sum(P(jjj, alpha, beta, xx[jjj])*dpoly2[jjj](xx[n])*w[i]/h[jjj], jjj = 0 .. N)
      end do
  end do:
  for n to N-1 do
      d[n] := BB[n, 0]*g1(t)+BB[n, N]*g2(t):
      d[n] := unapply(d[n], t)
  end do:
# print(`output redirected...`): # input placeholder
  for nn to N-1 do
      F[nn] := simplify(sum(BB[nn, ii]*u[ii](t), ii = 1 .. N-1)+u[nn](t)*(1-u[nn](t))*(rho-u[nn](t))+d[nn](t)):
      F[nn] := unapply(F[nn], t)
  end do:
# print(`output redirected...`): # input placeholder
  sys1 := [seq(diff(u[q](t),t)= F[q](t), q = 1 .. N-1)]:
# print(`output redirected...`): # input placeholder
  ics := seq(u[qq](0) = evalf(f(xx[qq])), qq = 1 .. N-1):
# print(`output redirected...`): # input placeholder
  sol:=dsolve([sys1[], ics], numeric):
  plots:-odeplot(sol,[[t,u[1](t)],[t,u[2](t)], [t,u[3](t)]], t=0..0.4);

Your function f1(x) defines the "base" of the goblet - and you have a pretty much free choice (it's aesthetics after all)

Your function f2(x) defines the "stem" of the goblet- and again you have a pretty much free choice (it's aesthetics after all)

However it is mandatory that at the boundary between "base" and "stem", (in your case x=0.5, although it could be any other value - again aesthetics) the values of the functions should be the same - ie f1(0.5)=f2(0.5). This criterion is met with the first case you supply, ie

f1:=x->-2.6x+1.5
f2:=x->0.2+0.05*sin(2*(x-0.5))

when x=0.5, f1(x)=f2(x)=0.2

However when you change the definition of f2, to

f2:=x->0.4+0.05*sin(2*(x-0.5))

f1(0.5)=0.2, but f2(0.5)=0.4, so the base does not "neatly" attach to the stem.

One way around this issue: suppose x1 is the coordinate where the base joins the stem, then you will get a "neat" join provided that

f2:= x-> f1(x1)+0.05*sin(2*(x-x1))

Obviously you can pick any other functions for the base/stem which you want, but if x1 is the coordinate where they join, then you have to ensure that f1(x1)=f2(x1)!

Tried Maple 18, 2015, 2016 - couldn't get a "general" solution in any of them. So which Maple version gave you a *general* solution.

Trivial to get a numeric solution in any of the above three versions with

eq := diff(y(x), x) = ((76.559-179.54*((1/3600)*x+1)+113.15*((1/3600)*x+1)^2-13.661*((1/3600)*x+1)^3+.4621*((1/3600)*x+1)^4)*.88-.15*((76.559-179.54*((1/3600)*x+1)+113.15*((1/3600)*x+1)^2-13.661*((1/3600)*x+1)^3+.4621*((1/3600)*x+1)^4)*.88)*(1-0.45e-2*(y(x)-9.8-273))-(3.8+2.8*3.7+5.76*10^(-8)*(y(x)^2+(273+9.8+(1/46800)*(18.3-9.8)*x)^2)*(y(x)+273+9.8+(1/46800)*(18.3-9.8)*x))*(273+9.8+(1/46800)*(18.3-9.8)*x-y(x)))/(903*(2702*0.2e-2));
sol:=dsolve({eq, y(0) = 283.8},numeric );
plots[odeplot]( sol, x=-1000..1000);

Having defined functions, they need to be called with an argument: eg when using 'f' in the definition of "iterf', youu need to use f(t). Similarly in the fsolve command 'iterf' needs to be iterf(Te). Corrected worksheet attached, which provides an answe for Te

wsCorr.mw

  1. You specify the data as a:={10,11,-13,9,20,74,10}. Now the curly braces indicate a set in Maple, so the minute you enter this command two things will happen (which you may or may not want)
    1. the duplicate entries (eg `10` ) will be reduced to a single entry
    2. the data will be reorganised in numeric order
  2. Previous responses have transformed your original from a set to a list, whilst warning about modifying list entries: lists are not mutable, so every time you change a list entry, you actually have to create a whole new list. This is rather inefficient, although you will probably only notice a timing problem, if the list is pretty long. I guess I'd say that using while using lists in this problem is not "wrong", it is "bad practice"
  3. So I would modify Kitonum's first solution very slightly, to get

a:=Array([10,11,-13,9,20,74,10]);
map(t->`if`(t<0,0, t), a);

Because there are usually many ways to do stuff

restart;
bits:=10000000:
text:=11110011:
add( `if`(irem(bits,10,'bits')+irem(text,10,'text')=1,1,0),
        j=1..length(text)
     );

Incorrect syntax for DEplot. It should be.

DETools[DEplot](eq, y(x), x=0..1, [y(0)=-1, y(1)=0]);

but if you try this, it will Maple will complain about the initial conditions, because DEplot() only works with initial value problems (see the help page). You have a boundary value problem. Easiest way to get a plot is with

E:=0.001:
eq := E*(diff(y(x), $(x, 2)))+(x^2+1)*(diff(y(x), x))-x*(x-1/2)^2 = -x^2+2.7^x:
p:=dsolve({eq, y(0)=-1, y(1)=0}, maxmesh=1024, numeric ):
plots[odeplot]( p, x=0..1);

First 187 188 189 190 191 192 193 Last Page 189 of 207