WD0HHU

50 Reputation

4 Badges

5 years, 113 days

MaplePrimes Activity


These are replies submitted by WD0HHU

@sand15 Thank you for your insights and to @acer's.  I do a lot of orbital mechanics problems and using the Explore function is quite useful in visualizing orbits.

@C_R Try this out! I tried to upload it with the green arrow but for some reason it would not go!!

restart;
with(plots);
pov := proc(p, a, b, c) plots:-display(p, orientation = [a, b, c]); end proc;
YECI := arrow(<0, 9000, 0>, shape = arrow, color = "Purple", thickness = 5);
ZECI := arrow(<0, 0, 9000>, shape = arrow, color = red, thickness = 5);
XECI := arrow(<9000, 0, 0>, shape = arrow, color = "Coral", thickness = 5);
to3d := plottools:-transform((x, y) -> [x, y, 0]);
EQ := plottools:-circle([0, 0], 6378, color = red, transparency = 0., thickness = 3);
EQUATOR := to3d(EQ);
alias(pt_arrow = plottools[arrow]);
alias(pl_arrow = plots[arrow]);
T4310 := textplot3d([9000, 0, 0, " +X"], 'align' = {'above', 'right'}, font = [Helvetica, bold, 18], color = "Coral");
T4320 := textplot3d([0, 9000, 0, " +Y"], 'align' = {'below', 'right'}, font = [Helvetica, bold, 18], color = "Purple");
T4330 := textplot3d([0, 0, 9000, " +Z"], 'align' = {'above', 'right'}, font = [Helvetica, bold, 18], color = red);

PP := display(plot3d(6378, x = -2*Pi .. 0, y = -Pi .. 0, coords = spherical, style = surface, axes = none, scaling = constrained, image = "http://www.vendian.org/mncharity/dir3/planet_globes/TemporaryURL/earth0_src_thumb.jpg", size = [2400, 1200], grid = [30, 30]), EQUATOR, XECI, YECI, ZECI, T4310, T4320, T4330);

Explore(pov(PP, theta, phi, psi), parameters = ([theta, phi, psi] =~ -180 .. 180), placement = right, initialvalues = [theta = -2, phi = 68, psi = 7]);

@sand15 I took what you did and applied it to a globe of the Earth.

Dear @acer, I went back and took a hard look at the "subsindents" Help page and I know finally have started to understand what that Maple command is supposed to do! You should have them include your simple but illustrative example to show how powerful this command is!!  Also, I am starting to understand the "evalindets" is about.

Thank you! 

Hello @acer! I took your suggestion and applied the "simplify" command as follows:

simplify(subs(convert(sols[25], list), lhs(sys[7]))) 

and I got the expected "0" result!!

Thank you again.  I always learn things from your responses, probably more than you know!!

Hello @acer again! I was looking at the solutions that came from "sols" and I did the following:  

subs(convert(sols[25], list), lhs(sys[7]))

to substitute a solution -- in this case sols[25], into the sys[7] -- and see if it equaled zero.

I noticed in this case it was non-zero.  It seems like it forgot but it should have included b__1=0 as part of the solution in sols[25].  Am I missing something here?  

Thank you.

Dear @acer, I know your are one of the many Maple "Dads" that know everything! I am sorry but I am baffled by what you did in the 

sols := subsindets([solve(sys,explicit,allsolutions)],`=`,eq->ifelse(eq,NULL,eq));

line of Maple code.  I am especially intrigued by the subsindets command? Is this a standard way to solve this type of system of linear equations with Maple?

Thank you.


 

> 

restart

> 

target := r -> exp(sin(r))

proc (r) options operator, arrow; exp(sin(r)) end proc

(1)
> 

X := < [seq(0..2.0*Pi, Pi/100.0)] >:
Y := (exp@sin)~(X):

model  := r -> a*sin(b*r+c) + d;
Y__est := model~(X):

fit := unapply(Statistics:-NonlinearFit(model(r), X, Y, r), r)

proc (r) options operator, arrow; a*sin(b*r+c)+d end proc

 

proc (r) options operator, arrow; HFloat(1.1349036230282985)*sin(HFloat(1.0079063136739561)*r-HFloat(0.025858569285319585))+HFloat(1.264756992961412) end proc

(2)
> 

plot(
  [exp(sin(r)), fit(r)]
  , r=0..2*Pi
  , color=[blue, red]
  , legend=[typeset(target(r)), typeset(evalf[4](fit(r)))]
  , title = typeset(RMSE = (2*Pi/numelems(X)) * evalf[4](add((fit-target)~(X)^~2)))
)

 
> 

H1 := expand((target-model)(r)^2)

(exp(sin(r)))^2-2*exp(sin(r))*a*sin(b*r)*cos(c)-2*exp(sin(r))*a*cos(b*r)*sin(c)-2*exp(sin(r))*d+a^2*sin(b*r)^2*cos(c)^2+2*a^2*sin(b*r)*cos(c)*cos(b*r)*sin(c)+2*a*sin(b*r)*cos(c)*d+a^2*cos(b*r)^2*sin(c)^2+2*a*cos(b*r)*sin(c)*d+d^2

(3)


Great simplification: given the fit we got above we use the assumption  b = 1

> 

H2 := simplify(eval(H1, b=1));

(a*cos(c)*sin(r)+a*cos(r)*sin(c)+d-exp(sin(r)))^2

(4)
> 

H3 := map(int, H2, r=0..2*Pi)

(int(a*cos(c)*sin(r)+a*cos(r)*sin(c)+d-exp(sin(r)), r = 0 .. 2*Pi))^(4*Pi)

(5)
> 

uH3, kH3 := selectremove(has, [op(H3)], int);

[int(a*cos(c)*sin(r)+a*cos(r)*sin(c)+d-exp(sin(r)), r = 0 .. 2*Pi)], [4*Pi]

(6)
> 

uH4 := IntegrationTools:-Expand(uH3[1])

2*d*Pi-2*Pi*BesselI(0, 1)

(7)
> 

uH5 := evalf(uH4)

6.283185308*d-7.954926524

(8)
> 

M1 := eval(add([uH5, kH3[]]), b=1)

6.283185308*d+4.611444096

(9)
> 

dM1 := diff~(dM1, [a, c, d]);
Sol := solve(%, [a, c, d]);

 print~(Sol):
print~([ seq( [evalf(eval(M1, sol)), sol], sol in Sol) ]):

[0, 0, 0]

 

[[a = a, c = c, d = d]]

 

[a = a, c = c, d = d]

 

[6.283185308*d+4.611444096, [a = a, c = c, d = d]]

(10)
> 

dM2 := Matrix(3, 3, (i, j) -> diff(M1, [a, c, d][i], [a, c, d][j]));

dM2red := dM2[1..2, 1..2];

for sol in Sol do
  eig := LinearAlgebra:-Eigenvalues(eval(dM2red, sol)):
  if evalf(mul(eig)) < 0 then
    printf("\n%a is a saddle point\n", sol)
  elif evalf(eig[1]) > 0 then
    printf("\n%a is a minimum\n", sol)
  else
    printf("\n%a is a maximum\n", sol)  
  end if:
end do:

Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0})

 

Matrix(%id = 36893490502983952972)

 


[a = a, c = c, d = d] is a maximum

 
> 

use plots in
  display(
    plot3d(evalf(eval(M1, Sol[1][3])), a=-1.5..1.5, c=-1..4, style=wireframe, color="LightBlue", lightmodel=light3)
    ,
    pointplot3d(eval([a, c, M1], Sol[2]), symbol=solidcircle, symbolsize=40, color=red)
    ,
    pointplot3d(eval([a, c, M1], Sol[3]), symbol=solidcircle, symbolsize=40, color=red)
    ,
    pointplot3d(eval([a, c, M1], Sol[1]), symbol=solidcircle, symbolsize=40, color=green)
  )
end use;

use plots in
  display(
    contourplot(evalf(eval(M1, Sol[1][3])), a=-1.5..1.5, c=-1..4, color="LightBlue", contours=20)
    ,
    pointplot(eval([a, c], Sol[2]), symbol=solidcircle, symbolsize=20, color=red)
    ,
    pointplot(eval([a, c], Sol[3]), symbol=solidcircle, symbolsize=20, color=red)
    ,
    pointplot(eval([a, c], Sol[1]), symbol=solidcircle, symbolsize=20, color=green)
  )
end use;

Warning, expecting only range variables [a, c] in expression 6.283185308*d+4.611444096 to be plotted but found name d

 

Error, invalid subscript selector

 

Error, (in plot/iplot2d) cannot mix numeric and boolean arguments to min

 
> 

with(plots)

> 

Question:Calculating a "distance integral"

> 

plot3d(evalf(eval(M1, Sol[1][3])), a = -1.5 .. 1.5, c = -1 .. 4, style = wireframe, color = "LightBlue", lightmodel = light3)

Warning, expecting only range variables [a, c] in expression 6.283185308*d+4.611444096 to be plotted but found name d

 

 
> 

Sol

[[a = a, c = c, d = d]]

(11)
> 

NULL


 

Download NonlinearFit_addon.mw

@sand15 

@WD0HHU Here is the file again!

Dear @sand15.  That looked like it was going to work but failed.  I've uploaded my version with I think is your suggested fix.  But there is something different with Maple 2026 that is causing an issue.

Thank you. 

Dear @sand15.  I tried to run your "NonlinearFit_Addon.mw" in Maple 2026 and it appears that the solve fails because it returns [].  Could this because you are using an earlier version of Maple.  

Thank you. 

@dharr Depending on the resolution of your laptop or desktop monitor, you can adjust the size of the plots with view command to fill out the plots.  This is a great illustration of the derivative of a function.  I wished I had something like this 54 years ago when I was taking freshman calculus at Purdue University.
 

> 

restart; with(plots); s := proc (t) options operator, arrow; 2*t^4-30*t^3+135*t^2-120*t-10 end proc; diff(s(t), t); v := proc (t) options operator, arrow; diff(s(t), t) end proc; p1 := plot(s(t), t = 0 .. 8, 'gridlines', 'color' = "red", 'title' = "Plot of s(t)", background = "Azure", size = [1700, 800], axesfont = [Helvetica, bold, 14], view = [default, -100 .. 500], titlefont = [Helvetica, bold, 18], labelfont = [Helvetica, bold, 24], axis[1] = [location = low], thickness = 4, annotation = typeset("t =", ('xcoordinate')(digits = 6), " ", "  s(t)= ", ('ycoordinate')(digits = 6), " "), labels = [t, "s(t)"], labeldirections = [Horizontal, Vertical]); p2 := plot(v(t), t = 0 .. 8, 'gridlines', 'color' = "blue", 'title' = "Plot of v(t)", background = "Azure", size = [1700, 800], axesfont = [Helvetica, bold, 14], view = [default, -200 .. 300], titlefont = [Helvetica, bold, 18], labelfont = [Helvetica, bold, 24], axis[1] = [location = low], thickness = 5, annotation = typeset("t =", ('xcoordinate')(digits = 6), " ", "  v(t)= ", ('ycoordinate')(digits = 6), " "), labels = [t, "v(t)"], labeldirections = [Horizontal, Vertical]); plots:-display(Array([p1, p2]))

proc (t) options operator, arrow; 2*t^4-30*t^3+135*t^2-120*t-10 end proc

 

8*t^3-90*t^2+270*t-120

 

proc (t) options operator, arrow; diff(s(t), t) end proc

 

 

 

 

 

 

 
> 

DocumentTools:-Tabulate([p1, p2], width = 50)


 

Download SideBySidePlotting.mw

Hello @acer! My version of Maple is `Maple 2025.2, X86 64 WINDOWS, Nov 11 2025, Build ID 1971053` and I tried to upload the file to you but somehow it did not happen.  I notice that you are using a Linux version of Maple 2025.2.  This is interestesing and a little disturbing that there are differences in the results based on whether one is using Windows versus Linux.  

Hello @acer! I tried your worksheet and I didn't get the zero on the last simplify statement.  I'll upload my worksheet.

@acer I agree with the user `nm` that the Explore command could definitely be improved.  This should be considered as a major improvement in the next upgrade to Maple.  You can't set the fonts in the sliders, for example.  Also, you can't set the font of the tick marks.  The font size is hard to read.  You can't set the font size of the value of the slider on the right.  This is not the best example of an important command like Explore.  I wish it would get improved at some point in the near future.

1 2 3 4 5 Page 1 of 5