mmcdara

6730 Reputation

18 Badges

8 years, 185 days

MaplePrimes Activity


These are answers submitted by mmcdara


 

restart
rel :=  {x+abs(y+1)=1, y+abs(z+2)=1, z+abs(x-2)=1}
      {x + |y + 1| = 1, y + |z + 2| = 1, z + |x - 2| = 1}

# replace abs(u) by piecewise(u < 0, -u, u):

rel_2 := eval(rel, abs=(u -> piecewise(u < 0, -u, u))):
print~(rel_2):
            x + piecewise(y < -1, -y - 1, y + 1) = 1
            y + piecewise(z < -2, -z - 2, z + 2) = 1
            z + piecewise(x < 2, -x + 2, x - 2) = 1

solve(rel_2)
            {x = z + 1, y = -1 - z, -2 <= z, z <= 0}


The attached file contains a visual check of this solution
piecewised_relations.mw

For file T1.mw:
You have 7 equations and 3 unknowns and you can estimate yourself lucky to get a solution.

For file T2.mw:
You have 11 equations and 5 unknowns {d, a[1], b[1], c[1], c[2]}: thus there are all the reasons at world for you not getting a solution (unless your 11 equations are such that, by chance or by construction [compare EQ0 and EQ1 or EQ9 and EQ10] mutually dependent in some way.) 
Note that this is all the more true that you wrote

solve(Eqs, {a[0], a[1], b[1], c[1], c[2]})

instead of

solve(Eqs, {d, a[1], b[1], c[1], c[2]})

!!!

So let"s take only 5 equations out of the 11 ones (this can be done in 462 different ways) and look if all these 5-by-5 systems have a solution or not.
The attached file shows that 25 systems out of 462 do not have a solution.

Let's take anyone of them, for instance the system made of equations

{EQ[i], i in [0, 1, 3, 5, 7]}

Completing this set of equations by any non empty subset of this next set

{EQ[i], i in [2, 4, 6, 8, 9, 10]}

will give a new set of more than 5 equations which has no solution.
In particular the set

{EQ[i], i in [0, ..., 10]}

does not have a solution.

NULL

NULL

NULL

restart

with(student):

EQ[0] := -2*sinh(d)^2*b[1]*c[1]*c[2]/cosh(d)^2;

-2*sinh(d)^2*b[1]*c[1]*c[2]/cosh(d)^2

(1)

EQ[1] := -sinh(d)^2*b[1]*c[2]/cosh(d)^2;

-sinh(d)^2*b[1]*c[2]/cosh(d)^2

(2)

EQ[2] := 2*b[1]*(3*cosh(d)^4*c[1]*c[2]-cosh(d)^4-3*cosh(d)^2*c[1]*c[2]+cosh(d)^2+c[1]*c[2])/cosh(d)^4;

2*b[1]*(3*cosh(d)^4*c[1]*c[2]-cosh(d)^4-3*cosh(d)^2*c[1]*c[2]+cosh(d)^2+c[1]*c[2])/cosh(d)^4

(3)

EQ[3] := ((-1+(a[1]+3*b[1])*c[2])*cosh(d)^4+(1+(-a[1]-3*b[1])*c[2])*cosh(d)^2+b[1]*c[2])/cosh(d)^4;

((-1+(a[1]+3*b[1])*c[2])*cosh(d)^4+(1+(-a[1]-3*b[1])*c[2])*cosh(d)^2+b[1]*c[2])/cosh(d)^4

(4)

EQ[4] := ((2*a[1]*c[1]*c[2]-6*b[1]*c[1]*c[2]-2*a[1]+4*b[1])*cosh(d)^4+(-2*a[1]*c[1]*c[2]+6*b[1]*c[1]*c[2]+4*a[1]-6*b[1])*cosh(d)^2-2*b[1]*c[1]*c[2]-2*a[1]+2*b[1])/cosh(d)^4;

((2*a[1]*c[1]*c[2]-6*b[1]*c[1]*c[2]-2*a[1]+4*b[1])*cosh(d)^4+(-2*a[1]*c[1]*c[2]+6*b[1]*c[1]*c[2]+4*a[1]-6*b[1])*cosh(d)^2-2*b[1]*c[1]*c[2]-2*a[1]+2*b[1])/cosh(d)^4

(5)

EQ[5] := ((2+(-3*a[1]-3*b[1])*c[2])*cosh(d)^4+(-2+(3*a[1]+3*b[1])*c[2])*cosh(d)^2+1+(-a[1]-b[1])*c[2])/cosh(d)^4;

((2+(-3*a[1]-3*b[1])*c[2])*cosh(d)^4+(-2+(3*a[1]+3*b[1])*c[2])*cosh(d)^2+1+(-a[1]-b[1])*c[2])/cosh(d)^4

(6)

EQ[6] := ((-6*a[1]*c[1]*c[2]+2*b[1]*c[1]*c[2]+4*a[1]-2*b[1])*cosh(d)^4+(6*a[1]*c[1]*c[2]-2*b[1]*c[1]*c[2]-6*a[1]+4*b[1])*cosh(d)^2-2*a[1]*c[1]*c[2]+2*a[1]-2*b[1])/cosh(d)^4;

((-6*a[1]*c[1]*c[2]+2*b[1]*c[1]*c[2]+4*a[1]-2*b[1])*cosh(d)^4+(6*a[1]*c[1]*c[2]-2*b[1]*c[1]*c[2]-6*a[1]+4*b[1])*cosh(d)^2-2*a[1]*c[1]*c[2]+2*a[1]-2*b[1])/cosh(d)^4

(7)

EQ[7] := ((-1+(3*a[1]+b[1])*c[2])*cosh(d)^4+(1+(-3*a[1]-b[1])*c[2])*cosh(d)^2+a[1]*c[2])/cosh(d)^4;

((-1+(3*a[1]+b[1])*c[2])*cosh(d)^4+(1+(-3*a[1]-b[1])*c[2])*cosh(d)^2+a[1]*c[2])/cosh(d)^4

(8)

EQ[8] := 2*a[1]*(3*cosh(d)^4*c[1]*c[2]-cosh(d)^4-3*cosh(d)^2*c[1]*c[2]+cosh(d)^2+c[1]*c[2])/cosh(d)^4;

2*a[1]*(3*cosh(d)^4*c[1]*c[2]-cosh(d)^4-3*cosh(d)^2*c[1]*c[2]+cosh(d)^2+c[1]*c[2])/cosh(d)^4

(9)

EQ[9] := -sinh(d)^2*a[1]*c[2]/cosh(d)^2;

-sinh(d)^2*a[1]*c[2]/cosh(d)^2

(10)

EQ[10] := -2*sinh(d)^2*a[1]*c[1]*c[2]/cosh(d)^2;

-2*sinh(d)^2*a[1]*c[1]*c[2]/cosh(d)^2

(11)

Eqs := {seq(EQ[i], i = 0 .. 10)}:

Sol := solve(Eqs, {a[0], a[1], b[1], c[1], c[2]})

indets(Eqs, name);

{d, a[1], b[1], c[1], c[2]}

(12)

11!/5!/6!

462

(13)

AllCombs := convert~(convert(convert~(combinat:-permute(11, 5), set), set), list):

AllCombs := map(OneComb -> OneComb-~1, AllCombs):

failures := 0:
for r in AllCombs do
  s := solve({seq(EQ[i], i in r)}, {d, a[1], b[1], c[1], c[2]}):
  if [s]=[] then
    printf("%a\n", r):
    failures := failures+1:
  end if:
end do:

[0, 1, 3, 5, 7]

[0, 2, 3, 5, 7]

[0, 3, 4, 5, 7]

[0, 3, 5, 6, 7]

[0, 3, 5, 7, 8]

[0, 3, 5, 7, 9]

[1, 2, 3, 5, 7]

[1, 3, 4, 5, 7]

[1, 3, 5, 6, 7]

[1, 3, 5, 7, 8]
[1, 3, 5, 7, 9]

[1, 3, 5, 7, 10]

[2, 3, 4, 5, 7]

[2, 3, 5, 6, 7]

[2, 3, 5, 7, 9]

[2, 3, 5, 7, 10]

[3, 4, 5, 7, 8]

[3, 4, 5, 7, 9]
[3, 4, 5, 7, 10]

[3, 5, 6, 7, 8]
[3, 5, 6, 7, 9]
[3, 5, 6, 7, 10]

[3, 5, 7, 8, 9]

[3, 5, 7, 8, 10]
[3, 5, 7, 9, 10]

 

failures

25

(14)

 

NULL

Download T2_no_solution.mw

 

with(LinearAlgebra):

sys1   := [seq(Eq[i], i=1..4)]:
var1   := [seq(diff(v[i-1](t), t), i=1..4)]:
A1, B1 := GenerateMatrix(sys1, var1):
A1, B1 := GenerateMatrix(sys1, var1):

sys2   := [entries(B1, nolist)]:
var2   := [seq(v[i-1](t), i=1..4)]:
A2, B2 := GenerateMatrix(sys2, var2):
A2, B2 := GenerateMatrix(sys2, var2):

A1 &. <var1> = A2 &. <var2> - B2



Download MatrixForm.mw

Be carefull, this method doesn't handle correctly all the situations.

restart
alias (U=U(xi)):
Balance := proc(EQ)
  local eq   := eval(EQ, Diff=diff);
  local HODD := degree(eval(eval(eq, U=exp(__k*xi)), xi=0), __k);
  local HNLD := degree(eval(eq, U=__C), __C);
  M = solve(HNLD*M = HODD+M)
end proc:

eq := a*U+b*U^2+diff(U, xi$2)+diff(U, xi):
Balance(eq)
                             M = 2

eq := a*U+b*U^2+Diff(U, xi$2)+Diff(U, xi):
Balance(eq)

                             M = 2

eq := a*U+b*U^(-2)+diff(U, xi$5)+diff(U, xi$3)+c*U^3:
Balance(eq);
                                 5
                             M = -
                                 2

Let 

f := a -> x^3+a*x+1

a third degree polynom wrt x, parameterized by some real a.
In this simple case solve(f(a), x) doesn't return a list, nor a set, but a sequence:

f := a -> x^3+a*x+1solve(f(a), x):
whattype(%);
                            exprseq


If one defines a procedure sol this way

sol := a -> {solve(f(a), x)}:

one can easily verify that repeted executions of sol(a), where a is now assigned a numeric value, alwys returns theroots in the same order (defined by set):

  1. If the three roots are real the order is defined by '<', that is the smallest root is the first oneand largest the last one.
  2. If only one root is real and the two others are of the form p-q*I and  p+q*I (with q > 0), then the order is:
    1. the real root is the first,
    2. root  p-q*I is the second one,
    3. root  p+q*I is the last (third) one.

To avoid mixing the roots define the variable sola  this way:

sola := sol(a):

Then sola contains roots sorted according to the order given in points 1, 2, 3. This is because the formal result sol(a) contains a real root and two a priori conjugate complex roots (whoch might happento be both real for some values of a).

If you make a to vary in some real range, the first root in sola, which is assumed to be real, will take indeed real values, but also complex values, which means that its rank can take values 1, 2 or 3 depending on the value of a.
The plots in the attached file show how the rank of the three roots evolve as a ranges from -5 to +5.

To answer your question:

  • The order of roots depends on their expression (real, p-q*Ip+q*I) and then a root who was ranked first for some value of a, can be ranked 2 or 3 for a close value of a, giving the false impression of a "random" order returned by solve.
  • To understand (and control it?) this phenomenon you must "stuck" the roots, for example by doing sol := a -> {solve(f(a), x)}, and assign the roots a name, for instance
    R1, R2, R3 := sola[]:
    
    # check
    R1;
    R2;
    R3;
    Doing this will help you to track a given root as a evolves.

root_order.mw

restart:

for i from 1 to 1000 do

  # your own lines are replaced by a sleep of 0.01 second
  Threads:-Sleep(.01);

  if i mod 100 = 0 then
    DocumentTools:-Tabulate(
      [sprintf("%d", i)],
      'alignment'='left',
      'widthmode'='percentage',
      'width'=10
    )
  end if
end do

Download Counter.mw

An alternative: search on this site for "progression bar" 

I suggest you to solve the pde without any boundary condition, which will givea solution that contains integration constants, and next to evaluate these constants given the boundary condition.

If I'm not mistaken thesolution should be this one: laplacian_mmcdara.mw

Here is an example of compartmental model (4 compartments) and a way to assess its transition coefficients given some observations.
As I do not have any observation for this hypothetical model I used the classical technique wich consists in creating "pseudo-observations" which correspond to the value of this model at some times.
More precisely for a N-compartments model M(x1(t), ..., xN(t), t ; K) with transition matrix K  (K numeric), the "pseudo-observations" are mape of P (N+1)-tuples { (t, x[1](t), ..., x[N](t)), t in {t1, ..., tP} }.
The goal is then to recover blindly estimations of K by exploting some prior domain Dom(K).
Without observation noise this estimation should be equal to K provided the model is identifiable (which depends on K and of the observations).

The attached file presents the case of noise free observations and a noisy case.

Hope this will give you some idea to go further.
An_example.mw
An_example_edited.mw

For a 9-compartment model you have potentially 90 coefficients to assess (9^2 compartment-to-compartment coefficients plus 9 compartment-to-exterior coefficients) which is almost impossible with usual methods unless the 9-by-9 matrix K is very parse (by "usual methods" I mean optimization methods by contrast to neural network methods for instance)
Even with specific estimation methods it's very unlikely that the solution you get will be "numerically unique": it often happens that the estimation which minimizes some discrepancy between model predictions and observations is not a point but a variety of higher dimension or, even if this is indeed a single point, that large deviations in some directions around it (think to this point as a point in dimension 90 for instance) do not change significantly the value if the discrepancy.

So be extremely carefull in applying a minimization algorithm.
A preliminary analysis may help. For instance, for large times, the behavior of some xn(t) is generally governed by the largest coefficient kn, m: this is a trick which can enable assessing the values of the leading coefficients of each equation?

Without knowing your model it's not possible to say more (see @Carl Love's reply).

I assume the histograms you refer two are those created by the package Statistics?
If they come from package ImageTools what I say doesn't apply.

restart

with(Statistics):

N := 100:
K := 5:
S := Sample(Uniform(0, 1), N):

H := Histogram(S, maxbins=K):
plots:-display(H);

 

# Structure of H

op(H);

POLYGONS([[HFloat(0.011902069501241395), 0], [HFloat(0.20364021195311627), 0], [HFloat(0.20364021195311627), HFloat(1.0430892750001413)], [HFloat(0.011902069501241395), HFloat(1.0430892750001413)]], [[HFloat(0.20364021195311627), 0], [HFloat(0.39537835440499114), 0], [HFloat(0.39537835440499114), HFloat(0.9387803475001271)], [HFloat(0.20364021195311627), HFloat(0.9387803475001271)]], [[HFloat(0.39537835440499114), 0], [HFloat(0.587116496856866), 0], [HFloat(0.587116496856866), HFloat(0.8866258837501201)], [HFloat(0.39537835440499114), HFloat(0.8866258837501201)]], [[HFloat(0.587116496856866), 0], [HFloat(0.7788546393087409), 0], [HFloat(0.7788546393087409), HFloat(0.9909348112501342)], [HFloat(0.587116496856866), HFloat(0.9909348112501342)]], [[HFloat(0.7788546393087409), 0], [HFloat(0.9705927817606158), 0], [HFloat(0.9705927817606158), HFloat(1.3560160575001836)], [HFloat(0.7788546393087409), HFloat(1.3560160575001836)]], COLOUR(RGB, .24313725, .34117647, .54117647)), AXESSTYLE(BOX)

(1)

# H is made of K polygons (the K vertical bars)

g := [plottools:-getdata(H)];

g := [["polygon", [0.119020695012413951e-1 .. .203640211953116268, 0. .. 1.04308927500014126], Matrix(4, 2, {(1, 1) = 0.11902069501241395e-1, (1, 2) = .0, (2, 1) = .20364021195311627, (2, 2) = .0, (3, 1) = .20364021195311627, (3, 2) = 1.0430892750001413, (4, 1) = 0.11902069501241395e-1, (4, 2) = 1.0430892750001413}, datatype = float[8])], ["polygon", [.203640211953116268 .. .395378354404991139, 0. .. .938780347500127066], Matrix(4, 2, {(1, 1) = .20364021195311627, (1, 2) = .0, (2, 1) = .39537835440499114, (2, 2) = .0, (3, 1) = .39537835440499114, (3, 2) = .9387803475001271, (4, 1) = .20364021195311627, (4, 2) = .9387803475001271}, datatype = float[8])], ["polygon", [.395378354404991139 .. .587116496856865955, 0. .. .886625883750120081], Matrix(4, 2, {(1, 1) = .39537835440499114, (1, 2) = .0, (2, 1) = .587116496856866, (2, 2) = .0, (3, 1) = .587116496856866, (3, 2) = .8866258837501201, (4, 1) = .39537835440499114, (4, 2) = .8866258837501201}, datatype = float[8])], ["polygon", [.587116496856865955 .. .778854639308740881, 0. .. .990934811250134162], Matrix(4, 2, {(1, 1) = .587116496856866, (1, 2) = .0, (2, 1) = .7788546393087409, (2, 2) = .0, (3, 1) = .7788546393087409, (3, 2) = .9909348112501342, (4, 1) = .587116496856866, (4, 2) = .9909348112501342}, datatype = float[8])], ["polygon", [.778854639308740881 .. .970592781760615808, 0. .. 1.35601605750018361], Matrix(4, 2, {(1, 1) = .7788546393087409, (1, 2) = .0, (2, 1) = .9705927817606158, (2, 2) = .0, (3, 1) = .9705927817606158, (3, 2) = 1.3560160575001836, (4, 1) = .7788546393087409, (4, 2) = 1.3560160575001836}, datatype = float[8])]]

(2)

# to get the "bins" you can
# (1) extract the K matrices from the list above

bins := map2(op, 3, g);

bins := [Matrix(4, 2, {(1, 1) = 0.11902069501241395e-1, (1, 2) = .0, (2, 1) = .20364021195311627, (2, 2) = .0, (3, 1) = .20364021195311627, (3, 2) = 1.0430892750001413, (4, 1) = 0.11902069501241395e-1, (4, 2) = 1.0430892750001413}, datatype = float[8]), Matrix(4, 2, {(1, 1) = .20364021195311627, (1, 2) = .0, (2, 1) = .39537835440499114, (2, 2) = .0, (3, 1) = .39537835440499114, (3, 2) = .9387803475001271, (4, 1) = .20364021195311627, (4, 2) = .9387803475001271}, datatype = float[8]), Matrix(4, 2, {(1, 1) = .39537835440499114, (1, 2) = .0, (2, 1) = .587116496856866, (2, 2) = .0, (3, 1) = .587116496856866, (3, 2) = .8866258837501201, (4, 1) = .39537835440499114, (4, 2) = .8866258837501201}, datatype = float[8]), Matrix(4, 2, {(1, 1) = .587116496856866, (1, 2) = .0, (2, 1) = .7788546393087409, (2, 2) = .0, (3, 1) = .7788546393087409, (3, 2) = .9909348112501342, (4, 1) = .587116496856866, (4, 2) = .9909348112501342}, datatype = float[8]), Matrix(4, 2, {(1, 1) = .7788546393087409, (1, 2) = .0, (2, 1) = .9705927817606158, (2, 2) = .0, (3, 1) = .9705927817606158, (3, 2) = 1.3560160575001836, (4, 1) = .7788546393087409, (4, 2) = 1.3560160575001836}, datatype = float[8])]

(3)

# (2) extract only the ranges
bins := map2(op, 2, g);

[[0.119020695012413951e-1 .. .203640211953116268, 0. .. 1.04308927500014126], [.203640211953116268 .. .395378354404991139, 0. .. .938780347500127066], [.395378354404991139 .. .587116496856865955, 0. .. .886625883750120081], [.587116496856865955 .. .778854639308740881, 0. .. .990934811250134162], [.778854639308740881 .. .970592781760615808, 0. .. 1.35601605750018361]]

(4)

# An other way is to use TallyInto:
# (note this method gives the counts)

epsilon := 1e-9:  # to catch the right end point

r := [seq((min..max+epsilon)(S), (max-min)(S)/K)]:
R := [seq(r[i]..r[i+1], i=1..K)]:

T := TallyInto(S, R)

[HFloat(0.011902069501241397) .. HFloat(0.203640212) = 20, HFloat(0.203640212) .. HFloat(0.3953783545) = 18, HFloat(0.3953783545) .. HFloat(0.587116497) = 17, HFloat(0.587116497) .. HFloat(0.7788546395) = 19, HFloat(0.7788546395) .. HFloat(0.970592782) = 26]

(5)

# If you want the frequencies do this

lhs~(T) =~ (rhs/N)~(T)
 

[HFloat(0.011902069501241397) .. HFloat(0.203640212) = 1/5, HFloat(0.203640212) .. HFloat(0.3953783545) = 9/50, HFloat(0.3953783545) .. HFloat(0.587116497) = 17/100, HFloat(0.587116497) .. HFloat(0.7788546395) = 19/100, HFloat(0.7788546395) .. HFloat(0.970592782) = 13/50]

(6)

 

Download HowToCatchTheBins.mw

In this kind of problem  the causality principle must hold: the Delta pulse is the cause of y(t), meaning that y(t) doesn't exist before Delta is applied.
So it doesn't matter to consider the limit of y(t) when t goes to 0 from the left.
The Laplace transform, for instance, is perfectly suited tosolve this (linear) problem:

restart
de := D(y)(t) + y(t)/tau = Dirac(t)/tau;
                             y(t)   Dirac(t)
                   D(y)(t) + ---- = --------
                             tau      tau   
with(inttrans):
lde := laplace(de, t, p)
                                   laplace(y(t), t, p)    1 
    p laplace(y(t), t, p) - y(0) + ------------------- = ---
                                           tau           tau
lde0 := eval(lde, y(0)=0):
ly := rhs(isolate(lde0, laplace(y(t), t, p))):
Y := unapply(invlaplace(ly, p, t), t)
        /   t \
     exp|- ---|
        \  tau/
t -> ----------
        tau    

Download laplace.mw

Two solutions:

restart:
with(LinearAlgebra):

sanity := proc()
  local A, __U, __S, __Vt;
  A :=RandomMatrix(3,10);
  __U, __S, __Vt := SingularValues(A, output=['U','S','Vt']);
end proc:

sanity():

or (IMO better for future use)

restart:
with(LinearAlgebra):

sanity := proc()
  local A;
  A :=RandomMatrix(3,10);
  SingularValues(A, output=['U','S','Vt']);
end proc:

U, VS, Vt := sanity():

The (A?) key to get a solution up to xi=0.25 is to use a continuation method (see here help(dsolve, numeric_bvp, advanced) ).
I wasn't capable to get a solution for higher values of xi.

Does this "critical" value of 0.25 means something to you?
If not you can try, as suggested by the error messages, to change the continuation strategy... but this likely require a lot of time that I have not to help you further.

secod_code_mmcdara.mw

in exponentials:

restart; with(plots); Digits := 10; L := 1; TT := 0.1e-2; l := 1/5; b[1] := .18; b[2] := 2*10^(-9); k[1] := 1.3*10^(-7); k[-1] := 24; k[2] := 7.2; p := .9997; d[1] := 0.412e-1; f := .2988*10^8; g := 2.02*10^7; s := 1.36*10^4; E[0] := 3.3*10^5; T1[0] := .5*10^9; C1[0] := 3.3*10^5; alpha[0] := 10^(-10); D1 := 10^(-6); D2 := 10^(-2); D3 := 10^(-6); d[4] := 1.155*10^(-2); t[0] := 1/D1; kappa := 10^4; k[3] := 300*(24*60); chi := 0; sigma := d[1]*t[0]; rho := f*t[0]*C1[0]/(E[0]*T1[0]); mu := k[1]*t[0]*T1[0]; eta := g/T1[0]; `&epsilon;` := t[0]*C1[0]*(p*k[2]+k[-1])/E[0]; omega := D3/D1; beta1 := b[1]*t[0]; beta2 := b[2]*T1[0]; phi := k[1]*t[0]*E[0]; lambda := t[0]*C1[0]*(k[-1]+k[2]*(1-p))/T1[0]; psi := t[0]*(k[-1]+k[2]); gamma1 := chi*alpha[0]/D1; delta := D2/D1; kappa := k[3]*t[0]*C1[0]/alpha[0]; xi := d[4]*t[0]; PDE1 := diff(u(y, t), t) = diff(u(y, t), y, y)-gamma1*(u(y, t)*(diff(theta(y, t), y, y))+(diff(u(y, t), y))*(diff(theta(y, t), y)))+sigma*piecewise(y <= l, 0, 1.)+rho*C(y, t)/(eta+T(y, t))-sigma*u(y, t)-mu*u(y, t)*T(y, t)+`&epsilon;`*C(y, t); PDE2 := diff(theta(y, t), t) = delta*(diff(theta(y, t), y, y))+kappa*C(y, t)-xi*theta(y, t); PDE3 := diff(T(y, t), t) = omega*(diff(T(y, t), y, y))+beta1*(1-beta2*T(y, t))*T(y, t)-phi*u(y, t)*T(y, t)+lambda*C(y, t); PDE4 := diff(C(y, t), t) = mu*u(y, t)*T(y, t)-psi*C(y, t); ICs := u(y, 0) = piecewise(0 <= y and y <= l, 0, 1-exp(-0.1e-2*(y-l)^2)), T(y, 0) = piecewise(0 <= y and y <= l, 1-exp(-0.1e-2*(y-l)^2), 0), C(y, 0) = piecewise(l-`&epsilon;` <= y and y <= l+`&epsilon;`, exp(-0.1e-2*(y-l)^2), 0), theta(y, 0) = 0; BCs := {(D[1](T))(0, t) = 0, (D[1](T))(1, t) = 0, (D[1](theta))(0, t) = 0, (D[1](theta))(1, t) = 0, (D[1](u))(0, t) = 0, (D[1](u))(1, t) = 0}; HA1 := [0]; AA := [red, green, blue, cyan, purple, black]

 

PDE := {PDE1, PDE2, PDE3, PDE4}; pds := pdsolve(PDE, {ICs, BCs[]}, numeric, spacestep = 1/50, timestep = 1/50)

{diff(C(y, t), t) = 65000000.00*u(y, t)*T(y, t)-31200000.0*C(y, t), diff(T(y, t), t) = diff(diff(T(y, t), y), y)+180000.00*(1-1.000000000*T(y, t))*T(y, t)-42900.00000*u(y, t)*T(y, t)+15841.42560*C(y, t), diff(theta(y, t), t) = 10000*(diff(diff(theta(y, t), y), y))+0.1425600000e28*C(y, t)-11550.00000*theta(y, t), diff(u(y, t), t) = diff(diff(u(y, t), y), y)+41200.0000*piecewise(y <= 1/5, 0, 1.)+59760.00000*C(y, t)/(0.4040000000e-1+T(y, t))-41200.0000*u(y, t)-65000000.00*u(y, t)*T(y, t)+31197840.00*C(y, t)}

 

_m4725937312

(1)

Plotsu := pds:-plot[plots:-display](u(y, t), t = TT, linestyle = "solid", labels = ["y", "u"], color = red, numpoints = 800); -1; plots:-display(Plotsu)

 

NULL

Download Num_PDE_mmcdara.mw

I agree with Rouben.
You can easily find (on the web or in your math books) the equation of the tangent plane to a sphere and try to code them in Maple.
Maybe this is what you have been asked for?

If you are not comfortable with maths and need to solve this problem quickly, you can use the geom3d package:
With_geom3d.mw
This will answer your question, but it won't help you understand how the equations were constructed.

Maybe reading carefully the three procedures TangentPlane, IsOnObject and onobjl could help you understand how to derive the equations.


here is an extremely simple way do draw random triangles
 

restart

with(plots):
with(plottools):
with(Statistics):

interface(version);

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

randomize();

c := rand(0. .. 1):
r := rand(0. .. 2.*Pi):
p := [seq(r(), k=1..3)]:
display(
  plottools:-circle([0, 0], 1, color=gray),
  seq(
    PLOT(
      CURVES(
        [sin,cos]~([seq(r(), k=1..3)])[[$1..3, 1]]
        , COLOR(RGB, c(), c(), c())
        , THICKNESS(2)
      )
    )
    , n=1..3
  )
)

169245464804467

 

 

 

 

Download RandomTriangles.mw

Let me know if you have some constraints on the triangles.
For instance here is a simple way to generate triangles which contain the center of the circle:

 

restart

with(plots):
with(plottools):
with(Statistics):

interface(version);

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

randomize();

c := rand(0. .. 1):
p := 0, rand(0. .. 1.*Pi)():
q := rand(1.*Pi.. p[2]+1.*Pi)():
p := [p[], q]:

T := PLOT(
       CURVES(
         [cos, sin]~(p)[[$1..3, 1]]
         , COLOR(RGB, c(), c(), c())
         , THICKNESS(2)
       )
     ):

display(
  plottools:-circle([0, 0], 1, color=gray),
  rotate(T, rand(0. .. 2.*Pi)())
)

169246137904467

 

 

 

 

Download RandomTriangle_2.mw

Note that the procedure in RandomTriangle_2.mw doesn't produce uniformly distributed triangles in the following sense: while p[2] is obviously uniformly distributed over [0, Pi], one can see that q (the third point p[3]) is not uniformly distributed over [Pi, 2*Pi]

# Do this to convince you
K := 10000:
P := Matrix(K, 2):
for k from 1 to K do
  p := rand(0. .. 1.*Pi)():
  q := rand(1.*Pi.. p+1.*Pi)():
  P[k, 1] := p:
  P[k, 2] := q:
end do:
Histogram(P[..,1]);
Histogram(P[..,2]);

Here is the exact expression of the PDF of q:

p2 := RandomVariable(Uniform(0, Pi));
q  := Pi + RandomVariable(Uniform(0, 1)) * p2;

# and thus 
combine(PDF(Y, y), ln);
             /                                 /  -y + Pi\  
             |                               ln|- -------|  
             |                                 \    Pi   /  
    piecewise|y - Pi < 0, 0, y - Pi <= Pi, - -------------, 
             \                                    Pi        

                    \
                    |
                    |
      Pi < y - Pi, 0|
                    /


 

First 10 11 12 13 14 15 16 Last Page 12 of 58