sand15

1209 Reputation

15 Badges

10 years, 351 days

MaplePrimes Activity


These are answers submitted by sand15

What do the regions labelled  TM1, TM2, TM3 are aimed to represent?

Did you mean this: Regions_where_each_TMi_is_the_largest.mw

restart;

with(geometry):

with(StringTools):

interface(worksheetdir):

currentdir(%):

toX := proc(e)
  if e::list then
    cat(
      "\\left(",
      seq( cat(latex(u, 'output' = 'string'), "; "), u in e[1..-2]),
      latex(e[-1], 'output' = 'string'),
      "\\right)"
    )
  else
    latex(e, 'output' = 'string')
  end if:
end proc:

printf("\\documentclass[12pt]{article}\n"):

printf("\\usepackage{amsmath,amssymb}\n"):

printf("\\usepackage{enumitem}\n"):

printf("\\begin{document}\n\n"):

f := x -> (x^2 + 4*x + 7)/(x + 1):

df := simplify(diff(f(x), x)):

cuctri := sort([solve(df = 0, x)], key = evalf):

g := simplify(diff(df, x)):

xcd := rhs(solve([df = 0, g(x) < 0], x)[1]):

xct := rhs(solve([df = 0, 0 < g(x)], x)[1]):

ycd := simplify(f(xcd)):

yct := simplify(f(xct)):

mycd := coordinates(point(A, xcd, ycd)):

myct := coordinates(point(B, xct, yct)):

L := [cat("Let a function be given: $y = ", toX(f(x)), "$."), cat("Its derivative is: $y' = ", toX(df), "$."), cat("The maximum point of the graph  $ ", toX(mycd), "$.")]:

 

printf("\\begin{enumerate}[label=\\arabic*)]\n");

for item in L do

    printf("\\item %s\n", item);

end do;

printf("\\end{enumerate}\n\n");

printf("\\end{document}\n\n");

 

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}[label=\arabic*)]
\item Let a function be given: $y = {\frac {{x}^{2}+4\,x+7}{x+1}}$.
\item Its derivative is: $y' = {\frac {{x}^{2}+2\,x-3}{ \left( x+1 \right) ^{2}}}$.
\item The maximum point of the graph  $ \left(-3; -2\right)$.
\end{enumerate}

\end{document}

 

 

Download One_way.mw

(Shame there is no example in the corresponding help page about this way to use dualaxisplot)

restart

with(Optimization):

NULL

_local(Pi);

`&Pi;_12` := (0.1455251030e-2*Ce+.5352049476)*(0.369876310e-1+`-`(0.3638127575e-2*Ce))+.8*(-.1671790360+1.121361872*Ce)*(0.1849381518e-1+`-`(0.1819063782e-2*Ce))+`-`(Ce*(0.1849381518e-1+`-`(0.1819063782e-2*Ce)));

(0.1455251030e-2*Ce+.5352049476)*(0.369876310e-1-0.3638127575e-2*Ce)+(-.1337432288+.8970894976*Ce)*(0.1849381518e-1-0.1819063782e-2*Ce)-Ce*(0.1849381518e-1-0.1819063782e-2*Ce)

(1)

`&Pi;_22` := Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(0.1455251030e-2, Ce), .5356096675), Student:-VectorCalculus:-`+`(0.355258312e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.3638127575e-2, Ce)))), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(.8, Student:-VectorCalculus:-`+`(-.1184158360, Student:-VectorCalculus:-`*`(1.121361872, Ce))), Student:-VectorCalculus:-`+`(0.1776291535e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce))))), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(Ce, Student:-VectorCalculus:-`+`(0.1776291535e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce))))));

(0.1455251030e-2*Ce+.5356096675)*(0.355258312e-1-0.3638127575e-2*Ce)+(-0.9473266880e-1+.8970894976*Ce)*(0.1776291535e-1-0.1819063782e-2*Ce)-Ce*(0.1776291535e-1-0.1819063782e-2*Ce)

(2)

`&Pi;_32` := Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(0.1455251030e-2, Ce), .5356038465), Student:-VectorCalculus:-`+`(0.355403838e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.3638127575e-2, Ce)))), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(.8, Student:-VectorCalculus:-`+`(-.1179012835, Student:-VectorCalculus:-`*`(1.121361872, Ce))), Student:-VectorCalculus:-`+`(0.1777019161e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce))))), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(Ce, Student:-VectorCalculus:-`+`(0.1777019161e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce))))));

(0.1455251030e-2*Ce+.5356038465)*(0.355403838e-1-0.3638127575e-2*Ce)+(-0.9432102680e-1+.8970894976*Ce)*(0.1777019161e-1-0.1819063782e-2*Ce)-Ce*(0.1777019161e-1-0.1819063782e-2*Ce)

(3)

S12 := plot(`&Pi;_12`, Ce = 0 .. 0.9e-1, color = [red], labels = ["Ce", "Manufacturer Profit"], labeldirections = ["horizontal", "vertical"], legend = [`#msubsup(mi("Pi"),mi("m"),mn("W"));`]):

`&Pi;_1` := Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.60726413e-1, Ce)), .6173851967), Student:-VectorCalculus:-`+`(0.1849381518e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce)))), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.2500000000e-1, Student:-VectorCalculus:-`+`(0.1849381518e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce)))^2)));

(-0.60726413e-1*Ce+.6173851967)*(0.1849381518e-1-0.1819063782e-2*Ce)-0.2500000000e-1*(0.1849381518e-1-0.1819063782e-2*Ce)^2

(4)

`&Pi;_2` := Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.60726413e-1, Ce)), .5929853242), Student:-VectorCalculus:-`+`(0.1776291535e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce)))), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.2500000000e-1, Student:-VectorCalculus:-`+`(0.1776291535e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce)))^2)));

(-0.60726413e-1*Ce+.5929853242)*(0.1776291535e-1-0.1819063782e-2*Ce)-0.2500000000e-1*(0.1776291535e-1-0.1819063782e-2*Ce)^2

(5)

`&Pi;_3` := Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.60726413e-1, Ce)), .5932282299), Student:-VectorCalculus:-`+`(0.1777019161e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce)))), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.2500000000e-1, Student:-VectorCalculus:-`+`(0.1777019161e-1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(0.1819063782e-2, Ce)))^2)));

(-0.60726413e-1*Ce+.5932282299)*(0.1777019161e-1-0.1819063782e-2*Ce)-0.2500000000e-1*(0.1777019161e-1-0.1819063782e-2*Ce)^2

(6)

S1 := plot(`&Pi;_1`, Ce = 0 .. 0.9e-1, color = [yellow], labels = ["Ce", "Retailer profit"], labeldirections = ["horizontal", "vertical"], legend = [`#msubsup(mi("Pi"),mi("r"),mn("W"));`]):

dualaxisplot(
  display(S1, S2, S3)
  ,
  display(S12, S22, S32)
)

 
 

``

Download All_plots_Combined_sand15.mw


One way is to give rho a numeric value BEFORE solving the ode system, the other one (which I use in the attached file) is to use the dsolve/numeric option 'parameters'.
 

Before doing this I advice you to rewrite the system you want to solve, which is actually a DAE (Differential Algebraic System), as an ODE system (Maple can solve DAE systems but I can't see any reasons for doing so here unless adding unnecessary complexity).
 

Once all this done dsolve is then capable to compute a solution. 
Nevertheless you will see in the attached file that an arbitrary choice of the rho value (I took rho = 1), leads to a singularity at time 0.57: because I have no idea of the values rho might have

(rho is ought to represent the density of Mars atmosphere, something about 20g/m3, but I don't know what are the units you use) 

it's hard to say more about this dicontinuity (real or simple artefact due to unrealistic rho value?).
Nevertheless a quick analysis is provided at the end of this answer.


SimpleMarsEntryAndAeroBrakingModel_sand15.mw



Note that other choices enable computing the solution for arbitrary much larger times, for instance

ans(parameters=[0.1])
                          [rho = 0.1]

display(
  Matrix(2, 3, [seq(odeplot(ans, [t, u], t=0..100, title=typeset(u)), u in unknowns)])
)


Nevertheless I suppose you want to end the simulation when the probe hits the ground, don't you?  
If it is so, let landing_t the time when the probe reaches Mars surface. Given its average radius is 3389.5 Km, landing_t verifies  r(landing_t) = 3389.5. The easiest way to stop the simulation when this latter condition is fullfiled uses the dsolve/numeric 'events' option:

landing_r := 3389.5; # kilometers

ans := dsolve(
         ODESYS
         , numeric
         , method = rkf45
         , maxfun = -1
         , parameters = params
         , events = [[r(t) = landing_r, halt]]
       ):

# Specialize the solution for some given value of rho, here rho=0.1

ans(parameters=[0.1]);
                  [rho = .1]

# initialize the solution procedure for some time a priori larger than
# the expected landing time:

ans(100):

# Catch the value of landing_t (meaning the value of t which fires the event)

landing_t := ans(eventfired=[1])[]
Warning, cannot evaluate the solution further right of 264.44373, event #1 triggered a halt
                   landing_t := 11.9098649021394

Next do the plots from 0 to landing_t.
For more details download the worksheets at the end of this answer.


By the way: shouldn't  g be equal to the gravitational acceleration on Mars (about 3.73 m/s2 ... you seem to get a value of about 12.64 m/s2)?


Last but not least: the worksheet below provides a short analysis of the emergence of a singularity. From this analysis it is clear that the right hand side of the d𝜙(t)/dt equation takes an infinite value for some finite time and that comes from (cos(𝛾(t)) = 0 at this same time (cos(𝛾(t)) is present at the denominator of d𝜙(t)/dt equation).
This means the flight path angle 𝛾(t) is equal to -𝜋/2 at finite time (vertical drop)... which should not be possible when there is friction.
My advice: check your equations, data and units.

singularity_analysis_sand15.mw   see also   capturing_cos(gamma(t))=0.mw

I guess someone else could interpret your question differently and provide another answer.
Whatever here is mine: My_interpretation.mw (file can't be uploaded)

-0.06888275721

You write "I want to choose A to obtain the smallest absolute value of Em, preferably ~ -0.00005".
I suppose you want to say "I want to choose A to obtain the smallest absolute value of Em, preferably ~ +0.00005", don't you?

Whatever, Em is strctly negative for A > 0 and its limit when A goes to 0 from the right is -0.06888275721, which means that your requirement cannot be met.

Note that for A = 0 we have  E(𝜐) = C𝜐2 + -0.06888275721 which immediatly gives the value of C... but the fitted model is unacceptable has shown in the attached file.

At the very end I'm leaning to consider your problem is not correctly posed and I suggest you to consider carefully what you want to do.
ML_sand15.mw

for i2 varying from 0 to 1

doen't nmean anything at all as the 
Error, controlling variable of for loop must be a name or sequence of 2 names
says: between for and from you must have only one name (here you have i2 and varying).

Given the past worksheets you posted I don't even understand how you can have written  (sorry if I feel that rude) such a stupid  thing?
A few correct syntaxes are

for i2 from 0 to 1 do
...
end do:

for i2 from 0 to 1 by 1/3 do
...
end do:

# etc

Note that the first syntax seems quite stupid to me in your context:

# with K2 = 0.1968052257

for i2 from 0 to 1 do
  if i2 > K2 then 
    do_something
  else
    do_something_else
  endif:
end do:

because the counter (here i2) being an integer unless "by some_value" is specified, it takes only the values i1=0 and i2=1. So a simpler operation is 

Do_this := i2 -> piecewise(i2 > K2, do_something, do_something_else)

Nothing of what you try to achieve is clear to me.
Moreover, if you are not capable to manage correctly the 2D input document mode, just as I can't neither, use the 1D input worksheet mode (your file contains a lot of breaks which generate errors (yout for anf if structures do not end correctly).

Whatever... look to the attached file to see how to write something error free A_no_error_worksheet_sand15.mw and try to use it contents to formulate correctly your problem (which I repeat I do not understand).

(done with Maple 2015 but should work the same with Maple 2018)
One_way_sand15.mw   (read carefully the last comment in thiw worksheet)


Proceed the same way for the 3D plots by replacing p1_final by p1 in C11 and p2_final by p2 in C12.

Note: If you do some browsing on this same site you should be able to find several questions about the same subject.
@acer already gave a lot of answers too [moderator: eg. here, here, here]
[moderator: If you need to export the 3D plot with colorbar in such an old Maple version then see also here.]

[moderator: colorbars received direct support for 3D plotting commands in Maple 2024.]

restart;
n := 0:
L := []:

for a from 3 to 100 do
    for b from 3 to a do
        c2 := a^2 - a*b + b^2;
        c := isqrt(c2);
        if c^2 = c2 then
            if c < a + b and a < b + c and b < c + a then
                if igcd(a, b, c) = 1 then
                    x2 := (-a^2 + b^2 + c^2)/2;
                    y2 := (a^2 - b^2 + c^2)/2;
                    z2 := (a^2 + b^2 - c^2)/2;
                    if 0 < x2 and 0 < y2 and 0 < z2 then
                        # One way
                        S := [sqrt(x2), sqrt(y2), sqrt(z2)];
                        S := S[sort(evalf(S), output=permutation)];
                        x := S[1]; 
                        y := S[2]; 
                        z := S[3];
                        n := n + 1;
                        L := [op(L), [x, y, z, sqrt(x^2 + y^2), sqrt(y^2 + z^2), sqrt(x^2 + z^2)]];
                    end if;
                end if;
            end if;
        end if;
    end do;
end do;

n;
L;


Why was sort([sqrt(x2), sqrt(y2), sqrt(z2)]) ineffective?
Look at this

S0 := [6*sqrt(110), 2*sqrt(610), 3*sqrt(649)];
sort(S0, `>`)
Error, invalid input: a numeric list is expected for sort method ``>``

# To understand this "failure" look at this 
if S0[1] > S0[2] then "yes" else "no" end if;
Error, cannot determine if this expression is true or false: 2*610^(1/2) < 6*110^(1/2)

So sort, which vasically uses an if structure, simply doesn't know how to compare these two non rational numbers.

Note that is can do it:

is(S0[1] > S0[2]);
                             true
is(S0[1] < S0[2]);
                             false

 

(strangely it takes a long time to be processed)

restart

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)

expr := sqrt((-alpha^2*x^2 + R^2 + x^2)/(-alpha^2*x^2 + R^2))/sqrt(R^4/((-alpha^2*x^2 + R^2 + x^2)^2*(-alpha^2*x^2 + R^2))):

subexpr := indets(expr, `+`);
CodeTools:-Usage( simplify(expr) assuming op(subexpr >=~ 0), R >= 0 )

{-alpha^2*x^2+R^2, -alpha^2*x^2+R^2+x^2}

 

memory used=0.59GiB, alloc change=429.34MiB, cpu time=8.33s, real time=8.16s, gc time=356.09ms

 

(-alpha^2*x^2+R^2+x^2)^(3/2)/R^2

(2)
 

 

Download simplify_radical_sand15.mw

From the code below you should be able to define any binary operator you want.

restart

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)

Isom := `&cong;`:
Isom(A, B);

`&cong;`(A, B)

(2)

IsContained := `&#x2286;`:
IsContained(A, B)

`&#x2286;`(A, B)

(3)

IsNotContained := `&#x2288;`:
IsNotContained(A, B)

`&#x2288;`(A, B)

(4)

DoesNotContain := `&#x2289;`:
DoesNotContain(A, B)

`&#x2289;`(A, B)

(5)

# For details look to the answers to this QUESTION

`print/Fs` := proc(x,y)
   uses Typesetting;
   mrow(
     Typeset(x),
     mo("&InvisibleTimes;"),
     mover(mo("&rarr;"),mo("s")),
     mo("&InvisibleTimes;"),
     Typeset(y)
   );
end proc:

Fs(A, B)

Fs(A, B)

(6)

# For any other hexadecimal code see HERE , for instance here are different arrows:

`#mo("&mapsto;")`;

`#mo("&#x21a3;")`;

`#mo("&#x21a0;")`;

`#mo("&mapsto;")`

 

`#mo("&#x21a3;")`

 

`#mo("&#x21a0;")`

(7)
 

 

Download Special_Operators.mw

AA := value( eval(A, {Omega = (t -> 1), chi = (t -> 1), g = (t -> 1), i = 1, p = (t -> 1), i = 1}) );
has(AA, {int, Int})
                             false

h-pde-M_sand15.mw

t-plot_sand15.mw

Some functions, like 'sin' for instance, leads to an unevaluated integral.

Even using evalf/Int doesn't help for the the numeric values are Float(undefined).

restart

ode := x^2 = sum(x*(diff(y(x), [`$`(x, i)]))/factorial(i), i = 0 .. 3);

x^2 = x*y(x)+x*(diff(y(x), x))+(1/2)*x*(diff(diff(y(x), x), x))+(1/6)*x*(diff(diff(diff(y(x), x), x), x))

(1)
 

 

ics := y(0) = 0, (D(y))(0) = 0, ((D@@2)(y))(0) = 0;

y(0) = 0, (D(y))(0) = 0, ((D@@2)(y))(0) = 0

(2)

sol := dsolve({ics, ode});

y(x) = x-1+(1/6)*(4*(2^(1/2)+1)^(2/3)-2*2^(1/2)*(2^(1/2)+1)^(2/3)+2^(1/2)*(2^(1/2)+1)^(1/3)-(2^(1/2)+1)^(1/3)+1)*2^(1/2)*exp((2^(1/2)*(2^(1/2)+1)^(2/3)-(2^(1/2)+1)^(2/3)-(2^(1/2)+1)^(1/3)-1)*x)/((2^(1/2)+1)^(2/3)*(2*2^(1/2)-2))+(1/6)*(8*(2^(1/2)+1)^(2/3)-4*2^(1/2)*(2^(1/2)+1)^(2/3)-2^(1/2)*(2^(1/2)+1)^(1/3)+(2^(1/2)+1)^(1/3)-1)*2^(1/2)*exp(-(1/2)*(2^(1/2)*(2^(1/2)+1)^(2/3)-(2^(1/2)+1)^(2/3)-(2^(1/2)+1)^(1/3)+2)*x)*cos((1/2)*3^(1/2)*(2^(1/2)+1)^(1/3)*(2^(1/2)*(2^(1/2)+1)^(1/3)-(2^(1/2)+1)^(1/3)+1)*x)/((2^(1/2)+1)^(2/3)*(2*2^(1/2)-2))-(1/6)*(2^(1/2)*(2^(1/2)+1)^(1/3)-(2^(1/2)+1)^(1/3)-1)*3^(1/2)*2^(1/2)*exp(-(1/2)*(2^(1/2)*(2^(1/2)+1)^(2/3)-(2^(1/2)+1)^(2/3)-(2^(1/2)+1)^(1/3)+2)*x)*sin((1/2)*3^(1/2)*(2^(1/2)+1)^(1/3)*(2^(1/2)*(2^(1/2)+1)^(1/3)-(2^(1/2)+1)^(1/3)+1)*x)/((2^(1/2)+1)^(2/3)*(2*2^(1/2)-2))

(3)

plot([rhs(sol), lhs(ode)], x = 0 .. 1, color = [red, blue], legend = `~`[typeset]([y(x), lhs(ode)]))

 

plot([eval(rhs(ode), sol), lhs(ode)], x = 0 .. 1, color = [red, blue], style = [line, point], numpoints = 30, legend = `~`[typeset]([('rhs')('ode'), lhs(ode)]))

 

``

Download DGL_test_sand15.mw

1 2 3 4 5 6 7 Page 1 of 8