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:

Fortran Calculator

Fortran

Function: fortran (<expr>) Prints <expr> as a Fortran statement. The output line is indented with spaces. If the line is too long, fortran prints continuation lines. fortran prints the exponentiation operator ^ as **, and prints a complex number a + b %i in the form (a,b).

f(x):= log(x+1);
T4(x):=taylor(f(x), x, 0, 4);
T7(x):=taylor(f(x), x, 0, 7);
T11(x):=taylor(f(x), x, 0, 11);
T16(x):=taylor(f(x), x, 0, 16);
fortran(T4(x));
fortran(T7(x));
fortran(T11(x));
fortran(T16(x));
tex(T4(x));
tex(T7(x));
tex(T11(x));
tex(T16(x));
plot2d ([f(x),T4(x),T7(x),T11(x),T16(x)],[x, -1.5, 1.5],[y, -4, 2],[legend, "log(1+x)", "y=T4", "y=T7", "y=T11", "y=T16"],[gnuplot_preamble,"set key left"]);

<expr> may be an equation. If so, fortran prints an assignment statement, assigning the right-hand side of the equation to the left-hand side. In particular, if the right-hand side of <expr> is the name of a matrix, then fortran prints an assignment statement for each element of the matrix.

If <expr> is not something recognized by fortran, the expression is printed in grind format without complaint. fortran does not know about lists, arrays, or functions.

fortindent controls the left margin of the printed lines. 0 is the normal margin (i.e., indented 6 spaces). Increasing fortindent causes expressions to be printed further to the right.

When fortspaces is true, fortran fills out each printed line with spaces to 80 columns.

fortran evaluates its arguments; quoting an argument defeats evaluation. fortran always returns done.

Examples:

     (%i1) expr: (a + b)^12$
     (%i2) fortran (expr);
           (b+a)**12
     (%o2)                         done
     (%i3) fortran (x=expr);
           x = (b+a)**12
     (%o3)                         done
     (%i4) fortran (x=expand (expr));
           x = b**12+12*a*b**11+66*a**2*b**10+220*a**3*b**9+495*a**4*b**8+792
          1   *a**5*b**7+924*a**6*b**6+792*a**7*b**5+495*a**8*b**4+220*a**9*b
          2   **3+66*a**10*b**2+12*a**11*b+a**12
     (%o4)                         done
     (%i5) fortran (x=7+5*%i);
           x = (7,5)
     (%o5)                         done
     (%i6) fortran (x=[1,2,3,4]);
           x = [1,2,3,4]
     (%o6)                         done
     (%i7) f(x) := x^2$
     (%i8) fortran (f);
           f
     (%o8)                         done

(%o1)                                true
(%i2) 

Fortran Example

Related Examples

fortran-log-plot2d-taylor-tex
plot2d ([P16(x),P4(x),P7(x),P11(x),f(x)], [x, -1.5, 1.5], [y, -4, 2],[color, green, blue, black, magenta, red],[legend, "T16", "T4", "T7", "T11", "Log(1+x)"],[axes,true], [xlabel,"X"] , [ylabel,"Y"]);

f(x):= log(1+x);

P4(x):=taylor(f(x), x...

P7(x):=taylor(f(x), x...

Calculate

fortran-plot2d-sin-taylor-tex
plot2d ([f(x),P1(x),P3(x),P5(x),P7(x)], [x, -%pi, %pi],[color, red, blue, black, orage, green],[legend, "y=sin(x)", "y=P1(x)", "y=P3(x)", "y=P5(x)", "y=P7(x)"],[axes,true], [xlabel,"X"] , [ylabel,"Y"]);

f(x):= sin(x);

P1(x):=taylor(f(x), x...

P3(x):=taylor(f(x), x...

Calculate

fortran-log-plot2d-taylor-tex
plot2d ([f(x),t(x),t2(x),t3(x),t4(x)], [x, -%pi, %pi]);

f(x):= log(x);

t(x):=taylor(f(x), x,...

t2(x):=taylor(f(x), x...

Calculate

fortran-log-plot2d-taylor-tex
plot2d ([f(x), P1(x), P3(x), P5(x), P7(x)], [x, -%pi, %pi]);

f(x):=log(1+x);

P1(x):=taylor(f(x), x...

P3(x):=taylor(f(x), x...

Calculate

fortran-plot2d-sin-taylor-tex
plot2d ([f(x),t(x)], [x, -5, 5]);

f(x):= sin(x);

t(x):=taylor(f(x), x,...

fortran(t(x));

Calculate

fortran-linsolve

eq1:x*4+y-2=y;

eq2:x+2=y;

fortran (linsolve([eq...

Calculate

fortran-log-plot2d-taylor-tex
plot2d ([f(x),t4(x), t7(x), t11(x), t16(x)], [x, -1.5, 1.5], [y, -4, 2]);

f(x):= log(1+x);

t4(x):=taylor(f(x), x...

t7(x):=taylor(f(x), x...

Calculate

fortran-plot2d-sin-taylor-tex
plot2d ([f(x),t(x), t1(x), t3(x), t5(x), t7(x)], [x, -%pi, %pi]);

f(x):= sin(x);

t1(x):=taylor(f(x), x...

t3(x):=taylor(f(x), x...

Calculate

fortran-log-sum

dLdB:1/B*sum(Ni[i],i,...

fortran(dLdB);

Calculate

fortran-plot2d-sin-taylor-tex
plot2d ([f(x),T1(x), T3(x), T5(x), T7(x)], [x, -%pi, %pi], [y, -2, 2], [color,blue,green,red,black,green],[legend, "f", "P1", "P3", "P5", "P7"],       [axes, true], [ylabel,"sin(x)"]);

f(x):= sin(x);

T1(x):=taylor(f(x), x...

T3(x):=taylor(f(x), x...

Calculate