-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfaq.html
635 lines (624 loc) · 40.3 KB
/
faq.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
<!DOCTYPE html>
<html lang="en" data-content_root="./">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>FriCAS FAQ — FriCAS</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/classic.css?v=514cf933" />
<link rel="stylesheet" href="_static/style.css" type="text/css" />
<script src="_static/documentation_options.js?v=a44cb687"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Examples" href="examples.html" />
<link rel="prev" title="Help" href="help.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="examples.html" title="Examples"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="help.html" title="Help"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">FriCAS</a> »</li>
<li class="nav-item nav-item-1"><a href="help.html" accesskey="U">Help</a> »</li>
<li class="nav-item nav-item-this"><a href="">FriCAS FAQ</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="fricas-faq">
<h1>FriCAS FAQ<a class="headerlink" href="#fricas-faq" title="Link to this heading">¶</a></h1>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#general-questions" id="id1">General Questions</a></p>
<ul>
<li><p><a class="reference internal" href="#what-is-fricas" id="id2">What is FriCAS?</a></p></li>
<li><p><a class="reference internal" href="#what-is-the-relation-between-fricas-and-axiom" id="id3">What is the relation between FriCAS and Axiom?</a></p></li>
<li><p><a class="reference internal" href="#what-does-the-fricas-name-mean" id="id4">What does the FriCAS name mean?</a></p></li>
<li><p><a class="reference internal" href="#where-can-i-find-online-information-about-fricas" id="id5">Where can I find online information about FriCAS?</a></p></li>
<li><p><a class="reference internal" href="#where-can-i-find-documentation" id="id6">Where can I find documentation?</a></p></li>
<li><p><a class="reference internal" href="#where-should-i-report-bugs" id="id7">Where should I report bugs?</a></p></li>
<li><p><a class="reference internal" href="#how-one-can-use-fricas-in-a-pipe-or-in-batch-mode" id="id8">How one can use FriCAS in a pipe or in batch mode?</a></p></li>
<li><p><a class="reference internal" href="#how-to-find-where-an-exported-function-is-implemented" id="id9">How to find where an exported function is implemented?</a></p></li>
<li><p><a class="reference internal" href="#clef-does-not-work-is-there-an-alternative" id="id10">Clef does not work. Is there an alternative?</a></p></li>
<li><p><a class="reference internal" href="#default-hyperdoc-window-is-too-small-how-to-enlarge-it" id="id11">Default HyperDoc window is too small. How to enlarge it?</a></p></li>
<li><p><a class="reference internal" href="#why-does-fricas-behave-differently-after-loading-new-code" id="id12">Why does FriCAS behave differently after loading new code?</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#old-axiom-faq" id="id13">Old Axiom FAQ</a></p>
<ul>
<li><p><a class="reference internal" href="#the-fricas-command-fails" id="id14">The fricas command fails.</a></p></li>
<li><p><a class="reference internal" href="#how-can-i-create-and-access-lisp-functions-from-fricas" id="id15">How can I create and access Lisp functions from FriCAS?</a></p></li>
<li><p><a class="reference internal" href="#how-can-i-see-what-the-interpreter-is-trying-to-do" id="id16">How can I see what the interpreter is trying to do?</a></p></li>
<li><p><a class="reference internal" href="#how-can-i-record-console-output" id="id17">How can I record console output?</a></p></li>
<li><p><a class="reference internal" href="#graphics-doesn-t-work-or-sman-fails-to-start" id="id18">Graphics doesn’t work or sman fails to start ?</a></p></li>
<li><p><a class="reference internal" href="#what-is-the-purpose-of-the-domain-hackpi" id="id19">What is the purpose of the domain HACKPI?</a></p></li>
<li><p><a class="reference internal" href="#why-do-fricas-input-defined-functions-fail-in-fricas" id="id20">Why do .fricas.input defined functions fail in fricas?</a></p></li>
<li><p><a class="reference internal" href="#how-can-i-debug-algebra-code" id="id21">How can I debug algebra code?</a></p></li>
<li><p><a class="reference internal" href="#how-can-i-access-lisp-code-from-the-fricas-command-line" id="id22">How can I access lisp code from the FriCAS command line?</a></p></li>
</ul>
</li>
</ul>
</nav>
<section id="general-questions">
<h2>General Questions<a class="headerlink" href="#general-questions" title="Link to this heading">¶</a></h2>
<section id="what-is-fricas">
<h3>What is FriCAS?<a class="headerlink" href="#what-is-fricas" title="Link to this heading">¶</a></h3>
<p>FriCAS is an advanced computer algebra system. Its capabilities range
from calculus (integration and differentiation) to abstract algebra.
It can plot functions and has an integrated help system.</p>
</section>
<section id="what-is-the-relation-between-fricas-and-axiom">
<h3>What is the relation between FriCAS and Axiom?<a class="headerlink" href="#what-is-the-relation-between-fricas-and-axiom" title="Link to this heading">¶</a></h3>
<p>FriCAS forked from Axiom in 2007. FriCAS seeks different development
methodology and after fork removed several unused parts (without
removing functionality). FriCAS fixed a lot of bugs and added new
functionality. As of April 2013, in the src/algebra subdirectory,
which hosts mathematical functionality about 25% of code was added
after the fork.</p>
</section>
<section id="what-does-the-fricas-name-mean">
<h3>What does the FriCAS name mean?<a class="headerlink" href="#what-does-the-fricas-name-mean" title="Link to this heading">¶</a></h3>
<p>The prefix <em>Fri</em> is a deliberate misspelling of Free – FriCAS sounds
like Free CAS.</p>
<p>There is also a second meaning: the Polish word “frykas” (which sounds
similar to FriCAS) denotes generally tasty food (dainty); the French
word “fricassee” and the German “Frikassee” name a particular food.</p>
</section>
<section id="where-can-i-find-online-information-about-fricas">
<h3>Where can I find online information about FriCAS?<a class="headerlink" href="#where-can-i-find-online-information-about-fricas" title="Link to this heading">¶</a></h3>
<p>The main entrance point to documentation about FriCAS is
<a class="reference external" href="http://fricas.github.io">http://fricas.github.io</a>.</p>
<p>The mailing list
<a class="reference external" href="https://groups.google.com/group/fricas-devel?hl=en">https://groups.google.com/group/fricas-devel?hl=en</a>
is intended both for users and developers.
Please sign up before posting a message.</p>
</section>
<section id="where-can-i-find-documentation">
<h3>Where can I find documentation?<a class="headerlink" href="#where-can-i-find-documentation" title="Link to this heading">¶</a></h3>
<p>The main source of information about FriCAS is the “Axiom book” by
Jenks and Sutor in its adaptation for FriCAS. FriCAS continues to
update that contents of that book along with its development and calls
it <a class="reference external" href="https://fricas.github.io/book.pdf">FriCAS Book</a>. Its content is shown by the integrated HyperDoc
help system. You can also access the book in .pdf form at
<a class="reference external" href="http://fricas.github.io/book.pdf">http://fricas.github.io/book.pdf</a>.
An older version is available in in .xhtml form at
<a class="reference external" href="http://wiki.fricas.org/JenksSutorInXhtml">http://wiki.fricas.org/JenksSutorInXhtml</a>.</p>
</section>
<section id="where-should-i-report-bugs">
<h3>Where should I report bugs?<a class="headerlink" href="#where-should-i-report-bugs" title="Link to this heading">¶</a></h3>
<p>FriCAS moved to GitHub in March 2020. Issues should be reported to
<a class="reference external" href="https://github.com/fricas/fricas/issues">https://github.com/fricas/fricas/issues</a>.</p>
<p>The older bugtrackers at
<a class="reference external" href="http://sourceforge.net/tracker/?atid=972421&group_id=200168">SourceForge</a>
and
the <a class="reference external" href="`http://wiki.fricas.org/IssueTracker">FriCAS wiki</a>
should not be used anymore.</p>
</section>
<section id="how-one-can-use-fricas-in-a-pipe-or-in-batch-mode">
<h3>How one can use FriCAS in a pipe or in batch mode?<a class="headerlink" href="#how-one-can-use-fricas-in-a-pipe-or-in-batch-mode" title="Link to this heading">¶</a></h3>
<p>Currently trying to run plain <code class="docutils literal notranslate"><span class="pre">fricas</span></code> command in a pipe hangs
(this is a bug, but fix requires substantial change).
Instead, one needs to pass <code class="docutils literal notranslate"><span class="pre">-nosman</span></code> option.</p>
<p>There several ways to let FriCAS process commands from a file.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>fricas -nosman < tst.input > tst.output
cat tst.input | fricas -nosman > tst.output
echo ')read tst.input' | fricas -nosman > tst.output
</pre></div>
</div>
<p>Whereas the first two versions do not show the input in <code class="docutils literal notranslate"><span class="pre">tst.ouput</span></code>,
the last command does. However, in the latter case it is hard to
distinguish input from output.</p>
<p>Note: Similarly to the commandline, pipe mode requires each function
to be defined in a single line.</p>
</section>
<section id="how-to-find-where-an-exported-function-is-implemented">
<h3>How to find where an exported function is implemented?<a class="headerlink" href="#how-to-find-where-an-exported-function-is-implemented" title="Link to this heading">¶</a></h3>
<p>In Hyperdoc ‘Browse’ window enter the constructor name or its
abbreviation and click on ‘Constructors’. In the resulting form
specify all parameters. Then click on ‘Operations’ and finally on
‘Implementations’. If you are interested in a single operation, after
clicking on ‘Operations’ click on an operation name and then click on
‘Implementations’.</p>
</section>
<section id="clef-does-not-work-is-there-an-alternative">
<h3>Clef does not work. Is there an alternative?<a class="headerlink" href="#clef-does-not-work-is-there-an-alternative" title="Link to this heading">¶</a></h3>
<p>If you have GNU Readline and <code class="docutils literal notranslate"><span class="pre">rlwrap</span></code> installed, the <code class="docutils literal notranslate"><span class="pre">-rl</span></code> option
will use GNU Readline editing, tab completion, and history, i.e. call
FriCAS like this:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>fricas -rl
</pre></div>
</div>
</section>
<section id="default-hyperdoc-window-is-too-small-how-to-enlarge-it">
<h3>Default HyperDoc window is too small. How to enlarge it?<a class="headerlink" href="#default-hyperdoc-window-is-too-small-how-to-enlarge-it" title="Link to this heading">¶</a></h3>
<p>Put the lines like below in file called <code class="docutils literal notranslate"><span class="pre">~/.Xresources</span></code>.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>FriCAS.hyperdoc.FormGeometry: =1200x700+40+40
FriCAS.hyperdoc.Geometry: =1200x700+40+40
</pre></div>
</div>
<p>They should take effect the next time you log in. If not
you may have to manually run</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>xrdb -m ~/.Xresources
</pre></div>
</div>
<p>If you work with a 4K-display and want to make the font bigger, you
can add the following to your <code class="docutils literal notranslate"><span class="pre">.Xresources</span></code> file.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>FriCAS.hyperdoc.Geometry: =1500x800+0+0
FriCAS.hyperdoc.RmFont: -adobe-courier-bold-r-*-*-34-*-*-*-*-*-*-*
FriCAS.hyperdoc.RmColor: black
FriCAS.hyperdoc.ActiveFont: -adobe-courier-bold-r-*-*-34-*-*-*-*-*-*-*
FriCAS.hyperdoc.ActiveColor: blue
FriCAS.hyperdoc.FriCASFont: -adobe-courier-bold-r-*-*-34-*-*-*-*-*-*-*
FriCAS.hyperdoc.FriCASColor: #008000
FriCAS.hyperdoc.BoldFont: -adobe-courier-bold-r-*-*-34-*-*-*-*-*-*-*
FriCAS.hyperdoc.BoldColor: red
FriCAS.hyperdoc.TtFont: -adobe-courier-bold-r-*-*-34-*-*-*-*-*-*-*
FriCAS.hyperdoc.TtColor: black
FriCAS.hyperdoc.EmphasizeFont: -adobe-courier-bold-r-*-*-34-*-*-*-*-*-*-*
FriCAS.hyperdoc.EmphasizeColor: #800080
FriCAS.hyperdoc.InputBackground: #FFFF80
FriCAS.hyperdoc.InputForeground: black
FriCAS.hyperdoc.BorderColor: black
FriCAS.hyperdoc.Background: white
</pre></div>
</div>
<p>Of course, you might want to choose other fonts that are available on
your computer. Use <code class="docutils literal notranslate"><span class="pre">xfontsel</span></code> to find out.</p>
</section>
<section id="why-does-fricas-behave-differently-after-loading-new-code">
<h3>Why does FriCAS behave differently after loading new code?<a class="headerlink" href="#why-does-fricas-behave-differently-after-loading-new-code" title="Link to this heading">¶</a></h3>
<p>When FriCAS loads new code, current variables become invalid.
This happens when you use</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)lib SOMELIB
</pre></div>
</div>
<p>or automatically when you compile a file via</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)compile foo.spad
</pre></div>
</div>
<p>You have to load and compile code before you start your computation.</p>
</section>
</section>
<section id="old-axiom-faq">
<h2>Old Axiom FAQ<a class="headerlink" href="#old-axiom-faq" title="Link to this heading">¶</a></h2>
<p>This list has been slightly adapted to match the new name FriCAS.</p>
<section id="the-fricas-command-fails">
<h3>The fricas command fails.<a class="headerlink" href="#the-fricas-command-fails" title="Link to this heading">¶</a></h3>
<p>This is likely one of two problems.</p>
<p>1. FriCAS uses clef as its command line editor. This has functionality
similar to GNU Readline but was written independently. The fricas
command uses</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>clef -e $FRICAS/bin/FRICASsys
</pre></div>
</div>
<p>Clef attempts to create new terminals and this might fail.
The first thing to check is the permission bits on /dev/pty.</p>
<p>2. It is possible to run the fricas image, called <code class="docutils literal notranslate"><span class="pre">FRICASsys</span></code>,
directly. Just type FRICASsys. It won’t have command recall or command
line editing but everything else is there.
A direct call to <code class="docutils literal notranslate"><span class="pre">FRICASsys</span></code> (with the <code class="docutils literal notranslate"><span class="pre">FRICAS</span></code> environment
variable set appropriately) can be done by calling</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>fricas -nosman
</pre></div>
</div>
</section>
<section id="how-can-i-create-and-access-lisp-functions-from-fricas">
<h3>How can I create and access Lisp functions from FriCAS?<a class="headerlink" href="#how-can-i-create-and-access-lisp-functions-from-fricas" title="Link to this heading">¶</a></h3>
<p>SExpression is the domain that handles raw lisp objects.
It is possible to create SExpression elements directly.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>m:=[1::SEX, 2::SEX]
[1,2]
Type: List SExpression
n:=m::SEX
(1 2)
Type: SExpression
car(n)
1
Type: SExpression
</pre></div>
</div>
<p>You can access lisp functions directly as in</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>GENSYM()$Lisp
</pre></div>
</div>
<p>Lisp is the domain, known to the interpreter and compiler, that
contains lisp functions and symbols.</p>
<p>Notice that FriCAS is case-sensitive and that generally lisp symbols
are upper case.</p>
<p>You can also create and call lisp functions.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)lisp (defun foo () (print "it works"))
Value = FOO
FOO()$Lisp
"it works"
it works
Type: SExpression
</pre></div>
</div>
<p>While accessing and writing functions in Lisp is possible it is
discouraged. FriCAS contains a programming language that should be
able to achieve almost everything you need.</p>
<p><strong>Use Lisp only when you cannot achieve your goal otherwise!</strong></p>
</section>
<section id="how-can-i-see-what-the-interpreter-is-trying-to-do">
<h3>How can I see what the interpreter is trying to do?<a class="headerlink" href="#how-can-i-see-what-the-interpreter-is-trying-to-do" title="Link to this heading">¶</a></h3>
<p>The command</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)set message bottomup on
</pre></div>
</div>
<p>will tell you the signatures that the interpreter is trying to use.</p>
<p>Another method is to do</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)boot $monitorNewWorld := t
</pre></div>
</div>
<p>and you can view database calls with</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)lisp (setq *miss* t)
</pre></div>
</div>
</section>
<section id="how-can-i-record-console-output">
<h3>How can I record console output?<a class="headerlink" href="#how-can-i-record-console-output" title="Link to this heading">¶</a></h3>
<p>Use <code class="docutils literal notranslate"><span class="pre">)spool</span></code>.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)spool filename
</pre></div>
</div>
<p>starts sending output to the file called <code class="docutils literal notranslate"><span class="pre">filename</span></code> and</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)spool )off
</pre></div>
</div>
<p>stops sending output to the file.</p>
</section>
<section id="graphics-doesn-t-work-or-sman-fails-to-start">
<h3>Graphics doesn’t work or sman fails to start ?<a class="headerlink" href="#graphics-doesn-t-work-or-sman-fails-to-start" title="Link to this heading">¶</a></h3>
<p>First try running <code class="docutils literal notranslate"><span class="pre">sman</span></code> as</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>sman -debug -noclef -noht
</pre></div>
</div>
<p>If graphics still doesn’t work or sman fails to start then look at the
error messages.</p>
</section>
<section id="what-is-the-purpose-of-the-domain-hackpi">
<h3>What is the purpose of the domain HACKPI?<a class="headerlink" href="#what-is-the-purpose-of-the-domain-hackpi" title="Link to this heading">¶</a></h3>
<p>HACKPI is a hack provided for the benefit of the FriCAS interpreter.
As a mathematical type, it is the simple transcendental extension
<span class="math notranslate nohighlight">\(Q(\pi)\)</span> of the rational numbers. This type allows interactive users to
use the name <code class="docutils literal notranslate"><span class="pre">%pi</span></code> without a type both where a numerical value is
expected as in</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>draw(sin x,x=-%pi..%pi)
</pre></div>
</div>
<p>or when the exact symbolic value is meant. The interpreter defaults a
typeless <code class="docutils literal notranslate"><span class="pre">%pi</span></code> to HACKPI and then uses the various conversions to cast
it further as required by the context.</p>
<p>One could argue that it is unfair to single <code class="docutils literal notranslate"><span class="pre">%pi</span></code> out from other
constants, but it occurs frequently enough in school examples
(specially for graphs) so it was worth a special hack. In a
non-interactive environment (library), HACKPI would not exist.</p>
</section>
<section id="why-do-fricas-input-defined-functions-fail-in-fricas">
<h3>Why do .fricas.input defined functions fail in fricas?<a class="headerlink" href="#why-do-fricas-input-defined-functions-fail-in-fricas" title="Link to this heading">¶</a></h3>
<p>You write this in your <code class="docutils literal notranslate"><span class="pre">.fricas.input</span></code> file:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>mrd(x:Integer,v:Integer):Integer == x+y
</pre></div>
</div>
<p>You can’t see this function even though it appears to be defined. That’s
because FriCAS is working in a new frame.</p>
<p>When you start <code class="docutils literal notranslate"><span class="pre">FRICASsys</span></code> you are running the interpreter talking
directly to the terminal. So the <code class="docutils literal notranslate"><span class="pre">.input</span></code> file is actually talking
to a frame at the top level. Your function is defined.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">.fricas.input</span></code> file is read in a “frame” called “initial”.
<code class="docutils literal notranslate"><span class="pre">FRICASsys</span></code> only uses the “initial” frame (although you can define and
use new ones). A frame contains its own variables and function definitions.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">fricas</span></code> command does several things that <code class="docutils literal notranslate"><span class="pre">FRICASsys</span></code> does
not. In particular the <code class="docutils literal notranslate"><span class="pre">fricas</span></code> shell script starts up the <code class="docutils literal notranslate"><span class="pre">sman</span></code>
process which starts <code class="docutils literal notranslate"><span class="pre">FRICASsys</span></code> (which reads the <code class="docutils literal notranslate"><span class="pre">.fricas.input</span></code>
file) and then <code class="docutils literal notranslate"><span class="pre">sman</span></code> creates a new frame (usually a random lisp gensym
name). In this new frame (created after <code class="docutils literal notranslate"><span class="pre">.fricas.input</span></code> is read) your
mrandom function is not defined.</p>
<p>To see this do</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>fricas -nosman -- This starts FRICASsys directly.
mrandom(3,3,3) -- compiles and runs the function
)quit
</pre></div>
</div>
<p>Now do</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>fricas
mrandom(3,3,3) -- undefined function
)frame next
mrandom(3,3,3) -- compiles and runs the function
)frame names -- shows you all of the defined frames
)quit
</pre></div>
</div>
<p>So with the <code class="docutils literal notranslate"><span class="pre">fricas</span></code> shell script the process is</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>fricas
start sman (done by fricas shell script)
sman starts FRICASsys (done by sman)
create frame "initial" (done by FRICASsys)
read .fricas.input (define your function here)
create frame "G00234" (done by sman)
put up a command prompt (in frame G00234, no functions defined)
)frame next (done by you)
.... and now you're back in frame initial
.... and your function is there
</pre></div>
</div>
<p>So your function was read and it is defined. However the function got
defined in the “initial” frame (because you defined it in the
<code class="docutils literal notranslate"><span class="pre">.fricas.input</span></code> file) and is not known in the frame created by
<code class="docutils literal notranslate"><span class="pre">sman</span></code>. The “)frame next” command will move you around the ring of
frames. (See the <code class="docutils literal notranslate"><span class="pre">)frame</span></code> command in the appendix of the
<a class="reference external" href="https://fricas.github.io/book.pdf">FriCAS Book</a>).</p>
</section>
<section id="how-can-i-debug-algebra-code">
<h3>How can I debug algebra code?<a class="headerlink" href="#how-can-i-debug-algebra-code" title="Link to this heading">¶</a></h3>
<p>FriCAS contains some powerful commands to help with testing and
debugging library modules written in Spad and also the FriCAS system
itself. The most important of these commands is <code class="docutils literal notranslate"><span class="pre">)trace</span></code>.</p>
<p>This command is used to trace the execution of functions that make
up the FriCAS system, functions defined by users, and functions from
the system library. Almost all options are available for each type
of function but exceptions will be noted below.</p>
<p>To list all functions, constructors, domains and packages that are
traced, simply issue</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace
</pre></div>
</div>
<p>To untrace everything that is traced, issue</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace )off
</pre></div>
</div>
<p>When a function is traced, the default system action is to display the
arguments to the function and the return value when the function is
exited. Other information can be displayed or collected when a
function is traced and this is controlled by the various options. If a
domain or package is traced, the default action is to trace all
functions exported. Individual interpreter, lisp or boot functions can
be traced by listing their names after <code class="docutils literal notranslate"><span class="pre">)trace</span></code>. Any options that are
present must follow the functions to be traced. For example</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace f
</pre></div>
</div>
<p>traces the function f. To untrace f, issue</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace f )off
</pre></div>
</div>
<p>Note that if a function name contains a special character, it will
be necessary to escape the character with an underscore</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace _/D_,1
</pre></div>
</div>
<p>To trace all domains or packages that are or will be created from a
particular constructor, give the constructor name or abbreviation
after <code class="docutils literal notranslate"><span class="pre">)trace</span></code></p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace MATRIX
)trace List Integer
</pre></div>
</div>
<p>The first command traces all domains currently instantiated with
<code class="docutils literal notranslate"><span class="pre">Matrix</span></code>. If additional domains are instantiated with this constructor
(for example, if you have used <code class="docutils literal notranslate"><span class="pre">Matrix(Integer)</span></code> and <code class="docutils literal notranslate"><span class="pre">Matrix(Float)</span></code>),
they will be automatically traced. The second command traces
<code class="docutils literal notranslate"><span class="pre">List(Integer)</span></code>.</p>
<p>The following are the general options for the <code class="docutils literal notranslate"><span class="pre">)trace</span></code> command.</p>
<p><code class="docutils literal notranslate"><span class="pre">)break</span> <span class="pre">after</span></code> – causes a Common Lisp break loop to be entered after
exiting the traced function.</p>
<p><code class="docutils literal notranslate"><span class="pre">)break</span> <span class="pre">before</span></code> – causes a Common Lisp break loop to be entered before
entering the traced function.</p>
<p><code class="docutils literal notranslate"><span class="pre">)break</span></code> – is the same as <code class="docutils literal notranslate"><span class="pre">)break</span> <span class="pre">before</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">)count</span></code> – causes the system to keep a count of the number of times the
traced function is entered.</p>
<p>The total can be displayed with:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace )stats
</pre></div>
</div>
<p>and cleared with:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace )stats reset
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">)count</span> <span class="pre">n</span></code> – causes information about the traced function to be displayed
for the first n executions. After the n-th execution, the function is
untraced.</p>
<p><code class="docutils literal notranslate"><span class="pre">)depth</span> <span class="pre">n</span></code> – causes trace information to be shown for only n levels of
recursion of the traced function.</p>
<p>The command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace fib )depth 10
</pre></div>
</div>
<p>will cause the display of only 10 levels of trace information for the
recursive execution of a user function fib.</p>
<p><code class="docutils literal notranslate"><span class="pre">)math</span></code> causes – the function arguments and return value to be displayed
in the FriCAS monospace two-dimensional math format.</p>
<p><code class="docutils literal notranslate"><span class="pre">)nonquietly</span></code> – causes the display of additional messages when a function
is traced.</p>
<p><code class="docutils literal notranslate"><span class="pre">)nt</span></code> – This suppresses all normal trace information. This option is useful
if the <code class="docutils literal notranslate"><span class="pre">)count</span></code> or <code class="docutils literal notranslate"><span class="pre">)timer</span></code> options are used and you are interested in the
statistics but not the function calling information.</p>
<p><code class="docutils literal notranslate"><span class="pre">)off</span></code> – causes untracing of all or specific functions. Without an argument,
all functions, constructors, domains and packages are untraced. Otherwise,
the given functions and other objects are untraced.</p>
<p>To immediately retrace the untraced functions, issue:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace )restore
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">)only</span> <span class="pre">listOfDataToDisplay</span></code> – causes only specific trace information to be
shown.</p>
<p><code class="docutils literal notranslate"><span class="pre">)restore</span></code> – causes the last untraced functions to be retraced. If
additional options are present, they are added to those previously in
effect.</p>
<p><code class="docutils literal notranslate"><span class="pre">)stats</span></code> – causes the display of statistics collected by the use of the
<code class="docutils literal notranslate"><span class="pre">)count</span></code> and <code class="docutils literal notranslate"><span class="pre">)timer</span></code> options.</p>
<p><code class="docutils literal notranslate"><span class="pre">)stats</span> <span class="pre">reset</span></code> – resets to 0 the statistics collected by the use of the
<code class="docutils literal notranslate"><span class="pre">)count</span></code> and <code class="docutils literal notranslate"><span class="pre">)timer</span></code> options.</p>
<p><code class="docutils literal notranslate"><span class="pre">)timer</span></code> – causes the system to keep a count of execution times for the
traced function. The total can be displayed with <code class="docutils literal notranslate"><span class="pre">)trace</span> <span class="pre">)stats</span></code> and
cleared with <code class="docutils literal notranslate"><span class="pre">)trace</span> <span class="pre">)stats</span> <span class="pre">reset</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">)varbreak</span> <span class="pre">var1</span> <span class="pre">...</span> <span class="pre">varN</span></code> – causes a Common Lisp break loop to be
entered after the assignment to any of the listed variables in the
traced function.</p>
<p><code class="docutils literal notranslate"><span class="pre">)vars</span></code> – causes the display of the value of any variable after it is
assigned in the traced function. Note that library code must have been
compiled using the <code class="docutils literal notranslate"><span class="pre">)vartrace</span></code> option in order to support this option.</p>
<p><code class="docutils literal notranslate"><span class="pre">)vars</span> <span class="pre">var1</span>  <span class="pre">...</span> <span class="pre">varN</span></code> – causes the display of the value of any of
the specified variables after they are assigned in the traced function.
Note that library code must have been compiled using the <code class="docutils literal notranslate"><span class="pre">)vartrace</span></code>
option in order to support this option.</p>
<p><code class="docutils literal notranslate"><span class="pre">)within</span> <span class="pre">executingFunction</span></code> – causes the display of trace information
only if the traced function is called when the given executingFunction
is running.</p>
<p>The following are the options for tracing constructors, domains and
packages.</p>
<p><code class="docutils literal notranslate"><span class="pre">)local</span> <span class="pre">op1</span> <span class="pre">...</span> <span class="pre">opN</span></code> – causes local functions of the constructor to
be traced. Note that to untrace an individual local function, you must
use the fully qualified internal name, using the escape character before
the semicolon. For example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace FRAC )local
)trace FRAC_;cancelGcd )off
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">)ops</span> <span class="pre">op1</span> <span class="pre">...</span> <span class="pre">opN</span></code> – By default, all operations from a domain or package
are traced when the domain or package is traced. This option allows you
to specify that only particular operations should be traced.</p>
<p>The command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>)trace Integer )ops min max _+ _-
</pre></div>
</div>
<p>traces four operations from the domain Integer. Since + and - are special
characters, it is necessary to escape them with an underscore.</p>
<p>Also See: <code class="docutils literal notranslate"><span class="pre">)boot</span></code>, <code class="docutils literal notranslate"><span class="pre">)lisp</span></code> , and <code class="docutils literal notranslate"><span class="pre">)ltrace</span></code>. Please refer to the
FriCAS Book section “FriCAS System Commands” for more detailed information.</p>
</section>
<section id="how-can-i-access-lisp-code-from-the-fricas-command-line">
<h3>How can I access lisp code from the FriCAS command line?<a class="headerlink" href="#how-can-i-access-lisp-code-from-the-fricas-command-line" title="Link to this heading">¶</a></h3>
<p>To run a lisp command from the command line use )lisp:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>--> )lisp (+ 2 3)
</pre></div>
</div>
<p>If you want to run a lot of lisp commands from the command line do</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>--> )lisp (setq $dalymode t)
--> (+ 2 3)
--> (defun foo (x y) (+ x y))
--> (foo 2 3)
--> 2 + 3
</pre></div>
</div>
<p>$dalymode says:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>If the first character is a '('
then it is lisp
else it is fricas
</pre></div>
</div>
<p>to disable it do</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>--> (setq $dalymode nil)
</pre></div>
</div>
<p>Tim Daly wrote this change to the interpreter because he used lisp a lot
during maintenance. It breaks some syntax but you can work around that.</p>
<p>If you really want to “drop” into lisp do</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>--> )fin
BOOT> (+ 2 3)
</pre></div>
</div>
<p>and now you are talking only to lisp at a lisp command prompt in
the BOOT package. To restart FriCAS type</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>BOOT>(restart)
</pre></div>
</div>
<p>Note: ‘)fin’ does not work when using Clozure CL or ECL. Due to
this do not use it in portable scripts.</p>
</section>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="api/index.html">FriCAS API</a></li>
<li class="toctree-l1"><a class="reference internal" href="features.html">Features</a></li>
<li class="toctree-l1"><a class="reference internal" href="download.html">Download</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="help.html">Help</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="development.html">Development</a></li>
<li class="toctree-l1"><a class="reference internal" href="citation.html">Citation</a></li>
<li class="toctree-l1"><a class="reference internal" href="history.html">History</a></li>
</ul>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/faq.rst.txt"
rel="nofollow">Show Source</a></li>
<li><a href="https://github.com/fricas/fricas/blob/master/src/doc/sphinx/source/faq.rst"
rel="nofollow">Show on GitHub</a></li>
<li><a href="https://github.com/fricas/fricas/edit/master/src/doc/sphinx/source/faq.rst"
rel="nofollow">Edit on GitHub</a></li>
</ul>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="examples.html" title="Examples"
>next</a> |</li>
<li class="right" >
<a href="help.html" title="Help"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">FriCAS</a> »</li>
<li class="nav-item nav-item-1"><a href="help.html" >Help</a> »</li>
<li class="nav-item nav-item-this"><a href="">FriCAS FAQ</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2007-2024, FriCAS Team.
</div>
</body>
</html>