Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

If

-- Special operator: if Represents conditional evaluation. Various forms of if expressions are recognized.

if <cond_1> then <expr_1> else <expr_0> evaluates to <expr_1> if <cond_1> evaluates to true, otherwise the expression evaluates to <expr_0>.

solve(-18*x^2-50=600*x)[1];
solve(-18*x^2-50=600*x)[2];
xvals: map(rhs,solve(-18*x^2-50=600*x));
yvals: map(lhs,solve(-18*x^2-50=600*x));
yvals[1] - xvals[1];
for i:1 while i<=(length(realroots(-18*x^2-50=600*x))) do (mye:yvals[i] - xvals[i],a:if(is(ratsimp(abs(mye-0)<= 0))) then return (100));
a;

if <cond_1> then <expr_1> elseif <cond_2> then <expr_2> elseif ... else <expr_0> evaluates to <expr_k> if <cond_k> is true and all preceding conditions are false. If none of the conditions are true, the expression evaluates to expr_0.

A trailing else false is assumed if else is missing. That is, if <cond_1> then <expr_1> is equivalent to if <cond_1> then <expr_1> else false, and if <cond_1> then <expr_1> elseif ... elseif <cond_n> then <expr_n> is equivalent to if <cond_1> then <expr_1> elseif ... elseif <cond_n> then <expr_n> else false.

The alternatives <expr_0>, ..., <expr_n> may be any Maxima expressions, including nested if expressions. The alternatives are neither simplified nor evaluated unless the corresponding condition is true.

The conditions <cond_1>, ..., <cond_n> are expressions which potentially or actually evaluate to true or false. When a condition does not actually evaluate to true or false, the behavior of if is governed by the global flag prederror. When prederror is true, it is an error if any evaluated condition does not evaluate to true or false. Otherwise, conditions which do not evaluate to true or false are accepted, and the result is a conditional expression.

Among other elements, conditions may comprise relational and logical operators as follows.

Operation Symbol Type

less than < relational infix less than <= or equal to relational infix equality (syntactic) = relational infix negation of = # relational infix equality (value) equal relational function negation of equal notequal relational function greater than >= or equal to relational infix greater than > relational infix and and logical infix or or logical infix not not logical prefix

There are also some inexact matches for if. Try ?? if to see them.

(%o1)                                true
(%i2) 

Related Examples

if-plot2d
plot2d([j(x)],[x,-1,1],[y,-1,1]);

j(x):=if (x<=0.5) ...

plot2d([j(x)],[x,-1,1...

g(x):=if (x<=0.5) ...

Calculate

if-reverse

:lisp (defun enum-int...

:lisp (enum-interval ...

:lisp (reduce '+ (enu...

Calculate

if-integrate-plot2d-quad_qag-sqrt
plot2d([F(x), f(x)], [x, -1, 2], [y, -0.5, 2.5], [box, true], [legend, "F(x)", "f(x)"]);

/*dystrybuanta*/F(x):...

/*gestosc*/f(x):=if (...

integrate(2*x^2, x);

Calculate

if

a(n):=if(n=0) then 0 ...

a(3);

Calculate

if-plot2d-plot3d
plot2d([f(x)],[x,-1,3],[y,-4,5]);

f(x):=if (x>=0) th...

plot2d([f(x)],[x,-1,3...

g(x):=f(x)/(f(x)+f(1-...

Calculate

if-invert-matrix-printf-submatrix

M: matrix( [2,1,5], [...

A:submatrix(M,3);

B:submatrix(submatrix...

Calculate

if-min-plot2d
plot2d([r(x),s(x)],[x,-1,1]);

j(x):=if (x<=0.5) ...

f(x):=j(2*x);

h(x):=j(2*x-1);

Calculate

if

sa (x) := if (x=a) th...

sb (x) := if (x=a) th...

sa (b);

Calculate

if-plot2d
plot2d(envelope(t, ramp_start, ramp_end) * ramp(t),[t,0,duration], [y,-1,1]);

duration:10000;

ramp_start:0.3;

ramp_end:-1;

Calculate

if-min-plot2d-sqrt
plot2d(h(x),[x,-1,1]);

j(x):=if (x<=0.5) ...

g(x):=if (x<=0.5) ...

p(x):=3+2*(j(x))^2+2*...

Calculate