mmcdara

6568 Reputation

18 Badges

8 years, 103 days

MaplePrimes Activity


These are answers submitted by mmcdara

@JAMET 

Il y a 3 coniques et plusieurs cas particuliers pour chacune d'elles. De plus certaines transformations classiques pour obtenir leur forme réduie (rotation puis translation) ne "marchent" pas toujours.
Si les conoques ne sontpas dégénérées, par exemple une parabole est bien une parabole et non pas deux droites arallèles, ou sui une ellipse et bien une ellipse et non pas un seul point, alors la procédure classique rotation+translations s'applique toujours.

Ce sont en effet les cas particuliers qui compliquent la chose (cf Bibmath et Wiki pour plus de détails sur les différents cas possibles)


Pour votre conique:

(
Voici un code "annexe" Gender_and_Signature.mw pour déterminer le genre et la signature de votre forme quadratique:

  • Déterminant       ==> genre=parabole,
  • Signature=(2, 1)  ==> classe=parabole (parabole non dégénérée)

)

 


Forme réduite et tracés
 

restart:

with(plots):
alias(PT=plottools):

f := (x, y) -> 9*x^2 - 24*y*x + 16*y^2 + 10*x - 70*y + 175;

proc (x, y) options operator, arrow; 9*x^2-24*y*x+16*y^2+10*x-70*y+175 end proc

(1)

xy := Vector(2, [x, y]):
XY := Vector(2, [X, Y]):
r  := theta -> Matrix(2$2, [cos(theta), -sin(theta), sin(theta), cos(theta)]):

rot := [entries(xy =~ r(theta) . XY, nolist)]

[x = cos(theta)*X-sin(theta)*Y, y = sin(theta)*X+cos(theta)*Y]

(2)

g := unapply(expand(f(op(rhs~(rot)))), (X, Y))

proc (X, Y) options operator, arrow; 9*cos(theta)^2*X^2+14*cos(theta)*X*sin(theta)*Y+9*sin(theta)^2*Y^2-24*sin(theta)*X^2*cos(theta)+24*sin(theta)^2*X*Y-24*cos(theta)^2*Y*X+24*cos(theta)*Y^2*sin(theta)+16*sin(theta)^2*X^2+16*cos(theta)^2*Y^2+10*cos(theta)*X-10*sin(theta)*Y-70*sin(theta)*X-70*cos(theta)*Y+175 end proc

(3)

c := coeffs(g(X, Y), [X, Y], 'mon'):
z := c[ListTools:-Search(X*Y, [mon])]

14*cos(theta)*sin(theta)+24*sin(theta)^2-24*cos(theta)^2

(4)

solve(z, theta);
Theta := %[1];

-arctan(4/3)+Pi, arctan(3/4), -arctan(4/3), arctan(3/4)-Pi

 

-arctan(4/3)+Pi

(5)

R := r(Theta);

ROT := [entries(xy =~ r(Theta) . XY, nolist)]

R := Matrix(2, 2, {(1, 1) = -3/5, (1, 2) = -4/5, (2, 1) = 4/5, (2, 2) = -3/5})

 

[x = -(3/5)*X-(4/5)*Y, y = (4/5)*X-(3/5)*Y]

(6)

G0 := eval(g(X, Y), theta=Theta)

25*X^2-62*X+34*Y+175

(7)

if has(G0, X^2) then
  G1       := Student:-Precalculus:-CompleteSquare(G0, X);
  delta__X := op([2, 1, 2], op(1, G1));
  st       := solve(identity(s*(Y+t)=G1-op(1, G1), Y), [s, t])[];
  delta__Y := eval(t, st);
  `Reduced Form` := eval(G1, {X=U-delta__X, Y=V-delta__Y});

elif has(G0, Y^2) then
  G1       := Student:-Precalculus:-CompleteSquare(G0, Y);
  delta__Y := op([2, 1, 2], op(1, G1));
  st       := solve(identity(s*(X+t)=G1-op(1, G1), X), [s, t])[];
  delta__X := eval(t, st);
  `Reduced Form` := eval(G1, {X=U-delta__X, Y=V-delta__Y});
end if;

25*(X-31/25)^2+34*Y+3414/25

 

-31/25

 

[s = 34, t = 1707/425]

 

1707/425

 

25*U^2+34*V

(8)

pf  := implicitplot(
         f(x, y)
         , x=-12..12, y=-12..12
         , grid=[60$2]
         , color=blue
         , legend=typeset(f)
       ):

pUV := implicitplot(
         `Reduced Form`
         , U=-10..10, V=-10..10
         , grid=[60$2]
         , color=red
         , style=point, symbol=circle
         , legend=typeset(`Reduced Form`=0)
       ):

A1 := display(PT:-arrow([0, 0], [0, -10], .2, .4, .1, color=green)):
A2 := display(PT:-arrow([0, 0], [10, 0], .2, .4, .1, color=green)):

pU := textplot([0, -10, U], font=[Helvetica, 10], align=right):
pV := textplot([10,  0, V], font=[Helvetica, 10], align=above):

display(
  pf
  , PT:-rotate(PT:-translate(pUV, -delta__X, -delta__Y), Theta)

  , PT:-rotate(PT:-translate(A1,  -delta__X, -delta__Y), Theta)
  , PT:-rotate(PT:-translate(A2,  -delta__X, -delta__Y), Theta)

  , PT:-rotate(PT:-translate(pU,  -delta__X, -delta__Y), Theta)
  , PT:-rotate(PT:-translate(pV,  -delta__X, -delta__Y), Theta)

  , view=[-5..12, 0..12]
  , scaling=constrained
)

 

 


 

Download Reduced_Parabola_2.mw


UPDATED 09/14/2024

This is typically a problem which is not well posed as it enables an infinity of solutions.

To make you understand this let's take this mechanical analogy

You are in 1D. A rod is made of two rods of same length L, the lewt one weights 10 kg, the right one 1kg.
The left extremity of the left rod is at position x=1 (so the system extends from x=1 to x=2).
Compute the position of the center of mass (the mean in Statistics) ?
Would you say: that it is (10*L/2 +1*(L+L/2)) / 11 = 13*L/2
if so you would be wrong: you missed a fundamental assumtion about the density of the mass distribution in each rod. 
The answer 13*L/2 is correct iif you assume the density is constant in each bar.

Relation with your problem.
If the probability density function (coninuous case) or the probability mass function (discrete case) is constant over each interval, then you can resume each interval by its "center of mass" anf rewrite your problem in termes of "weighted data": 

 

So your problem has an infinity of answers unless you correctly formulate assumptions on what happens within each class, or on the distribution of the underlying population those classes are built from.


More importantly
: I hope the question you pose is a simple amusement because in real data analysis you never compute statistics from data organized in classes.
You compute them from the raw data that you can organized further on as classes... if you want.
Computing statistics on classes and numbers implies loss of information and ambiguity.
This loss of information prevents from calculating statistics for class-based data.


Nevertheless here is my contribution to your problem stat2.mw.

I UPDATED this reply by adding file BOUNDS.mw which provides bounds for the mean, variance and quartiles when no assumption are made on the distribution of the data or when you do not know them:that's the only objective answer an honorable person should give you.
Whatever tthose assumptions might be your are assured that those bounds are these ones:

_____________________________________________________________________________________

Auxilliary point concerning your MMA results:

At the evidence the person who answered your question reduced you problem to a problem of assessing statistics on weighted data (which is wrong).

For your information, is one of the World reference code in statistics; its Weighted.Desc.Stat package is aimed to compute statistics for weighted data. 
Considering data consist in the vector x centers of classes  (which corresponds to the homogenous mass density distribution in the mechanical analogy) and in vector mu of weights, on gets these estimators when x is the vector of the centers of classes:.

> x <- c(1.25, 3.75, 6.25, 8.75)
> mu <- c(18, 11, 13, 6)
> w.mean(x, mu)
[1] 4.114583
> w.var(x, mu)
[1] 7.028537
> w.sd(x, mu)
[1] 2.651139
> 

Note thatthe variance here differs from MMA's (=7.549370660)


The formula Weighted.Desc.Stat uses to assess this variance, and why it uses it, are reproduced below.


(1)  Replace all occurrence of 

myfac[i]

by

myfac(i)


(2)  Replace all occurrence sum by add.
    
 (look to the terms addition and sum in the help pages, Page types=Dictionary)

sum_vs_add.mw


Orignal reply deleted by the author.

Revised version: Updated.mw

 


From the reference you give:

 

restart

a := 1;

h := 1;

# pA := [0, 0, 0]; # useless

pB := [a, 0, 0];

pC := [a, a, 0];

pD := [0, a, 0];

pS := [0, 0, h];

1

 

1

 

[1, 0, 0]

 

[1, 1, 0]

 

[0, 1, 0]

 

[0, 0, 1]

(1)

local D:
symbols := [B, C, D, S]:

use geom3d in
  seq(point(s, p||s), s in symbols);
  plane(SBC, [S, B, C]);
  plane(SCD, [S, C, D]);
  sbc    := < NormalVector(SBC) >;
  scd    := < NormalVector(SCD) >;

  # from the reference you give :
  # "the dihedral angle, φ... satisfies 0 ≤ φ ≤ π/2"
  # So 2*π/3 and 3*π/4 cannot be solutions as you say.
  
  cosphi := abs(Statistics:-Correlation(sbc, scd));
end use:

phi := identify(arccos(cosphi))

(1/3)*Pi

(2)

 


 

Download Dihedral_Angle.mw


As you've already noticed, there's nothing immediate..
The trick to derive equations 9, 11 and 13 is to multiply both sides of equation 7 by G' and integrate wrt eta (without without forgetting the "constant" K)

(Done with Maple 2015)
 

restart

eq_7 := diff(G(eta), eta$2) + sigma*G(eta) = nu

diff(diff(G(eta), eta), eta)+sigma*G(eta) = nu

(1)

 

sigma < 0

 

negsol := rhs( ( dsolve(eq_7) assuming sigma < 0) ):
negsol := expand(convert(negsol, trig)):


CS      := [C, S]:
replace := convert(indets(negsol, function), list) =~ CS:
negsol  := collect(eval(negsol, replace), CS):
B1B2    := solve({coeff(negsol, C)=B1, coeff(negsol, S)=B2}, [_C1, _C2]):

eq_8 := eval(eval(negsol, %[]), (rhs=lhs)~(replace));

B1*cosh((-sigma)^(1/2)*eta)+B2*sinh((-sigma)^(1/2)*eta)+nu/sigma

(2)

use IntegrationTools in

  # multiply both member of eq_7 by G'

  expand~(eq_7*~diff(G(eta), eta));
 
  # Integrate over eta

  map((Expand@Int), %, eta);
 
  # evaluate

  value~(%);
 
  # divide each term by G^2 (assuming G <> 0)

  expand(% /~ G(eta)^2);
 
  # isolate (G'/G)^2

  ref := isolate(%, (diff(G(eta), eta) / G(eta))^2);
 
  # add an integration "constant"

  ref := lhs(ref) = rhs(ref) + __K;
 
  # plug in ref the expression of G(eta) given by eq_8

  aux := eval(ref, G = (eta -> eq_8));

  # solve for __K

  K := simplify(solve(aux, __K));

  # Identify the denominator of K

  den := simplify(denom(K), {eq_8=G(eta)});

  # Rewrite K according to theprevious result

  K := numer(K)/den;

  # Finally

  eq_9 := eval(ref, __K=K);

end use:

eq_9;

(diff(G(eta), eta))^2/G(eta)^2 = 2*nu/G(eta)-sigma+(B1^2*sigma^2-B2^2*sigma^2-nu^2)/(sigma*G(eta)^2)

(3)

 

sigma > 0

 

eq_10 := eval( rhs( ( dsolve(eq_7) assuming sigma > 0) ), [_C1=B1, _C2=B2])

sin(sigma^(1/2)*eta)*B2+cos(sigma^(1/2)*eta)*B1+nu/sigma

(4)

use IntegrationTools in
 
  # plug in ref the expression of G(eta) given by eq_8

  aux := eval(ref, G = (eta -> eq_10));

  # solve for __K

  K := simplify(solve(aux, __K), size):
  K := simplify(numer(K))/denom(K);

  # Identify the denominator of K

  den := simplify(denom(K), {eq_10=G(eta)});

  # Rewrite K according to theprevious result

  K := numer(K)/den;

  # Finally

  eq_11 := eval(ref, __K=K);

end use:

eq_11

(diff(G(eta), eta))^2/G(eta)^2 = 2*nu/G(eta)-sigma+(B1^2*sigma^2+B2^2*sigma^2-nu^2)/(sigma*G(eta)^2)

(5)

 

sigma = 0

 

zerosol := dsolve(eval(eq_7, sigma = 0)):
eq_12   := rhs(eval(zerosol, {_C1=B1, _C2=B2}));

(1/2)*nu*eta^2+B1*eta+B2

(6)

use IntegrationTools in

  # multiply both member of eq_7 by G'

  expand~(eval(eq_7, sigma=0)*~diff(G(eta), eta));
 
  # Integrate over eta

  map((Expand@Int), %, eta);
 
  # evaluate

  value~(%);
 
  # divide each term by G^2 (assuming G <> 0)

  expand(% /~ G(eta)^2);
 
  # isolate (G'/G)^2

  ref := isolate(%, (diff(G(eta), eta) / G(eta))^2);
 
  # add an integration "constant"

  ref := lhs(ref) = rhs(ref) + __K;
 
  # plug in ref the expression of G(eta) given by eq_8

  aux := eval(ref, G = (eta -> eq_12));

  # solve for __K

  K := simplify(solve(aux, __K), size):
  K := simplify(numer(K))/denom(K);

  # Identify the denominator of K

  den := simplify(denom(K), {eq_12=G(eta)});

  # Rewrite K according to theprevious result

  K := simplify(numer(K)/den);

  # Finally

  eq_13 := eval(ref, __K=K);

end use:

eq_13

(diff(G(eta), eta))^2/G(eta)^2 = 2*nu/G(eta)+(B1^2-2*B2*nu)/G(eta)^2

(7)

 


 

Download This_way.mw



It's always annoying when the question you ask is not answered nor commented. 
Does this mean that nobody has any answers, or that the question isn't even worth spending time answering because it's completely irrelevant?
I do not consider your question lacks interest.

I'm afraid there is no solution to your problem, even in the far simpler 2D case.

Here are a few ideas ( a white elephant?) to rotate a text
Aligned.mw


This is bery basic stuff that must be enhanced to give acceptable results: increase the size of the text in t:=... (for instance font=[Helvetica, 50] for a better definition), adjust the threhold in function Tf , adjust the gridsize in densityplot, ...).

Hope this will help

restart

# Access to the help page

?sum

# from ,sum help page, example 4 (Maple 2015)

sum(1/k!,k=0..infinity);
evalf(%);

exp(1)

 

2.718281828

(1)

# A first example invoking the exponential function

sum(exp(-k), k=0..infinity);

-1/(exp(-1)-1)

(2)

# Use of the Inert form ('Sum'):

Sum(exp(-k), k=0..infinity) = sum(exp(-k), k=0..infinity);

Sum(exp(-k), k = 0 .. infinity) = -1/(exp(-1)-1)

(3)

# Be careful: functions 'add' and 'sum' do mean the same thing.
# This is a common error.
#
# To understand the difference between them: 'add' stands for 'addition' while
# 'sum' stands for... 'sum'
# (see these terms in Maple's dictionary: within the "Maple xxx Help" window: in the
# left pane click on the drop-down box labeled "Page Types",  unclick "Select all"
# and select only "Dictionary").
#
# Once done type addition in the top-left field and "Search": the right page should
# the definition of the term addition and refer to the function contain 'add'.
#
# Next type sum instead of addition and read carefuly the second item in the right pane:
#    2.  The limit of the sequence  of partial sums of the first n terms of an infinite series ,
#        as n tends to infinity.
#

 

 

Download sum.mw

Can you please keep this as a comment and avoid converting it into an answer, there is no reason to do so.

After your dsolve command type this to see that sys still contains an unknown quantity named e for which no ic/bc condition is given, so the error you get:

indets(sys1, name) minus {eta}
                              {e}

Cure: fix the value of e before executing dsolve or do

dsolve(eval(sys, e=some_numeric_value), numeric)

For instance

sol1 := dsolve(eval(sys1, e = 1), numeric);
           sol1 := proc(x_bvp)  ...  end;

restart:

with(geometry):

with(plots):

 

Bl := color = black;

y0 := x -> -ln(1 - exp(-x)):

y1 := x -> -ln(-1 + exp(-x)):

y2 := x -> -ln(1 + exp(-x)):

 

p  := plot(y0(x), x = 0.02 .. 4, scaling = constrained, color = blue):

p1 := plot(y2(x), x = -4 .. 4, scaling = constrained, color = green):

p2 := plot(y1(x), x = -4 .. 0, scaling = constrained, color = red):

display({p, p1, p2}, view = [-4 .. 4, -4 .. 5]);

color = black

 

 

# First way

plots:-display(
  plots:-inequal({y >= y2(x), y <= y1(x)}, x=-4..0, y=-4..4),
  plots:-inequal({y >= y2(x), y <= y0(x)}, x=0..4, y=-4..4)
);

 

# A less efficient way but having the characteristic function of the blue domain
# might be interesting.

interior := (x, y) -> piecewise(
                        x >=0
                        , piecewise(y < y0(x) and y > y2(x), 1, 0)
                        , piecewise(y < y1(x) and y > y2(x), 1, 0)
                      ):

plots:-contourplot(
  interior(x, y)
  , x=-4..4, y=-4..4
  , contours=1
  , grid=[200, 200]    # use grid=[400, 400] for a better rendering
  , filled=true
)

 

Area := int(int(1, y=y2(x)..y0(x)), x=0..4) + int(int(1, y=y2(x)..y1(x)), x=-4..0);
evalf(Area);

(1/6)*Pi^2-dilog(1-exp(-4))+dilog(1+exp(-4))-dilog(exp(4))-4*ln(-1+exp(4))-dilog(1+exp(4))

 

4.861536918

(1)
 

 

Download Amoeba.mw

A few workarounds colors.mw
 


which works for polynomial expressions of whose all functions depend on the same indeterminate.

For instance

expr = x(t)*diff(z(t), t)^2,
expr = diff(x(t), t$2)+x(t)*diff(z(t), t$3),
...

but not

expr = x(t)*z(u)^2,
expr = x(t)*diff(cos(u(t)), t),
...

 
 

restart

ddf := proc(F, {n::posint:=1})

  local f, df, idd, idf, rules, i, deg, opi:
  f  := eval(F, indets(F, name) =~ indets(F, name)(__t));
  df := diff(f, __t$n);

  idd, idf := selectremove(has, indets(df), diff);
  idd := convert(idd, list);
  idf := convert(idf minus {__t}, list);

  rules := NULL:
  for i in idd do
    if is(op([0, 0, 0], convert(i, D)) = `@@`) then
      deg := op(2, op([0, 0], convert(i, D)));
      opi := op([0, 1], convert(i, D));
    else
      deg := 1:
      opi := op([1, 0], i);
    end if:
    rules := rules, i = cat(`#mrow(mi("`, opi, `")`, seq(`,mi("&#x27;")`, j=1..deg), `)`);
  end do:
  for i in idf do
    rules := rules, i = cat(`#mi("`, op(0, i), `")`);
  end do;
  
  eval(df, [rules])
end proc:

 

ddf(z^2+y);
ddf(z^2+y, n=1);
ddf(z^2+y, n=2);
ddf(t, n=4);

2*`#mi("z")`*`#mrow(mi("z"),mi("&#x27;"))`+`#mrow(mi("y"),mi("&#x27;"))`

 

2*`#mi("z")`*`#mrow(mi("z"),mi("&#x27;"))`+`#mrow(mi("y"),mi("&#x27;"))`

 

2*`#mi("z")`*`#mrow(mi("z"),mi("&#x27;"),mi("&#x27;"))`+2*`#mrow(mi("z"),mi("&#x27;"))`^2+`#mrow(mi("y"),mi("&#x27;"),mi("&#x27;"))`

 

`#mrow(mi("t"),mi("&#x27;"),mi("&#x27;"),mi("&#x27;"),mi("&#x27;"))`

(1)

# Your result: y*z*(2*z*z'+y')*y''+6*y^2*x''''

expr := y * z * ddf(z^2+y, n=1) * ddf(y, n=2) + 6 * ddf(x, n=4) *y^2;

y*z*(2*`#mi("z")`*`#mrow(mi("z"),mi("&#x27;"))`+`#mrow(mi("y"),mi("&#x27;"))`)*`#mrow(mi("y"),mi("&#x27;"),mi("&#x27;"))`+6*`#mrow(mi("x"),mi("&#x27;"),mi("&#x27;"),mi("&#x27;"),mi("&#x27;"))`*y^2

(2)

 


 

Download An_alternative.mw

 



Could this help you Fireworks?

Another exemple of trajectory fading is provided in Jonglage_4.mw.
Here is an animation of a ball bouncing within a triangular shape: at the current time T the trajectory is plotted between T-dt and T, a colorscheme whose first color is equal to the background color mimics a fadding trajectory.

Based on Thomas' example  you would obaiin this


Thomas_with_fading.mw

 

It is easy to verify that G(x, y) = G(y, x).
Then the minimum is to be search along the line y=x.

# Verify that G(x, y)
simplify(G(x, y)-G(y, x))
                               0

# Define a univariate quantity T
T := expand(G(x, x));
s := [fsolve(diff(T, x))];
                  s := [0., .8073218015, 1.015827227]

# Which one is a maximizer/minimizer ?
 eval~(diff(T, x$2), x=~s);
                 [-5.600000000, 30.91991289, -88.23416528]

# then s[2] is the minimizer and the minimum is equal tools

G(s[2], s[2])
                          -0.397001070

# With minimize
minimize(T, x=0..1, location=true);
      -0.3970010694, {[{x = 0.8073218015}, -0.3970010694]}

(In Statistics a model is said to be linear if it writes as a linear combination of its parameters, not of its regressors [here lambda])

Here obj simply writes C__10*U + C__10*V where both U and V are known functions of lambda.
Then your problem is linear wrt C__10 and C__10LINEAR.mw 


Linearization is by far the simplest way to solve the problem (you can even find the solution by hand).

1 2 3 4 5 6 7 Last Page 1 of 56