Replies: 11 comments
-
I thought I'd take a look at this just for something to do. I fixed it for sin, cos, tan and cot by adding if/switch statements for specific cases in the trig function js files e.g. in tan.js
idk if this is the sort of thing you were looking for because it does add in the NaN which isnt ideal and you could just remove that part and let it go to the default. Anyway I hope this is the sort of thing you were looking for, it does fix the simplification so sin(pi)=0 in every case I could find and the same for the other generic trig functions I also added tests to check these cases as well and changed cot tests to actually test cot rather than 1/cot for normal numbers, I havent touched BigNumbers, Complex etc |
Beta Was this translation helpful? Give feedback.
-
@Veeloxfire thanks for looking into this! This is definitely the direction we should be thinking: replacing This issue is about algebraic simplification though, not numerical simplification. So we're looking to extend the rules that the console.log(math.simplify('log(e)').toString()) // already returns '1'
console.log(math.simplify('sin(pi)').toString()) // should return '0'
console.log(math.simplify('sin(pi / 2)').toString()) // should return '1'
// etc ...
Can you give an example? It may be the difference between numeric only implementation and the implementation supporting multiple data types (number, BigNumber, Fraction, etc)? |
Beta Was this translation helpful? Give feedback.
-
In my efforts to enhance simplify() as much as is plausible, I thought I might attack this one. Some guidance would help: should this be construed to extend to identities among the built-in functions as well? In other words, should it include such items as |
Beta Was this translation helpful? Give feedback.
-
Oh, another specific one I wanted to ask about was |
Beta Was this translation helpful? Give feedback.
-
Yes indeed, so we really rely on the meaning that we attach to named functions like
Yes that is correct, |
Beta Was this translation helpful? Give feedback.
-
Ah, true; we can see how simplify fares with "bidirectional" rules that apply if they (ultimately) reduce the complexity, and if the combinatorial explosion is not too bad, |
Beta Was this translation helpful? Give feedback.
-
Yes, it is a nice one 👍 |
Beta Was this translation helpful? Give feedback.
-
Request (#2502): I want to simplify |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing your use case María, that helps 👍 |
Beta Was this translation helpful? Give feedback.
-
So one question when we get around to this: should sqrt(expr) just simplify to (expr)^(1/2)? Or vice versa? Or simplify to expr^(1/2) at the beginning of simplification with that exponent marked in some way, and then if that exponent is around at the end of simplification convert it back to sqrt? Thoughts are welcome. |
Beta Was this translation helpful? Give feedback.
-
That is a good question. To me, |
Beta Was this translation helpful? Give feedback.
-
New issue originating from #925
Beta Was this translation helpful? Give feedback.
All reactions