7
1
Your goal is to write a program that will print out the Laplace transform of a polynomial function with integer coefficients f(x). The Laplace transform of f(x) is defined as the integral from 0 to infinity of f(x) e^(-sx) dx.
The standard input for the polynomial function will be
a+bx+cx^2+dx^3+...
If the coefficient is zero, that term is omitted. It can be taken in from any standard type of input.
This is valid input: 1+x^2-5x^4+20x^5
These aren't:
0
1+0x
1+x^1
x^0+x
You may output from any standard type of output, in any readable order. Trailing newline is permitted. No using built in evaluation functions.
Examples:
Input: 1
Output: 1/s
Input: 3-x
Output: 3/s-1/s^2
This is code golf, so the shortest entry in bytes wins.
Will the polynomial always have integer coefficients? – Alex A. – 2015-08-11T02:36:02.237
@AlexA. Yes. Edited into the question. – Teoc – 2015-08-11T02:36:36.320
The Laplace transform of
1
is1/s
, not-1/s
. – Dennis – 2015-08-11T02:43:27.007Also, does the output have to follow the same conventions as the input, i.e.,
0/s
and1/s^1
are not allowed? – Dennis – 2015-08-11T02:48:52.953@Dennis It can be any form. – Teoc – 2015-08-11T02:49:28.823
It's probably obvious, but what exactly does this mean: "evaluation functions"? I'm assuming I can't use any (built-in)
laplace(f(x))
-function, but what aboutintegral(f(x))
? – Stewie Griffin – 2015-08-11T07:50:02.390Is
1+2*x
valid input (note the *) – Stewie Griffin – 2015-08-11T08:56:29.440@Stewie Not valid for both questions. – Teoc – 2015-08-12T06:40:20.677