/*************** -*- Mode: MACSYMA; Package: MAXIMA -*-  ******************/
/***************************************************************************
***                                                                    *****
***     Copyright (c) 1984 by William Schelter,University of Texas     *****
***     All rights reserved                                            *****
***************************************************************************/


kill(all);
done;
deftaylor(f(x),x^2+sum(x^i/(2^i*i!^2),i,4,inf));
[f]$
taylor(%e^sqrt(f(x)),x,0,4);
1+x+x^2/2+3073*x^3/18432+12817*x^4/307200$

ev(x+sin(3*x)/sin(x),trigexpand,expand);
-sin(x)^2+3*cos(x)^2+x$
trigexpand(sin(10*x+y));
cos(10*x)*sin(y)+sin(10*x)*cos(y)$
-sin(x)^2+3*cos(x)^2+x;
-sin(x)^2+3*cos(x)^2+x$
expand(trigreduce(%));
2*cos(2*x)+x+1$
declare(j,integer,e,even,o,odd);
done$
sin(x+(e+1/2)*%pi),expand;
cos(x)$
sin(x+(o+1/2)*%pi),expand;
-cos(x)$
(linel:500,diff(exp(x^2+y)/(x+y),x,2));
4*x^2*%e^(y+x^2)/(y+x)+2*%e^(y+x^2)/(y+x)-4*x*%e^(y+x^2)/(y+x)^2 +2*%e^(y+x^2)/(y+x)^3$

sconcat(optimize(%));
"block([%1,%2,%3,%4],%1:y+x,%2:x^2,%3:%e^(y+%2),%4:1/%1,4*%2*%4*%3+2*%4*%3-(4*x*%3)/%1^2+(2*%3)/%1^3)"$

linel:79;
79$
laplace(%e^(2*t+a)*sin(t)*t,t,s);
%e^a*(2*s-4)/(s^2-4*s+5)^2$
'integrate(sinh(a*x)*f(t-x),x,0,t)+b*f(t) = t^2;
'integrate(f(t-x)*sinh(a*x),x,0,t)+b*f(t) = t^2$

expand(laplace(%,t,s),0,0);
''(expand(b*laplace(f(t),t,s)+a*laplace(f(t),t,s)/(s^2-a^2) = 2/s^3,0,0))$

linsolve([%],['laplace(f(t),t,s)]);
['laplace(f(t),t,s) = (2*s^2-2*a^2)/(b*s^5+(a-a^2*b)*s^3)]$

(exp : %,0);
0$

assume(a>0,b>0,a*b>1);
[a>0,b>0,a*b>1];
ilt(ev(exp[1]),s,t);
f(t)=-2*cosh(sqrt(a*b*(a*b-1))*t/b)/(a^3*b^2-2*a^2*b+a)+a*t^2/(a*b-1)+2/(a^3*b^2-2*a^2*b+a)$
forget(a>0,b>0,a*b>1);
[a>0,b>0,a*b>1];

/* bug reported to mailing list 2015-02-16: expand phenomenon */

block ([f1, f2], f1:y=(x+1)*(x+3), f2:expand(f1), string (expand(f1)=expand(f2)));
"(y = x^2+4*x+3) = (y = x^2+4*x+3)";

string ((a = b) = (c = d));
"(a = b) = (c = d)";

/* following is supposed to test pretty printing code path
 * not sure if embedded newline will be recognized appropriately on Windows
 */
block ([s, display2d : true, stuff],
  s : make_string_output_stream (),
  with_stdout (s, print ((a = b) = (c = d))),
  stuff : get_output_stream_string (s),
  close (s),
  stuff);
"(a = b) = (c = d) 
";

infix ("foo");
"foo";

string ((a foo b) foo (c foo d));
"(a foo b) foo (c foo d)";

/* following is supposed to test pretty printing code path
 * not sure if embedded newline will be recognized appropriately on Windows
 */
block ([s, display2d : true, stuff],
  s : make_string_output_stream (),
  with_stdout (s, print ((a foo b) foo (c foo d))),
  stuff : get_output_stream_string (s),
  close (s),
  stuff);
"(a foo b) foo (c foo d) 
";

kill ("foo");
done;
