Solved

# How to represent ln^2(x) in Java

Posted on 2010-08-14
1,029 Views
How to represent ln^2(x) in Java?

Math.log(x) would work for just ln(x) but how do I do ln^2(x)?
0
Question by:Midwest
• 2
• 2
• 2
• +1

LVL 92

Expert Comment

0

Author Comment

It is not ln(subscript(2))x it is ln^2(x).  See image.  This is different right?
img.JPG
0

LVL 84

Accepted Solution

ozo earned 450 total points
Math.log(x)*Math.log(x)
0

Author Comment

So, would this work?  Math.pow((Math.log(x), 2));
0

LVL 92

Expert Comment

If what you need is natural log squared, then yes
0

LVL 84

Expert Comment

yes
0

LVL 4

Assisted Solution

QCD earned 50 total points
If by ln^2(x), you actually mean ln(ln(x)), this would be Math.log(Math.log(x))

If you mean (ln(x))^2 = ln(x) * ln(x), this would be Math.pow(Math.log(x),2), as a number of people have indicated.

The notation itself can be ambiguous.  It would help if we knew the context.

Additionally, in some contexts, log(x) is understood to be the natural log, ln(x).  In others, it is understood to be base 2, or even base 10.
0

## Featured Post

### Suggested Solutions

This is a research brief on the potential colonization of humans on Mars.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.