Packages to solve domain, equations and inequalities, interval arithmetic functions.



At the risk of discouraging you, I would like to make some suggestions 
on how to (re)write some of your code.

1. Using [a,b] to represent an interval is probably not a good idea 
since [a,b] is used as a list and also a matrix row and maybe a set, and 
also a parameter list and a subscript list
already.

It may not seem logical to you, but you can use  interval(a,b)  and it 
takes no more space or access time etc.  A good way to think about this 
is that
[a,b]  is the same as  ?mlist(a,b).

If you want to have open and closed intervals, I'm not sure how to best 
encode them, but using
[[a,a],[a,b],[b,b]]   for the close interval from a to b does not seem 
economical, especially since a list of lists looks like a matrix.

perhaps interval(a,b,left)  interval(a,b,right), interval(a,b,both)?

or  %union(interval(a,b),a)    %union(interval(a,b),b)  etc.

In the interests of "data abstraction" it would be better to define 
operations like low(interval) and high(interval)  rather than using  
interval[1].
in fact you could have atomic items or something else be intervals.
Thus if we wanted to have an interval from 3 to 3,  we could just use 3.

is_an_interval(a):= atom(h) or op(a)='interval;

low(h):= if atom(h) then h else if op(h)='interval then inpart(h,1);

If you later decide to change the representation, the only things that 
need to be changed are definitions of low, high, is_an_interval, and
other data representation programs.

You might also decide how to do comparisons using something other than 
<, >, etc.

There are also arguments for why intervals should be labeled according 
to their origin, and how to maintain them.
see, for example,
http://www.cs.berkeley.edu/~fateman/papers/interval.pdf

I think it would be good to have inequality solving in Maxima, and I 
hope your programs can be made as complete,
efficient, and correct as possible.

RJF





mihail22 mihail22 wrote:
> Hi.
> Thank you for attention to my letter.
>
> This simple project is related to modification of Maxima's solver 
> (equations and inequalities).
> Using domain function in the solver to eliminate wrong roots from the 
> final result of the function.
>
> I have developed new functions:
>   1) module that computes domain of superposition of elementary functions;
>   2) interval arithmetics module;
>   3) module to solve equations and inequalities.
>
> Modules to solve inequalities ond compute domain are located in the 
> same file "ineq_domain.mac".
> Module to solve equations is located in the "solve_equation.mac".
> Interval arithmetics functions are written in the 
> "interval_arithmetics.mac".
>
> 1), (inequality 3)) Package to solve inequalities is based on idea of 
> "solve_rat_ineq" and
> package "fourier_elim". It can solve polynomial and rational 
> inequalities, and linear
> inequalities with functions abs(), max(), min() and simple cases that 
> can be reduced to linear ones.
> This package produces answer - internal representation of lists of 
> intervals. It uses
> package "interval_arithmetic" to perform basic operations with 
> intervals and lists of intervals:
> intersect, combine, exclude, etc. (comments on internal arithmetic 
> functions are written in source
> file "interval_arithmetic.mac".)
> Internal representation from the function 'solve_ineq' is used to 
> compute domain of mathematical
> expressions. It process superposition of functions and accumulate list 
> of all sub-domains for
> subexpressions. Basic points to compute domain are functions:
> f(x)/g(x), log(f(x)), (f(x)^(g(x)), tan(x), cot(x), sec(x), csc(x), 
> asin(x),
> acos(x),f(x)^(negative exponent).
>
> Functions: domain_return(expr, var), solve_ineq(ineq, var) --- 
> produces result in
> the internal representation of lists of intervals, single points, 
> periodic results and
> unsolved expressions.
>
> Functions: solve_inequality(ineq, var), domain_solve(expr, var) --- 
> produces result in
>  the TeX-form. It can be used to output results as images or .pdf and 
> .ps text.
>
> 2) Internal arithmetics package is used in solving domain, equality 
> and inequality.
>  Description of basic functions is located in the file 
> "interval_arithmetic.mac".
>  If the function does not include in its name suffix _strict_, it 
> handles input parameters
>  as the set of segments (The boundary points of intervals are 
> included). If a function
> name contains the suffix _strcit_, then the input and output values of 
> intervals, and
> segments should be interpreted as follows:
>   ______________________________
> _________________________________
>   Internal representation    ||||    Mathematical representation
>   
> --------------------------------------------------------------------------------------------------
>   |     [a,b]                           ->                            
> (a,b)              |
>   |     [[a,a],[a,b]]                ->                            
> [a,b)              |
>   |     [[a,b],[b,b]]                ->                            
> (a,b]              |
>   |     [[a,a],[a,b],[b,b]]        ->                            
> [a,b]              |
>   
> ----------------------------------------------------------------------------------------------------
>  
> 3) Package to solve equations. It uses functions 'solve' and 
> 'to_poly_solve'. Some steps of the
> solution are displayed. Before solution of the equation it does 
> preprocessing to check domain of
> expression, check some classes of equations and special processing.
> Result contains roots from real domain only (Russian school's program 
> does not contain imaginary domain
> and this packages will be used for special school program).
> This module catches errors of 'to_poly_solve' (if it can not solve) 
> and produces corresponding result
> without error message.
>
> This module is written to solve single equations with one variable 
> (mainly). But it has some processing
> of systems of equations (in that case it calls 'solve' function to 
> solve the system of equations).
>
> After solving of equation this module does post-processing to discard 
> roots that are not in the domain of
> initial equation.
> Result is the list of explicit roots (or intervals:  x/x=1 => (minf, 
> 0), (0, inf)), periodic roots, unsolved
> expressions.
>
> In some cases solver have to turn off Maxima's simplifier: it is 
> necessary to compute domain for some
> expressions before simplification stage. For example: 
> asin(x)/asin(x)=1. If simplifier is turned on then result
> is [minf, inf]. Else if simplifier is turned off then result is [-1, 
> 0), (0, 1]. For equation
> ((x+1)/(x+1)+(2*x+3)/(2*x+3))/((x^2-4)/(x^2-4))=2 result is (minf, 
> -2),(-2, -3/2),(-3/2, -1), (-1, 2), (2, inf)
>
> (or in TeX-form $$x\in\left( -\infty 
> ,-2\right)\cup\left(-2,-{{3}\over{2}}\right)\cup\left(-{{3}\over{2}},-1\right)
> \cup\left(-1,2\right)\cup\left(2,\infty \right)$$)
>
> Interesting example of using simp:false.
>
> If simp:true then function solve(1.3^x=6, x) and function 
> to_poly_solve(1.3^x=6, x) can not solve it.
> If simp:false then solve produces correct result - correct root 
> log(6)/log(13/10)
> $$x={{\log 6}\over{\log \left({{13}\over{10}}\right)}}$$
>
>
>
> Function: solve_equation(equation, vars) --- produces result in 
> TeX-form expression.
> -----------------------------------------------------------------------------------------------------------
> !!!!!!Warning!!!!!!!!!!
> Before using of these modules You should do:
>   load("interval_arithmetic.mac"),
>   load("ineq_domain.mac"),
>   load("solve_equation.mac"),
>
> All functions of the above-mentioned packages should process some 
> cases when simplifier is turned off.
> Instruction for usage of functions:
>  1. before each function call you should do simp:false;
>  2. then function call: solve_equation(expr, var),
>                         solve_inequality(expr, var),
>                         domain_solve(expr, var),
>                         solve_ineq(expr, var),
>                         domain_return(expr, var);
>  3. after function call you should do simp:true. It is necessary due 
> to correct working of other Maxima's functions.
>
> Example:
>   simp:false,
>   solve_equation((x+1)/(x+1)+(2*x+3)/(2*x+3)=2,x),
>   simp:true,
>  
>   simp:false,
>   
> solve_equation(1/x*sin(sqrt(cot(1/(x-sin(log(asin(x)))))))+acos(tan(x+10))+(1+x)^(x*sqrt(x+2*cos(x)))=0,x),
>   simp:true,
>  
>   simp:false,
>   solve_inequality((x-1)/(x-2)*(x-3)/(x-4)*(x-5)/(x-6)>=0,x),
>   simp:true,
>
>   simp:false,
>   
> domain_solve(sqrt(abs(x)-7*x)+asin(1/1000000*x)/(x^2-16)+log(abs(x+5)-4)+(x-1)/(x-1)+(100000000-x^4)^(25*x)=0,x),
>   simp:true,
>
> -------------------------------------------------------------
>
> I work at solve_inequality package to add processing of new cases:
>       /* TODO: Inequality preprocessor
>        * Analyze type of the equation:
>        *  - with abs function,
>        *  - with square roots,
>        *  - with exponentiation,
>        *  - with logarithms,
>        *  - with trigonometric and arc-trigonometric functions      
>        */
> Also I am going to add special processing of periodic solutions --- 
> correct intersection, combination, output.
>
>
> --------------------------------------------------------------
> If it would be possible for You, please, try to test these packages.
>
> Best regards,
> Mihail Denisenko
> ------------------------------------------------------------------------
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>