A simple symbolic expression in Matlab

  • Context: MATLAB 
  • Thread starter Thread starter Dr_Pill
  • Start date Start date
  • Tags Tags
    Expression Matlab
Click For Summary

Discussion Overview

The discussion revolves around the use of symbolic expressions in Matlab, specifically the evaluation of the equation x² - 1 = (x + 1)(x - 1). Participants explore the behavior of Matlab's logical function in checking mathematical equivalence and suggest alternative methods for validation.

Discussion Character

  • Technical explanation, Conceptual clarification, Homework-related

Main Points Raised

  • One participant attempts to verify the equivalence of two expressions using Matlab's logical function and reports that it returns 0.
  • Another participant suggests that the logical function may not be suitable for checking equations that require simplification and recommends using the isAlways function instead.
  • A different participant interprets the result of 0 as potentially valid under certain conditions, noting that for x = 0, both expressions yield -1.
  • One participant provides a definition of the isAlways function, explaining its purpose in checking the validity of conditions for all possible values of symbolic variables.
  • Another participant clarifies that the original poster is analyzing the truthiness of the expressions rather than seeking a solution.

Areas of Agreement / Disagreement

Participants express differing views on the appropriateness of the logical function for this type of evaluation, with some suggesting alternatives while others provide interpretations of the results. No consensus is reached on the best approach to validate the expressions.

Contextual Notes

Participants note that the logical function may not recognize mathematical equivalence in certain cases, indicating a limitation in its application for symbolic expressions.

Dr_Pill
Messages
41
Reaction score
0
I tried to check

x²-1 = (x+1)(x--1)

So I did the following:

syms x

f = x^2 - 1
g = (x+1)*(x-1)

logical(f == g)

Matlab returns 0.

Any suggestions? :)

(Matlab beginner by the way)
 
Physics news on Phys.org
Maybe this? From

http://www.mathworks.com/help/symbolic/logical.html

"Do not use logical to check equations and inequalities that require simplification or mathematical transformations. For such equations and inequalities, logical might return unexpected results. For example, logical does not recognize mathematical equivalence of these expressions:
...
To test the validity of equations and inequalities that require simplification or mathematical transformations, use isAlways:

isAlways(sin(x)/cos(x) == tan(x))
ans = 1"
 
Dr_Pill said:
I tried to check

x²-1 = (x+1)(x--1)

So I did the following:
Matlab returns 0.

Any suggestions? :)

(Matlab beginner by the way)

If I'm interpreting the result correctly,
0 is a legit answer, if x = 0, f = -1 and g= -1, so f=g.

Never used the symbolic toolbox, just thought I'd point that out.
 
Ah, I see; he's analyzing the truthiness, not looking for a solution.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K