Skip to content

Commit

Permalink
Parenthesize integrand with addition or subtraction. Update Symtegrat…
Browse files Browse the repository at this point in the history
…ion version.
  • Loading branch information
chungyc committed Jan 13, 2025
1 parent 3fb8a29 commit 351ca11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Symtegration/Site/Content.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
module Symtegration.Site.Content where

import Symtegration
import Symtegration.Symbolic
import Text.Blaze.Html5

-- | Turn a list of expressions into HTML showing an expression integrated into its integral.
Expand All @@ -18,7 +19,9 @@ integralExamples = mapM_ (p . integralExample)
integralExample :: Expression -> Html
integralExample e = toHtml equation
where
equation = "\\( \\int " <> toLaTeX e <> " \\, dx = " <> t <> " \\)"
equation = "\\( \\int " <> delimit (toLaTeX e) <> " \\, dx = " <> t <> " \\)"
delimit v | (_ :+: _) <- e = brace v | (_ :-: _) <- e = brace v | otherwise = v
brace v = "\\left(" <> v <> "\\right)"
t
| Just e' <- integrate "x" e = toLaTeX e'
| otherwise = "\\bot"
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ packages:
# Dependency packages to be pulled from upstream that are not in the snapshot.
extra-deps:
- git: https://github.com/symtegration/symtegration
commit: '7d49eca9f48adf6740dcb3a7934872e3b91a30e6'
commit: 'f0d317fed5457bc96c69495c26a53eab8b7716e1'

0 comments on commit 351ca11

Please # to comment.