Symbolic sqrt?
See original GitHub issueIs it possible to treat a square root as it is, e.g. √5, without converting it to a number?
Specifically, I’d like to do the following:
sqrt(5) //=> √5 object
sqrt(2) + sqrt(3) //=> √2 + √3
sqrt(2) + sqrt(2) //=> 2 * √2
sqrt(3 * 3) //=> 3
I have read some examples and, like in the custom_datatatype.js example, I thought I could add a custom data type for √. But I couldn’t figure out how to return the value as it is of add, sub, etc.
If anyone knows how to do it right, please let me know! Finally, thank you for such a wonderful library.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Square root - Wikipedia
The symbol "√" for the square root was first used in print in 1525, in Christoph Rudolff's Coss.
Read more >Python | sympy.sqrt() method - GeeksforGeeks
Returns: Returns square root in terms of values and symbolically simplified mathematical expression corresponding to the input expression.
Read more >Symbolic sqrt(2) and sin(pi) - Specific Domains - Julia Discourse
Basic question on Julia symbolic. How to keep exp(1) as is and not convert it to a floating point number?
Read more >What is square root symbol? - Definition from WhatIs.com
The square root symbol is used to indicate the quantity or quantities which, when multiplied by itself or themselves, results in the quantity...
Read more >Function Reference: @sym/sqrt - Octave Forge - SourceForge
Note: this file is autogenerated: if you want to edit it, you might want to make changes to 'generate_functions.py' instead. Package: symbolic.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s good to hear 👍
About simplifying expressions with matrices: that is an open feature request, see #1913. Help is welcome 😃
Thanks for the link Viktor, I hadn’t heard about Nerdamer before, it looks great! I’ve linked to it from the downloads page.
@yasuhito The reason is that there is a built-in rule which evaluates functions containing constants, also for
sqrt
. This is thesimplifyConstant
rule: simplify.js#L300. So, what you need is create your own version of this function, which first checks the specialsqrt
rule, and otherwise fallback to the old behavior. Here a full example:You’re fully flexible in which rules you do or do not want to apply with the function simplify 😄