Search code examples
maximawxmaxima

wxmaxima transforming functions


I'm having problems with the 4th part of the exercise, I cannot get it to work in maxima:

firstly transform s_y(t) to t=... that should be t=sqrt(2*s_y/a_y)

then insert that into s_x(t), to get a new s_x2(s_y) function, where you don't insert a time but a vertical length (s_y), but still get a horizontal length.

the result should be s_x2(s_y)=a_x*s_y/a_y

How does that work in maxima?

What I tried: https://filebin.net/9hhdfkklqrn5fznt/Rakete.wxmx?t=tdbuwxj1

Aufgabe "Rakete" Dynamik 1
 -->    showtime:false; kill(all); linel: 65; load(ezunits);
(showtime)  false

(%o0)   done

(linel) 65

(%o2)   "C:/maxima-5.43.2/share/maxima/5.43.2/share/ezunits/ezunits.mac"
  1 Stellen Sie die Bewegungsgleichung für die Bewegung in x- un din y-Richtung auf.
a's über den Winkel bestimmen bestimmen
 -->    a: 15`m/s^2; β: 70*%pi/180; a_x: a*cos(β); a_y: a*sin(β);
(a) 15 ` m/s^2
(β) (7*%pi)/18
(a_x)   15*cos((7*%pi)/18) ` m/s^2
(a_y)   15*sin((7*%pi)/18) ` m/s^2
damit nun die funktionen für v(t) aufstellen
 -->    v_x(t):=a_x*t+0; v_y(t):=a_y*t+0;
(%o7)   v_x(t):=a_x*t+0

(%o8)   v_y(t):=a_y*t+0
damit nun die funktionen für s(t) aufstellen
 -->    s_x(t):=a_x/2*t^2+0+0; s_y(t):=a_y/2*t^2+0+0;
(%o56)  s_x(t):=a_x/2*t^2+0+0

(%o57)  s_y(t):=a_y/2*t^2+0+0
  2 Nach welcher Zeit t hat die Rakete eine Höhe von s_y=10km erreicht?
 -->    t10km: dimensionally(solve(s_y(t)=10000`m, t))$ t10km: rhs(t10km[2]); float(%);
(t10km) (2*10^(3/2))/(sqrt(3)*sqrt(sin((7*%pi)/18))) ` s

(%o48)  37.66833811883066 ` s
  3 Welche Strecke s_x parallel zur Erdoberfläche hat die Rakete nach dieser Zeit zurückgelegt?
 -->    Strecke_parallel: s_x(t10km); float(%);
(Strecke_parallel)  (10000*cos((7*%pi)/18))/sin((7*%pi)/18) ` m

(%o18)  3639.702342662025 ` m
einfacher
 -->    s_x10km: dimensionally(solve(tan(β)=(10000`m)/x,x))$ s_x10km: assoc(x, s_x10km); float(%);
(s_x10km)   10000/tan((7*%pi)/18) ` m

(%o51)  3639.702342662024 ` m
  4 Verallgemeinerung s_x(s_y)= ?
 -->    T: dimensionally(solve(s_y(x)=s_yx,x))$ T: rhs(T[2]); float(%);
(T) (sqrt(2)*sqrt(s_yx))/(sqrt(15)*sqrt(sin((7*%pi)/18))) ` s/sqrt(m)
(%o88)  0.3766833811883064*sqrt(s_yx) ` s/sqrt(m)
 -->    s_x2(s_yx):= s_x(T);
(%o92)  s_x2(s_yx):=s_x(T)
 -->    s_x2(10000`m); float(%);
(%o93)  (cos((7*%pi)/18)*s_yx)/sin((7*%pi)/18)
(%o94)  0.3639702342662025*s_yx
 -->    

Solution

  • I'm guessing about what you need to do here, but let me suggest that you change the definition of the function s_x2 to s_x2(s_yx):= ''(s_x(T)) instead of s_x2(s_yx):= s_x(T). The effect of the quote-quote '' is to paste the current value of s_x(T) into the function body. Otherwise, the function body is not evaluated, and you end up with an unevaluated symbol s_yx in the final result.

    When I try that, here's what I get. All the other stuff that went before is the same, I'm showing only the last part.

    (%i28) s_x2(s_yx):= ''(s_x(T));
                                        7 %pi
                                    cos(-----) s_yx
                                         18
    (%o28)            s_x2(s_yx) := ---------------
                                          7 %pi
                                      sin(-----)
                                           18
    (%i29) s_x2(10000`m);
                                    7 %pi
                          10000 cos(-----)
                                     18
    (%o29)                ---------------- ` m
                                 7 %pi
                             sin(-----)
                                  18
    (%i30) float(%);
    (%o30)                3639.702342662025 ` m
    

    Maxima has a so-called one-time evaluation policy, which leads, in this case, to s_yx not getting evaluated as expected. Using quote-quote in the function definition avoids the problem in this case.

    Another way to do it is to say define(s_x2(s_yx), s_x(T)). That's more general because quote-quote is applied only at the time the input is parsed.