tomleslie

13876 Reputation

20 Badges

15 years, 163 days

MaplePrimes Activity


These are replies submitted by tomleslie

The attached shows the result in Maple 2021.2

with(CurveFitting):
u := x -> exp(1/2*x^2 - 1/2):
r := evalf(allvalues(RootOf(ChebyshevT(5, x), x))):
points := Vector(5, i -> r[i]):
u_points := Vector(5, i -> u(points[i])):
P__2 := PolynomialInterpolation(points, u_points, x):
evalf(int(abs(u(x) - P__2), x = -1 .. 1));

0.6276721553e-3

(1)

 

Download numInt.mw

I also checked it in Maple 18 and it gave the same answer. I didn't check all versions in-between! Which version are you using?

@jennierubyjane 

You state

I just want to display the effects of Nb=Nt on -diff(theta(eta) against Bi. In the code, I don't know how to relate these three.

 -diff(theta(eta)  as y-axis and Bi as x=axis

Bi as x=axis is easy - my original post does this: but you can only plot  -diff(theta(eta) on the y-axis for a given value of 'eta'. I chose eta=0 simply because the y-axis on the graph graph in your original question is labelled theta'(0).

The only way you can plot -diff(theta(eta) is to use a a three-dimensional plot, with Bi along the x-axis, eta along the y-axis and -diff(theta(eta) along the z-axis

You can use my original code code for other values of Nt=Nb

plot
  ( getRes( 0.2, x),
    x=0..5
  );

Sets Nb=Nt=0.2 and plots -D(theta)(0) versus Bi. You can produce a similar plot for other values of Nb=Nt, just by changing the first argument to getRes - so for example Nb=Nt=0.1, would require

plot 
( getRes( 0.1, x), 
  x=0..5 
);

In the attached(a minor change from my original)  I plot -D(theta)(0) versus Bi for Nb=Nt=0.1..0.5 in steps of 0.1. (For Nb=Nt greater than ~0.5, the value of -D(theta)(0), just gets closer and closer to zero

restart

with(plots)

DE1 := diff(f(eta), `$`(eta, 3))+f(eta)*(diff(f(eta), `$`(eta, 2)))-(diff(f(eta), eta))^2 = 0

diff(diff(diff(f(eta), eta), eta), eta)+f(eta)*(diff(diff(f(eta), eta), eta))-(diff(f(eta), eta))^2 = 0

(1)

DE2 := diff(theta(eta), `$`(eta, 2))+Pr*f(eta)*(diff(theta(eta), eta))+Pr*Nb*(diff(theta(eta), eta))*(diff(phi(eta), eta))+Pr*Nt*(diff(theta(eta), eta))^2 = 0

diff(diff(theta(eta), eta), eta)+Pr*f(eta)*(diff(theta(eta), eta))+Pr*Nb*(diff(theta(eta), eta))*(diff(phi(eta), eta))+Pr*Nt*(diff(theta(eta), eta))^2 = 0

(2)

DE3 := diff(phi(eta), `$`(eta, 2))+Le*(diff(phi(eta), eta))+Nt*(diff(theta(eta), `$`(eta, 2)))/Nb

diff(diff(phi(eta), eta), eta)+Le*(diff(phi(eta), eta))+Nt*(diff(diff(theta(eta), eta), eta))/Nb

(3)

BC1 := f(0) = 0, (D(f))(0) = 1, (D(f))(10) = 0

f(0) = 0, (D(f))(0) = 1, (D(f))(10) = 0

(4)

BC2 := theta(10) = 0, (D(theta))(0) = -Bi*(1-theta(0))

theta(10) = 0, (D(theta))(0) = -Bi*(1-theta(0))

(5)

BC3 := phi(0) = 1, phi(10) = 0

phi(0) = 1, phi(10) = 0

(6)

``

  getRes:= proc(a, x);
                local sol;
                if   type(x, numeric)
                then sol:= dsolve
                           ( eval
                             ( {BC1, BC2, BC3, DE1, DE2, DE3},
                               [Nt = a, Nb = a, Pr = 10, Le = 10, Bi = x]
                             ),
                             numeric,
                             output = listprocedure,
                             abserr = 0.0001,
                             maxmesh = 1024,
                             initmesh = 512
                           );
                else return 'procname(a,x)';
                fi;
                return -eval(diff(theta(eta), eta), sol)(0)
           end proc:

  cl:=[red, green, blue, yellow, black]:
  L:=[0.1, 0.2, 0.3, 0.4, 0.5]:
  display
  ( [ seq
      ( plot
        ( getRes( L[k], x),
          x=0..5,
          color=cl[k]
        ),
        k=1..5
      )
    ]
  )
               

 

 

 

Download odeProb2.mw

should also have mentioned

  1. Since you are seeking a numeric solution all 'parameters (ie omega A[0] , A[1], Beta[1] ) willl have to be  given numeric values
  2. Since your pde is second order in one dependent variable and first order in the other, You are going to need a total of three boundary/initial conditions

@janhardo 

Whatever textbook(s) you are using - PLEASE THROW THEM AWAY

The examples you have provided in this thread were badly coded twenty years ago and they have become downright hilarious since then!

Please explain clearly why you want to learn how to code badly,  from a rubbish textbook when so many other (freely available) resources are available. The most obvious choice would be the Maple Programming Guide, written by the nice people at Maplesoft, who know what they are talking about.

You can access this from within Maple by typing

?Maple Programming Guide

at the "prompt" in Maple. If you prefer a pdf version then you caan download it from here

https://www.maplesoft.com/documentation_center/history.aspx

(admittedly this is the guide for Maple 2020 - it doesn't seem like a 2021 version has been produced yet, but any differences in the last year will be pretty minor)

Your latest "example" about identifying triangles and some of their properties should probably be coded something like the attached. (You should like this, becuase it contains what you insist on calling a "sub-procedure", albeit one written in operator form)

  checkTri:=proc( p, q, r )
                  uses geom3d:
                  local P, Q, R, T, eps:=1.0e-09, IsIsosceles,
                        isIso:= (x, y, z)-> `if`
                                            ( `and`
                                              ( abs( evalf(distance(x, y)-distance(x, z))) < eps,
                                                abs( evalf(FindAngle(y, T))-evalf(FindAngle(z, T)))< eps
                                              ),
                                              true,
                                              false
                                            );
                  point(P, p);
                  point(Q, q),
                  point(R, r);
                  triangle(T, [P, Q, R]);
                  IsIsosceles:= `or`
                                ( isIso(P, Q, R),
                                  isIso(Q, P, R),
                                  isIso(R, P, Q)
                                ):
                  return evalf(sides(T)),
                         [ evalf(FindAngle(P,T)), evalf(FindAngle(Q,T)), evalf(FindAngle(R,T))],
                         evalf(area(T)),
                         IsEquilateral(T),
                         IsRightTriangle(T),
                         IsIsosceles,
                         draw(T)
            end proc:;

  sides, angles, area, equilateral, rightAngled, isosceles, pic:= checkTri( [1,2,3], [-1,0,1], [2,1,0]);
  plots:-display(pic);

[3.464101616, 3.316624790, 3.316624790], [1.021329082, 1.021329082, 1.098934490], 4.898979486, false, false, true, INTERFACE_PLOT3D(POLYGONS(Matrix(3, 3, {(1, 1) = 1.0, (1, 2) = 2.0, (1, 3) = 3.0, (2, 1) = -1.0, (2, 2) = .0, (2, 3) = 1.0, (3, 1) = 2.0, (3, 2) = 1.0, (3, 3) = .0}, datatype = float[8])), SCALING(CONSTRAINED), AXESSTYLE(NONE), VIEW(-1. .. 2., 0. .. 2., 0. .. 3.))

 

 

 

Download triangles.mw

@janhardo 

Whatever textbook you are using -THROW IT AWAY!!

The attached shows how to use the (bad) code in your worksheet, and also how to write the procedure in a sensible manner

  restart;
#
# OP's example from a book which should be thrown
# away;
#
  binom:= proc(a, b, n, result::evaln)
               s:=0;
               for k from 0 to n do
                   s:=s+(n!/(k!*(n-k)!))*a^(n-k)*b^k;
               end do;  
               result:=s;
               RETURN()
          end proc:
#
# How to use the above bad code
#

  binom(x,y,6, result);
  result;

  binom(x,y,6, fred);
  fred;

Warning, (in binom) `s` is implicitly declared local

 

Warning, (in binom) `k` is implicitly declared local

 

x^6+6*x^5*y+15*x^4*y^2+20*x^3*y^3+15*x^2*y^4+6*x*y^5+y^6

 

x^6+6*x^5*y+15*x^4*y^2+20*x^3*y^3+15*x^2*y^4+6*x*y^5+y^6

(1)

  binom2:= proc(a, b, n)
                local k:
                return add( n!/(k!*(n-k)!)*a^(n-k)*b^k, k=0..n);
           end proc:
  result:= binom2(x,y,6);

x^6+6*x^5*y+15*x^4*y^2+20*x^3*y^3+15*x^2*y^4+6*x*y^5+y^6

(2)

 

Download binom.mw

@Carl Love 

This is just an "idle curiosity" question, but (based on my previous "toy" example), the permitted recursion level seems to be 97435 - see the attached

Does anybody know if this is machine -specific, OS-specific, built-in to Maple, something else?

It seems to be a very "uninteresting" number.

In case it matters I'm running Maple2021.2 on 64-bit Windows 7.

  restart;
  f:= proc(n);
           1/n;
           thisproc(n-1);
      end proc:
  f(97435);
  f(97436);

Error, (in f) numeric exception: division by zero

 

Error, (in f) too many levels of recursion

 

 

Download howMany.mw

@kencom1 

I don't understand the calculation you are attempting, but one way to progress is to "unassign" the names F, X, Y at an appropriate pont after each execution of the inner loop. The code now runs, but very slowly -Im not sure why. One possibility is that this calculation is generating huge numbers.

There are about 1080 atoms in the universe. Check the scale of the numbers in the attached, for example 10^136345195 - Now that is BIG - is this expected?

Should the quantity .eta' have a numerical value?

restart

NULL

F[0] := .2; X[0] := 0; Y[0] := .1130

for g from 0 while g < 100 do for k from 0 to 4 do F[k+1] := X[k]/(k+1); X[k+1] := Y[k]/(k+1); Y[k+1] := solve((k+1)*Y[k+1]-add(X[l]*X[k-l], l = 0 .. k)+add(F[l]*Y[k-l], l = 0 .. k), Y[k+1]) end do; m := .2; y := g*m; AA[g] := add(X[i]*(eta-y)^i, i = 0 .. k); BB[g] := add(Y[i]*(eta-y)^i, i = 0 .. k); CC[g] := add(F[i]*(eta-y)^i, i = 0 .. k); A := add(X[i]*m^i, i = 0 .. k); B := add(Y[i]*m^i, i = 0 .. k); C := add(F[i]*m^i, i = 0 .. k); unassign(F); unassign(X); unassign(Y); F[0] := C; X[0] := A; Y[0] := B end do

AA[87];BB[87];CC[87];;

-0.1689149670e32174704*eta+0.2939120426e32174705+0.4000000000e53008795*(eta-17.4)^2+0.5893757407e73842895*(eta-17.4)^3+0.6513070568e94676995*(eta-17.4)^4+0.5757968684e115511095*(eta-17.4)^5

 

0.8000000000e53008795*eta-0.1392000000e53008797+0.1768127222e73842896*(eta-17.4)^2+0.2605228227e94676996*(eta-17.4)^3+0.2878984342e115511096*(eta-17.4)^4+0.2545205292e136345196*(eta-17.4)^5

 

0.8640936749e26504402*eta-0.1503522994e26504404-0.8445748350e32174703*(eta-17.4)^2+0.1333333333e53008795*(eta-17.4)^3+0.1473439352e73842895*(eta-17.4)^4+0.1302614114e94676995*(eta-17.4)^5

(1)

 

Download indexProblem2.mw

 

Frome ther reference which you cite (emphasis added)

Definition 5.1.1.

The Poincaré disk model for hyperbolic geometry is the pair where consists of all points in such that and consists of all Möbius transformations for which The set is called the hyperbolic plane, and is called the transformation group in hyperbolic geometry.

I have two observations

  1. Why have you drawn your Poincare disk, centred at [1,1] which guarantees that
  2. Note that your second point is outside the unit disk

@Amir_Maple 

I think AxelVogt explained the "conceptual problem" rather better than my own original response

For your second point, one can expand the original function into x^11 - 5*x^9 + 10*x^7 - 10*x^5 + 5*x^3 - x and integrate this term by term so

the term x^11 integrates to x^12/12,
the term - 5*x^9 integrates to (-x^10)/2

and so on

So I asked you to think about which of these individual integrals gives rise a constant term 1/12

You were hoping to write your own numapprox:-chebyshev() command? As in the attached?

cheb3.mw

@Zeineb 

really understand the algorithm you are trying to implement, but it is fairly obvious that the quantity 'F_cheby' in your worksheet contains a significant term (ie 2.208298244*t^2) which is independent of 'x'. Setting x=0, will not make this term "disappear". Obvious question - why does this term occur?

I made this obvious in the attached, by inserting a simple collect() command

cheby2.mw

@FDS 

but I'd guess that the "clickable conversion" does not look "inside" data structures.

I've just tried clickable conversion with a simple list - that doesn't work either.

As a general observation, most operations which can be performed from context menus, are not as complete/sophisticated as explicitly coding the same operation

@janhardo 

Please upload a worksheet here which illustrates your issue.

Use the big green up-arrow in the MApleprimes toolbar

The example on the help page

NumberTheory,PrimeCounting

seems to work perfectly - see the attached. Please upload a worksheet here which illustrates your issue.

(Worksheets are still not displaying "inline" on this site!)

prCount.mw

@moon 

If you posted the worksheet (using the big green up-arrow in the Mapleprimes toolbar), respondents would be able to look at our polynomial, your solution method, and make sensible suggestions.

If you present an incomplete question, your possibility of getting an answer is close to nil

First 25 26 27 28 29 30 31 Last Page 27 of 207