summary refs log tree commit diff stats
path: root/article/texmacs-maxima-integral.html
blob: 7df36543696bb73af698c77cee8f1a1e71015e2f (plain) (blame)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
	<head>
		<title>TeXmacs Maxima Integrals</title>
		<link rel="stylesheet" href="/style.css" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<script id="MathJax-script" async src="https://static.andrewyu.org/mathjax/tex-svg.js"></script>
		<meta charset="utf-8" />
	</head>
	<body>
		<h1>TeXmacs Maxima Integrals</h1>
		<p>Article ID: 18</p>
		<p>
		I've been trying to get <a href="https://www.texmacs.org/">TeXmacs</a> with its <a href="https://maxima.sourceforge.io/">Maxima</a> <a href="https://www.texmacs.org/tmweb/documents/tutorials/maxima-tutorial/maxima-tutorial.en.html">plugin</a> to work.
		</p>
		<p>
		Enabling the ``mathematical input'' mode in its interactive sessions I can use TeXmacs as a nice computer algebra system. However, an issue arises when I use integration.
		</p>
		<p>
		If I enter \(\displaystyle\int x\,\mathrm{d}\,x\) with ``<code>\int &lt;enter&gt;x d&lt;tab&gt;&lt;tab&gt;x</code>'' (spaces here are actually typed in while the ``<code>&lt;tab&gt;</code>''s and ``<code>&lt;enter&gt;</code>''s are their respective keys), I get this idiosyncratic error:
		</p>
		<pre>incorrect syntax: 1 is not an infix operator
integrate( x 1,
	     ^</pre>
		<p>
		This seems to be a bug when TeXmacs is translating things into Maxima. Just replace the ``<code>&lt;tab&gt;</code>'' between the integrand and the ``\(\mathrm{d}\)'' with a multiplication operator entered by ``<code>*</code>''. For example, <code>\int &lt;enter&gt;x*d&lt;tab&gt;&lt;tab&gt;x</code> yields the correct result of \(\displaystyle\frac{x^2}{2}\) rather than the nonsensical error.
		</p>
		<p>
		For reference, the source code of a demonstration document is included below in Scheme and XML-like (?) formats.
		</p>
		<pre>(document (TeXmacs "2.1.1") (style (tuple "generic" "maxima")) (body (document (session "maxima" "default" (document (unfolded-io-math (document (with "color" "red" (concat "(" (with "math-font-family" "rm" "%i") "8) "))) (document (concat (big "int") " x <mathd> x")) (document "" "incorrect syntax: 1 is not an infix operator" "integrate( x 1," "             ^")) (unfolded-io-math (document (with "color" "red" (concat "(" (with "math-font-family" "rm" "%i") "8) "))) (document (concat (big "int") "x*<mathd> x")) (document "" (concat " " (math (with "math-display" "true" (concat (text (with "font-family" "tt" "color" "red" (concat "(" (with "math-font-family" "rm" "%o8") ") "))) (frac (concat "x" (rsup "2")) "2"))))))))))) (initial (collection (associate "page-medium" "paper") (associate "preamble" "true") (associate "prog-scripts" "maxima"))))</pre>
		<pre>&lt;TeXmacs|2.1.1&gt;

&lt;style|&lt;tuple|generic|maxima&gt;&gt;

&lt;\body&gt;
  &lt;\session|maxima|default&gt;
    &lt;\unfolded-io-math&gt;
      &lt;with|color|red|(&lt;with|math-font-family|rm|%i&gt;8) &gt;
    &lt;|unfolded-io-math&gt;
      &lt;big|int&gt; x \&lt;mathd\&gt; x
    &lt;|unfolded-io-math&gt;
      \;

      incorrect syntax: 1 is not an infix operator

      integrate( x 1,

      \ \ \ \ \ \ \ \ \ \ \ \ \ ^
    &lt;/unfolded-io-math&gt;

    &lt;\unfolded-io-math&gt;
      &lt;with|color|red|(&lt;with|math-font-family|rm|%i&gt;8) &gt;
    &lt;|unfolded-io-math&gt;
      &lt;big|int&gt;x*\&lt;mathd\&gt; x
    &lt;|unfolded-io-math&gt;
      \;

      \ &lt;math|&lt;with|math-display|true|&lt;text|&lt;with|font-family|tt|color|red|(&lt;with|math-font-family|rm|%o8&gt;)
      &gt;&gt;&lt;frac|x&lt;rsup|2&gt;|2&gt;&gt;&gt;
    &lt;/unfolded-io-math&gt;
  &lt;/session&gt;
&lt;/body&gt;

&lt;\initial&gt;
  &lt;\collection&gt;
    &lt;associate|page-medium|paper&gt;
    &lt;associate|preamble|false&gt;
    &lt;associate|prog-scripts|maxima&gt;
  &lt;/collection&gt;
&lt;/initial&gt;</pre>
		<div id="footer">
			<hr />
			<p><a href="/">Andrew Yu's Website</a></p>
		</div>
	</body>
</html>
pan class="nx">Colors []string `json:"colors"` // Thumbs []thumb `json:"thumbs"` } // type thumb struct { // Small string `json:"small"` // Original string `json:"original"` // Large string `json:"large"` // } var ( t time.Duration api string apiKey string dump bool quiet bool random bool version bool pathOnly bool fetchOnly bool ) func main() { parseFlags() if version { cetus.Version() return } rand.Seed(time.Now().Unix()) // Convert timeout to seconds t = t * time.Second body, err := whBody() if dump { fmt.Println(body) return } wh := wh{} err = json.Unmarshal([]byte(body), &wh) cetus.ErrChk("body unmarshal failed", err) // if random was set then wh holds list of multiple responses, // choose a random response from the list i := rand.Intn(len(wh.Photos)) whPhoto := wh.Photos[i] printDetails(whPhoto) // if fetchOnly is true then don't set background if fetchOnly { return } err = background.Set(whPhoto.Path) cetus.ErrChk("setting background failed", err) } func parseFlags() { flag.BoolVar(&quiet, "quiet", false, "No output") flag.BoolVar(&version, "version", false, "Cetus version") flag.BoolVar(&fetchOnly, "fetch-only", false, "Don't set background, only fetch info") flag.BoolVar(&dump, "dump", false, "Only dump received response") flag.BoolVar(&random, "random", true, "Choose a random image") flag.BoolVar(&pathOnly, "path-only", false, "Print only path of the image") flag.StringVar(&api, "api", "https://wallhaven.cc/api/v1/search", "Wallhaven Search API URL") flag.StringVar(&apiKey, "api-key", "", "Wallhaven API Key") flag.DurationVar(&t, "timeout", 32*time.Second, "Timeout for http client in seconds") flag.Parse() } func printDetails(whPhoto photo) { if quiet { return } if pathOnly { cetus.PrintPath(whPhoto.Path) return } fmt.Printf("Id: %s\n", whPhoto.Id) fmt.Printf("URL: %s\n", whPhoto.Url) fmt.Printf("Short URL: %s\n", whPhoto.ShortUrl) fmt.Printf("Source: %s\n", whPhoto.Source) fmt.Printf("Date: %s\n\n", whPhoto.CreatedAt) fmt.Printf("Resolution: %s\n", whPhoto.Resolution) fmt.Printf("Ratio: %s\n", whPhoto.Ratio) fmt.Printf("Views: %d\n", whPhoto.Views) fmt.Printf("Favorites: %d\n", whPhoto.Favorites) fmt.Printf("File Size: %d KiB\n", whPhoto.FileSize/1024) fmt.Printf("Category: %s\n", whPhoto.Category) } func whBody() (string, error) { reqInfo := make(map[string]string) reqInfo["api"] = api if random { reqInfo["random"] = "true" } body, err := wallhaven.GetWhJson(reqInfo, t) return body, err }