Skip to content

Commit

Permalink
fix for Lemniscate of Bernoulli in calc test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Ferris committed Apr 12, 2024
1 parent a5c4fb3 commit 802794a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Polyrat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,19 @@ export class Polyrat {
f = -f
t += '-'
}
if (f !== 1n) t += f
let products: string[] = []
if (f !== 1n) products.push(f.toString())
const dimensions = exponents.split(',')
for (let i = 0; i < dimensions.length; i++) {
if (dimensions[i] !== '0') {
let term = this.latinSymbols[i] ?? '?'
if (dimensions[i] !== '1') {
term += `^${parseInt(dimensions[i] ?? '0', 10)}`
}
t += term
products.push(term)
}
}
if (products.length) t += products.join('*')
if (t) s.s += t
}
return s.toString()
Expand All @@ -241,7 +243,7 @@ export class Polyrat {
const recipricol = exponent < 0
// pow doesn't work for < 0
// t.push(`pow(${this.symbols[i]},${exponent}.0)`)
// muliply instead
// multiply instead
if (recipricol) {
t.push('1.0/(1.0')
exponent = -exponent
Expand Down

0 comments on commit 802794a

Please sign in to comment.