Sindbad~EG File Manager
/* Some little-used operators for MathXpert, by M. Beeson.
1.10.94 original date
3.30.99 last modified
3.10.00 corrected strcat to strcpy in sumofarctan
*/
#include <string.h>
#include <math.h>
#include "globals.h"
#include "ops.h"
#include "trig.h"
#include "match.h"
#include "order.h"
#include "cancel.h"
#include "prover.h"
#include "symbols.h"
/*__________________________________________________________________*/
int sincossame(term t, term arg, term *next, char *reason)
/* cos x cos x = \onehalf sin 2x */
{ int err;
term lhs,rhs,a,temp,u;
lhs = product(sin1(var0),cos1(var0));
rhs = sin1(product(two,var0));
err = match(t,lhs,rhs,&a,&temp); /* instantiate a and temp */
if(err)
{ destroy_term(lhs);
destroy_term(rhs);
return 1;
}
SETCOLOR(temp,YELLOW);
err = cancel(temp,two,&u,next); /* make 2 sin x cos x = sin 2x */
if(err)
{ u = make_fraction(one,two);
SETCOLOR(u,YELLOW);
*next = product(make_fraction(one,two),temp);
strcpy(reason,"$sin \\theta cos \\theta = \\onehalf sin 2\\theta$");
return 0;
}
strcpy(reason,"$2 sin \\theta cos \\theta = sin 2\\theta$");
return 0;
}
/*__________________________________________________________________*/
int sumofarcsin(term t, term arg, term *next, char *reason)
/* arcsin x + arccos x = \\pi /2 */
{ term lhs,rhs,a;
int err;
if(FUNCTOR(t) != '+')
return 1;
lhs = sum(asin1(var0),acos1(var0));
rhs = make_fraction(pi_term,two);
err = match(t,lhs,rhs,&a,next); /* instantiate a and *next */
if(err)
{ destroy_term(lhs);
destroy_term(rhs);
return 1;
}
SETCOLOR(*next,YELLOW);
strcpy(reason,"$arcsin x+arccos x=\\pi /2$");
return 0;
}
/*__________________________________________________________________*/
int sumofarctan(term t, term arg, term *next, char *reason)
/* arctan x + arctan 1/x = pi x/2|x| */
{ term lhs,rhs,a,temp;
int err,complex;
if(FUNCTOR(t) != '+')
return 1;
lhs = sum(atan1(var0),atan1(reciprocal(var0)));
rhs = make_fraction(pi_term,two);
err = match(t,lhs,rhs,&a,next); /* instantiate a and *next */
if(err)
{ destroy_term(lhs);
destroy_term(rhs);
return 1;
}
strcpy(reason, "arctan x + arctan 1/x ");
complex = get_complex();
err = infer(lessthan(zero,complex ? re(a) : a));
if(!err)
{ if(complex)
strcat(reason,"$= \\pi /2 (Re[x] > 0)$");
else
strcat(reason,"$= \\pi /2 (x > 0)$");
SETCOLOR(*next,YELLOW);
return 0;
}
err = infer(lessthan(complex ? re(a) : a,zero));
if(!err)
{ *next = tnegate(*next);
if(complex)
strcat(reason, "$= -\\pi /2 (Re[x] < 0)$");
else
strcat(reason,"$= -\\pi /2 (x < 0)$");
SETCOLOR(*next,YELLOW);
return 0;;
}
temp = product(make_fraction(pi_term,two),make_fraction(a,abs1(a)));
polyval(temp,next);
SETCOLOR(*next,YELLOW);
return 0;
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists