Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8267593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:35:25+00:00 2026-06-08T05:35:25+00:00

I’m working on some numerical analysis assignment where I’m supposed to evaluate, plot and

  • 0

I’m working on some numerical analysis assignment where I’m supposed to evaluate, plot and differentiate mathematical expressions. Among other stuff. I implemented expression trees with Java.

So far, I can build the expression tree, display it with Latex, evaluate it, plot it and get its derivative. The is the interface that is implemented by the composite functions in the tree has the following methods:
Function[] child();
void addChild(Function chld);
double evaluate(HashMap subMap);
String toLatex();
int precedence();
Function derivative();

The implementations I coded so far are: Constant, Variable, Add, Subtract, Multiply, Divide, Power, Sine, Cosine, Ln.
Now, when I differentiate some basic function, I get it in a non-reduced form:
d/dx(x^2) ===> x^2 * (1 * 2 / x + 0 * ln(x))
That’s because the derivative is implemented in the most general way.

The solution I thought of is that on the construction of each node f in the tree, given f‘s children, I reduce the children recursively and then do some naive reconstruction. After such reconstruction, the children are “together” reduced with respect to f.
For example, given the expression 0 * x, the tree should look like:

  *
 / \
0   x

On the construction of the * node, if one of its children is a zero constant, the * node becomes a zero constant. And of course throws away its children.

  0


And so on for all the different cases for multiplication.
This requires a lot of analysis on my behalf and may not cover all the cases — keeping in mind that multiplication isn’t the only function required –.

The task is: given an expression tree, how can I do basic reduction on it? If you could refer me to any links or papers that present a solution for this problem — preferably in an elegant OO way — or if you have tackled it before, your help would be really appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:35:27+00:00Added an answer on June 8, 2026 at 5:35 am

    I have quite similar task: I need to simplify algebraic expressions e.g. (-1)*a + (b - a) + 2*a => b

    After a bit of googling it was found that Computer algebra systems should deal with such tasks.

    There is a good list of such libraries here: http://en.wikipedia.org/wiki/Comparison_of_computer_algebra_systems

    Have just tried MathEclipse/symja library – it has quite nice online evaluator (implemented using this library) which seems to do just what I need i.e. reduce expressions like 0*x => 0, a - b + (-1)*a => -b.

    Also you may check other Java CAS libraries.

    Hope this helps…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.