Evaluating exp(x) * sin(x): What's the Problem?

  • Thread starter Thread starter waht
  • Start date Start date
Click For Summary
SUMMARY

The discussion centers on the evaluation of the expression exp(x) * sin(x) in a programming environment, which results in a nonconformant arguments error due to the use of the standard multiplication operator (*). The solution involves using the element-wise multiplication operator (.*) to correctly compute the product of the two functions over the array x = (-10:0.1:10). This adjustment yields a valid 1 x 101 matrix output without errors.

PREREQUISITES
  • Understanding of element-wise operations in programming languages
  • Familiarity with the syntax of matrix operations
  • Basic knowledge of the exponential function exp(x) and sine function sin(x)
  • Experience with array manipulation in a programming environment
NEXT STEPS
  • Research the use of element-wise operators in MATLAB or similar programming languages
  • Explore matrix operations and their implications in numerical computing
  • Learn about vectorization techniques to optimize performance in mathematical computations
  • Investigate common errors related to matrix dimensions and how to resolve them
USEFUL FOR

Mathematicians, data scientists, and programmers who work with numerical computations and need to understand matrix operations and error handling in programming environments.

waht
Messages
1,502
Reaction score
4
When I generate a list x = (-10:0.1:10)

and want to evaluate it using a function

exp(x) * sin(x)

I get this error

error: operator *: nonconformant arguments (op1 is 1x101, op2 is 1x101)
error: evaluating binary operator `*' near line 4, column 11
error: evaluating assignment expression near line 4, column 3

wondering what's the problem here?
 
Physics news on Phys.org
try exp(x).*sin(x) which is a matrix element by element multiply which should give you a 1 x 101 matrix.
 
Thanks in worked. Didn't know you had to use .* operator.
 

Similar threads

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