Version Check

In [0]:
)version
)lisp cl-jupyter::+ispad-version+
)lisp cl-jupyter::*tmp-ispad*
Value = "FriCAS 2014-12-18 compiled at Son Okt 25 19:16:29 CET 2015"

Value = "0.9.6 :: 08-NOV-2015"

Value = ".tmp-ispad-40694.input"

Out[0]:

Examples

In [1]:
f(x) ==
  x>0 => 1
  x=0 => 0
  return -1
Out[1]:
                                                                   Type: Void
In [2]:
f(12.344)
Warning: HyperTeX macro table not found
   Compiling function f with type Float -> Integer 
Out[2]:
   1
                                                        Type: PositiveInteger
In [3]:
f(0.0)
Out[3]:
   0
                                                     Type: NonNegativeInteger
In [4]:
f(-1/7)
   Compiling function f with type Fraction(Integer) -> Integer 
Out[4]:
   - 1
                                                                Type: Integer
In [5]:
v:Vector(Integer):=[i^2 for i in 1..8]
Out[5]:
   [1,4,9,16,25,36,49,64]
                                                        Type: Vector(Integer)
In [6]:
M:= matrix [v,2*v,3*v]
Out[6]:
   +1  4   9   16  25  36   49   64 +
   |                                |
   |2  8   18  32  50  72   98   128|
   |                                |
   +3  12  27  48  75  108  147  192+
                                                        Type: Matrix(Integer)
In [7]:
L:=M*v
Out[7]:
   [8772,17544,26316]
                                                        Type: Vector(Integer)

TeX Output

In [8]:
)set output tex on
Out[8]:

In [9]:
M
Out[9]:
\( \def\sp{^}\def\sb{_}\def\leqno(#1){} \def\erf{\mathrm{erf}}\def\sinh{\mathrm{sinh}} \def\zag#1#2{{{\left.{#1}\right|}\over{\left|{#2}\right.}}} \def\csch{\mathrm{csch}} \require{color} \) $$ \left[ \begin{array}{cccccccc} 1 & 4 & 9 & {16} & {25} & {36} & {49} & {64} \\ 2 & 8 & {18} & {32} & {50} & {72} & {98} & {128} \\ 3 & {12} & {27} & {48} & {75} & {108} & {147} & {192} \end{array} \right] \leqno(NIL) $$ \(\\[3ex]\color{blue}\scriptsize\text{Matrix(Integer)}\)
In [10]:
L
Out[10]:
\( \def\sp{^}\def\sb{_}\def\leqno(#1){} \def\erf{\mathrm{erf}}\def\sinh{\mathrm{sinh}} \def\zag#1#2{{{\left.{#1}\right|}\over{\left|{#2}\right.}}} \def\csch{\mathrm{csch}} \require{color} \) $$ \left[ {8772}, \: {17544}, \: {26316} \right] \leqno(NIL) $$ \(\\[3ex]\color{blue}\scriptsize\text{Vector(Integer)}\)
In [11]:
I:=integrate(1/sqrt(1+x^4),x)
Out[11]:
\( \def\sp{^}\def\sb{_}\def\leqno(#1){} \def\erf{\mathrm{erf}}\def\sinh{\mathrm{sinh}} \def\zag#1#2{{{\left.{#1}\right|}\over{\left|{#2}\right.}}} \def\csch{\mathrm{csch}} \require{color} \) $$ \int \sp{\displaystyle x} {{1 \over {\sqrt {{{{ \%A} \sp {4}}+1}}}} \ {d \%A}} \leqno(NIL) $$ \(\\[3ex]\color{blue}\scriptsize\text{Union(Expression(Integer),...)}\)
In [12]:
D(I,x,2)
Out[12]:
\( \def\sp{^}\def\sb{_}\def\leqno(#1){} \def\erf{\mathrm{erf}}\def\sinh{\mathrm{sinh}} \def\zag#1#2{{{\left.{#1}\right|}\over{\left|{#2}\right.}}} \def\csch{\mathrm{csch}} \require{color} \) $$ -{{2 \ {{x} \sp {3}}} \over {{\left( {{x} \sp {4}}+1 \right)} \ {\sqrt {{{{x} \sp {4}}+1}}}}} \leqno(NIL) $$ \(\\[3ex]\color{blue}\scriptsize\text{Expression(Integer)}\)
In [13]:
function(%,G,x)
Out[13]:
\( \def\sp{^}\def\sb{_}\def\leqno(#1){} \def\erf{\mathrm{erf}}\def\sinh{\mathrm{sinh}} \def\zag#1#2{{{\left.{#1}\right|}\over{\left|{#2}\right.}}} \def\csch{\mathrm{csch}} \require{color} \) $$ G \leqno(NIL) $$ \(\\[3ex]\color{blue}\scriptsize\text{Symbol}\)
In [14]:
integrate(G(z),z)
   Compiling function G with type Variable(z) -> Expression(Integer) 
Out[14]:
\( \def\sp{^}\def\sb{_}\def\leqno(#1){} \def\erf{\mathrm{erf}}\def\sinh{\mathrm{sinh}} \def\zag#1#2{{{\left.{#1}\right|}\over{\left|{#2}\right.}}} \def\csch{\mathrm{csch}} \require{color} \) $$ 1 \over {\sqrt {{{{z} \sp {4}}+1}}} \leqno(NIL) $$ \(\\[3ex]\color{blue}\scriptsize\text{Union(Expression(Integer),...)}\)

Compile Test

In [15]:
)co ../spad/jupyter
   Compiling FriCAS source code from file 
      /home/kfp/Development/fricas_jupyter/static/ipynb/../spad/jupyter.spad
      using old system compiler.
   JUPY abbreviates package jupyter 
------------------------------------------------------------------------
   initializing NRLIB JUPY for jupyter 
   compiling into NRLIB JUPY 
Adding $ modemaps
Adding (String) modemaps
Adding (FileName) modemaps
   compiling local jFormat : (String,String) -> FileName
Adding (TextFile) modemaps
Time: 0.01 SEC.

   compiling exported jHtml : String -> FileName
Time: 0.00 SEC.

   compiling exported jMarkdown : String -> FileName
Time: 0.00 SEC.

   compiling exported jLatex : String -> FileName
Time: 0.00 SEC.

   compiling exported jJavascript : String -> FileName
Time: 0.00 SEC.

Adding (List (String)) modemaps
Adding (Expression (Float)) modemaps
Adding (SegmentBinding (Float)) modemaps
   compiling exported jDraw : (Expression Float,SegmentBinding Float) -> FileName
Adding (GnuDraw) modemaps
Adding (MoreSystemCommands) modemaps
Time: 0.02 SEC.

Adding (Expression (Float)) modemaps
Adding (SegmentBinding (Float)) modemaps
   compiling exported jDraw : (Expression Float,SegmentBinding Float,SegmentBinding Float) -> FileName
Adding (GnuDraw) modemaps
Adding (MoreSystemCommands) modemaps
Time: 0.01 SEC.

Adding (DoubleFloat) modemaps
Adding (List (DoubleFloat)) modemaps
   compiling exported jDrawXY : (List DoubleFloat,List DoubleFloat) -> FileName
Adding (GnuDraw) modemaps
Adding (MoreSystemCommands) modemaps
Time: 0.01 SEC.

(time taken in buildFunctor:  0)


;;;     ***       |jupyter| REDEFINED


;;;     ***       |jupyter| REDEFINED
Time: 0.01 SEC.


   Cumulative Statistics for Constructor jupyter
      Time: 0.06 seconds
 
   finalizing NRLIB JUPY 
   Processing jupyter for Browser database:
--------constructor---------
--------(jHtml ((FileName) (String)))---------
--->-->jupyter((jHtml ((FileName) (String)))): Improper first word in comments: html
"html display in ispad"
--------(jMarkdown ((FileName) (String)))---------
--->-->jupyter((jMarkdown ((FileName) (String)))): Improper first word in comments: markdown
"markdown display in ispad"
--------(jLatex ((FileName) (String)))---------
--->-->jupyter((jLatex ((FileName) (String)))): Improper first word in comments: latex
"latex display in ispad"
--------(jJavascript ((FileName) (String)))---------
--->-->jupyter((jJavascript ((FileName) (String)))): Improper first word in comments: javascript
"javascript display in ispad"
--------(jDraw ((FileName) (Expression (Float)) (SegmentBinding (Float))))---------
--->-->jupyter((jDraw ((FileName) (Expression (Float)) (SegmentBinding (Float))))): Improper first word in comments: GnuDraw
"GnuDraw 2D in Notebook"
--------(jDraw ((FileName) (Expression (Float)) (SegmentBinding (Float)) (SegmentBinding (Float))))---------
--->-->jupyter((jDraw ((FileName) (Expression (Float)) (SegmentBinding (Float)) (SegmentBinding (Float))))): Improper first word in comments: GnuDraw
"GnuDraw 3D in Notebook"
--------(jDrawXY ((FileName) (List (DoubleFloat)) (List (DoubleFloat))))---------
--->-->jupyter((jDrawXY ((FileName) (List (DoubleFloat)) (List (DoubleFloat))))): Improper first word in comments: GnuDraw
"GnuDraw 2D - (\\spad{x},{}\\spad{y}) lists"

; compiling file "/home/kfp/Development/fricas_jupyter/static/ipynb/JUPY.NRLIB/JUPY.lsp" (written 12 NOV 2015 01:09:51 AM):


; /home/kfp/Development/fricas_jupyter/static/ipynb/JUPY.NRLIB/JUPY.fasl written

; compilation finished in 0:00:00.078

------------------------------------------------------------------------
   jupyter is now explicitly exposed in frame initial 
   jupyter will be automatically loaded when needed from 
      /home/kfp/Development/fricas_jupyter/static/ipynb/JUPY.NRLIB/JUPY


Out[15]:

In [16]:
)show JUPY
 jupyter  is a package constructor
 Abbreviation for jupyter is JUPY 
 This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
 jHtml : String -> FileName            jJavascript : String -> FileName
 jLatex : String -> FileName           jMarkdown : String -> FileName
 jDraw : (Expression(Float),SegmentBinding(Float)) -> FileName
 jDraw : (Expression(Float),SegmentBinding(Float),SegmentBinding(Float)) -> FileName
 jDrawXY : (List(DoubleFloat),List(DoubleFloat)) -> FileName

Out[16]:

jupyter.spad tests

In [17]:
gnuDraw(G(x),x=-1..1,"gx.dat")
   Compiling function G with type Variable(x) -> Expression(Integer) 
   Compiling function %C with type DoubleFloat -> DoubleFloat 
Out[17]:
\( \def\sp{^}\def\sb{_}\def\leqno(#1){} \def\erf{\mathrm{erf}}\def\sinh{\mathrm{sinh}} \def\zag#1#2{{{\left.{#1}\right|}\over{\left|{#2}\right.}}} \def\csch{\mathrm{csch}} \require{color} \) \(\\[3ex]\color{blue}\scriptsize\text{Void}\)
In [18]:
)system gnuplot -e 'set term png' gx.dat > gx.png
Out[18]:

In [19]:
"gx.png"::FileName
Out[19]:
In [20]:
jDraw(sin(x)/x,x=0.1..12*%pi)
   Compiling function %E with type DoubleFloat -> DoubleFloat 
Out[20]:
In [21]:
)set output tex off
LDF ==> List DoubleFloat
X:=[i for i in 1..20]::LDF
Y:=[random 25 for i in 1..20]::LDF




Out[21]:
                                                                   Type: Void
   [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0,
    15.0, 16.0, 17.0, 18.0, 19.0, 20.0]
                                                      Type: List(DoubleFloat)
   [14.0, 12.0, 5.0, 1.0, 11.0, 3.0, 5.0, 4.0, 16.0, 7.0, 4.0, 1.0, 17.0, 19.0,
    23.0, 10.0, 18.0, 24.0, 13.0, 17.0]
                                                      Type: List(DoubleFloat)
In [22]:
jDrawXY(X,Y)
Out[22]:
In [23]:
jDraw(besselJ(1,x)*cos(y),x=0..10,y=0..10)
   Compiling function %G with type (DoubleFloat,DoubleFloat) -> 
      DoubleFloat 
Out[23]:

The following file type can be inserted by converting them to FileName:

  • .html
  • .md
  • .js
  • .svg
  • .png
In [24]:
"Flamingo.svg"::FileName
Out[24]:
image/svg+xml
In [25]:
jHtml  "<a href=_"http://www.w3schools.com/html/_">Visit our HTML tutorial</a>"
In [26]:
jHtml "<table style=_"width:100%_"> _
  <tr> _
    <td>Jill</td> _
    <td>Smith</td> _
    <td>50</td> _
  </tr> _
  <tr> _
    <td>Eve</td> _
    <td>Jackson</td> _
    <td>94</td> _
  </tr> _
</table>"
Out[26]:
Jill Smith 50
Eve Jackson 94
In [27]:
jHtml "<p>I will display &euro; and &#169; and &#174;</p>"
Out[27]:

I will display € and © and ®

In [28]:
jHtml "<p>This is <sub>subscripted</sub> text.</p>"
Out[28]:

This is subscripted text.

In [29]:
jHtml "<form> _
  First name:<br> _
  <input type=_"text_" name=_"firstname_"> _
  <br> _
  Last name:<br> _
  <input type=_"text_" name=_"lastname_"> _
</form> "
Out[29]:
First name:

Last name:
In [30]:
jHtml "<svg width=_"300_" height=_"200_"> <polygon points=_"100,10 40,198 190,78 10,78 160,198_" _
  style=_"fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;_"/> </svg>"
Out[30]:
In [31]:
jHtml  "<select name=_"cars_"> _
<option value=_"volvo_">Volvo</option> _
<option value=_"saab_">Saab</option> _
<option value=_"fiat_">Fiat</option> _
<option value=_"audi_">Audi</option> _
</select>"
Out[31]:
In [32]:
jHtml "$$-\frac{\hbar^2}{2m} \Delta\Psi+V(x)\,\Psi(x)=\ldots$$"
Out[32]:
$$-\frac{\hbar^2}{2m} \Delta\Psi+V(x)\,\Psi(x)=\ldots$$

Error tests

In [33]:
1/0
 
   >> Error detected within library code:
   division by zero

Out[33]:
error
In [34]:
besselI(1,23.3)
SIMPLE-ERROR: 
BesselI not implemented for (1.0 23.299999999999997)
Out[34]:

In [ ]: