1

I'm trying to plot a graph of the function Fh_1, but it looks like ezunits is causing problems. I can get results from it, when I enter x-values. But plotting isn't working, not even with dimensionally(). How can I get it to work?

(%i2)   kill(all); load(ezunits); g2r(x):= x*%pi/180;
(%o0)   done

(%o1)   "C:/maxima-5.44.0/share/maxima/5.44.0/share/ezunits/ezunits.mac"

(%o2)   g2r(x):=(x*%pi)/180
  1 variables
(%i3)   rho: atan(rat(0.35));
rat: replaced 0.35 by 7/20 = 0.35

(rho)   atan(7/20)
(%i4)   L_FPzuLH: 110`mm;
(L_FPzuLH)  110 ` mm
(%i5)   L_Backe: 33`mm;
(L_Backe)   33 ` mm
(%i6)   L_HebelLinks: 81`mm;
(L_HebelLinks)  81 ` mm
  2 function
(%i7)   Fh_1(D_Platte):= L_HebelLinks*sin(g2r(90)-(g2r(90)-(acos((L_FPzuLH-D_Platte-L_Backe)/L_HebelLinks)))-rho);
(%o7)   Fh_1(D_Platte):=L_HebelLinks*
sin(g2r(90)-(g2r(90)-acos((L_FPzuLH-D_Platte-L_Backe)/L_HebelLinks))-rho)
  3 this works
(%i9)   Fh_1(31`mm); float(%);
(%o8)   81*sin(acos(46/81)-atan(7/20)) ` mm

(%o9)   47.73170350716926 ` mm
  4 but not this
(%i10)  dimensionally(plot2d(Fh_1(x), [x,5`mm,55`mm]));
plotting: range must be of the form [variable, min, max]; found: 

 [x,5*g1498,55*g1498]

 -- an error. To debug this try: debugmode(true);

Paste for Maxima:

/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/
/* [ Created with wxMaxima version 21.02.0 ] */
/* [wxMaxima: input   start ] */
kill(all); load(ezunits); g2r(x):= x*%pi/180;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: section start ]
variables
   [wxMaxima: section end   ] */


/* [wxMaxima: input   start ] */
rho: atan(rat(0.35));
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
L_FPzuLH: 110`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
L_Backe: 33`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: input   start ] */
L_HebelLinks: 81`mm;
/* [wxMaxima: input   end   ] */


/* [wxMaxima: section start ]
function
   [wxMaxima: section end   ] */


/* [wxMaxima: input   start ] */
Fh_1(D_Platte):= L_HebelLinks*sin(g2r(90)-(g2r(90)-(acos((L_FPzuLH-D_Platte-L_Backe)/L_HebelLinks)))-rho);
/* [wxMaxima: input   end   ] */


/* [wxMaxima: section start ]
this works
   [wxMaxima: section end   ] */


/* [wxMaxima: input   start ] */
Fh_1(31`mm); float(%);
/* [wxMaxima: input   end   ] */


/* [wxMaxima: section start ]
but not this
   [wxMaxima: section end   ] */


/* [wxMaxima: input   start ] */
dimensionally(plot2d(Fh_1(x), [x,5`mm,55`mm]));
/* [wxMaxima: input   end   ] */



/* Old versions of Maxima abort on loading files that end in a comment. */
"Created with wxMaxima 21.02.0"$
Dux
  • 101
  • 4
  • `plot2d` and other plotting functions don't recognize units, and `dimensionally` doesn't have a useful effect for them, so the values supplied to a plotting function has to be just plain numbers. Call the function `qty` to get the quantity as a number, e.g. ``qty(5 ` mm)`` yields `5`. If you are using different units (with same dimensions), you'll need to convert to the same unit via double backtick, e.g. given `x` is the list ``[512 ` mm, 2 ` m, 3 ` cm]`` then you would say ```qty(x `` cm)``` to get `[256/5, 200, 3]`. – Robert Dodier May 30 '21 at 05:43

1 Answers1

0

So as I was saying in the comment above, call qty to get the quantity of a dimensional expression. Note that I am writing the argument for Fh_1 as x ` mm, where x is the nondimensional variable over which we are plotting.

plot2d (qty (Fh_1 (x ` mm)), [x, 5, 55]);

That works when I try it with Maxima 5.44. You might be interested to see

(%i11) qty(Fh_1(x ` mm));
                                    77 - x         7
(%o11)                  81 sin(acos(------) - atan(--))
                                      81           20

When I tried plot2d with the current (approximately 5.45) version, I ran into a stack overflow (having something to do with trying to determine if some expression is nondimensional), which I'm investigating now.

Here is a work around for the bug, which succeeds when I tried it with the current, near-5.45 version. I generate a list of points and then plot the points.

(%i11) qty(Fh_1(x ` mm));
                                    77 - x         7
(%o11)                  81 sin(acos(------) - atan(--))
                                      81           20
(%i12) ev(makelist([y,ev(%,x = y)],y,5,55),numer);
(%o12) [[5, 11.23941870984706], [6, 13.34349300482042], 
[7, 15.34276468157134], [8, 17.25033934972067], [9, 19.07666307706286], 
[10, 20.83022404590423], [11, 22.51803233322337], [12, 24.14595804280109], 
[13, 25.71897581938176], [14, 27.24134562928132], [15, 28.71674902665171], 
[16, 30.14839362529976], [17, 31.53909440876992], [18, 32.89133786911122], 
[19, 34.20733321424233], [20, 35.48905369852528], [21, 36.73827031267255], 
[22, 37.95657949382723], [23, 39.14542610575446], [24, 40.30612264125835], 
[25, 41.43986538015634], [26, 42.54774807342751], [27, 43.63077360174984], 
[28, 44.68986396358886], [29, 45.72586887656475], [30, 46.73957322048246], 
[31, 47.73170350716926], [32, 48.70293352820919], [33, 49.65388930464281], 
[34, 50.58515344111066], [35, 51.49726896955291], [36, 52.39074275352331], 
[37, 53.26604851273431], [38, 54.12362951808341], [39, 54.96390099970309], 
[40, 55.7872523042014], [41, 56.5940488319625], [42, 57.38463378095388], 
[43, 58.15932971977946], [44, 58.91844000959603], [45, 59.6622500918724], 
[46, 60.39102865673311], [47, 61.1050287047217], [48, 61.80448851319165], 
[49, 62.48963251713631], [50, 63.16067211306913], [51, 63.81780639352923], 
[52, 64.46122281889194], [53, 65.09109783238475], [54, 65.70759742353295], 
[55, 66.31087764466791]]
(%i13) plot2d([discrete,%]);
Robert Dodier
  • 16,905
  • 2
  • 31
  • 48