我使用bookdown来生成html和PDF文档.如何在定理和示例环境中使用内联R代码的结果?
这是我尝试过的:
---
title: "Test"
output:
bookdown::pdf_book:
toc: false
html_document:
toc: false
---
```{r}
a <- 2
b <- 3
```
If $a = `r a`$ and $b = `r b`$, then $a + b = `r a + b`$.
```{theorem}
If $a = `r a`$ and $b = `r b`$, then $a + b = `r a + b`$.
```
```{example}
If $a = `r a`$ and $b = `r b`$, then $a + b = `r a + …Run Code Online (Sandbox Code Playgroud) 我想在同一(部分)计数器上对所有定理和推论进行编号.但是当我这样做时,Cleveref将它们都命名为"定理".这是一个最小的例子:
\documentclass{amsart}
\usepackage{amsthm, cleveref}
%\crefname{theorem}{theorem}{theorems}
%\crefname{corollary}{corollary}{corollaries}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\begin{document}
\section{Section title}
\begin{theorem}\label{thm:test}
Here is the theorem.
\end{theorem}
\begin{corollary}\label{cor:test}
Here is the corollary.
\end{corollary}
The theorem reference is given by \cref{thm:test} and the corollary reference is given by \cref{cor:test}.
\end{document}
Run Code Online (Sandbox Code Playgroud)
这里,推论参考是'定理1.2'.即使明确说明crefname,此问题仍然存在.
有什么建议?
我正在尝试找到一种将以下一阶逻辑表达式放入Prolog中的方法:
(p(0) or p(1)) and not (p(0) and p(1))
Run Code Online (Sandbox Code Playgroud)
这意味着它应该以以下方式响应查询:
?- p(0)
Yes.
?- p(1)
Yes.
?- p(0),p(1).
No.
Run Code Online (Sandbox Code Playgroud)
我试图翻译逻辑表达式:
(p(0) or p(1)) and not (p(0) and p(1)) <=>
(not p(0) -> p(1)) and (p(0) -> not p(1)) <=>
p(0) <-> not p(1)
Run Code Online (Sandbox Code Playgroud)
使用Clarks补全(表示每个定义理论都可以通过给出if-halves放入逻辑程序中),我可以获得:
p(0) :- not p(1).
Run Code Online (Sandbox Code Playgroud)
不幸的是,这种结果理论仅是合理的(它不会得出虚假信息),而并不完整(例如:无法得出p(1))。这是克拉克斯定理的结果。
有人知道是否有更好的解决方案?谢谢!
您好,任何人都可以帮我解决这个问题
T(n)=T(n^(1/2)) + theta (lg lg n)
Run Code Online (Sandbox Code Playgroud)
这就是我到目前为止所做的
m = lg n
s(m)=s(m/2) + theta (lg m)
Run Code Online (Sandbox Code Playgroud)
在这里应用主定理
a=1 b=2
m^log 2 (1) = m^0 =1
Run Code Online (Sandbox Code Playgroud)
现在卡住了.
根据 B\xc3\xb6hm-Jacopini 定理,只需使用三个语句即可编写算法:
\n\n许多老师认为定理是一种信仰行为,他们教导不要使用(goto、jump、break、multiple return 等),因为这些指令是邪恶的。
\n\n但当我要求解释时,没有人能够提供定理的证明。
\n\n就我个人而言,我不认为该定理是错误的,但我认为它在现实世界中的适用性并不总是更好的选择。
\n\n所以我做了一点搜索,这些是我的疑问:
\n\n该定理已经通过流程图结构的归纳得到了证明,但它真的适用于计算机程序吗?
\n根据维基百科“B\xc3\xb6hm 和 Jacopini\ 的算法作为程序转换算法并不真正实用,因此为该方向的进一步研究打开了大门”。
定理的一个结果证明,每个“goto”都可以通过归纳转化为选择或迭代,但是效率呢?\n我找不到任何证据表明每个算法都可以重写并保持相同的性能。
递归,递归算法真的可以仅使用序列、选择和迭代来编写吗?\n我知道某些递归算法可以优化为循环(想想尾递归),但真的可以适用于所有算法吗?
干净的代码,我知道滥用跳转可能会创建出可怕的代码,但我认为在某些情况下正确使用循环中的中断可以提高代码的可读性。
样本:
\n\nn = 0;\nwhile (n < 1000 || (cond1 && cond2) || (cond3 && cond4) || (cond5 && cond6)) \n{ \n n++; \n //The rest of code \n} \nRun Code Online (Sandbox Code Playgroud)\n\n可以重写为:
\n\nfor (n = 0; n < 1000; n++)\n{\n if (cond1 && …Run Code Online (Sandbox Code Playgroud)